Skip to main content

Module pca

Module pca 

Source
Expand description

Principal Component Analysis (ISL ch 12, PRML ch 12) — the eigendecomposition of the feature covariance, reusing linear_algebra::{gemm, eigen} (no new solver). Mission note: PCA is the principled way to choose the engine’s 10D→5D NQuin relevance projection.

Centre the data, form the p×p covariance C = Xcᵀ Xc /(n−1) with gemm, symmetric-eigendecompose it with symmetric_eigen, and sort the eigenpairs descending. Eigenvalue k is the variance along principal component k. Kernel-class DenseLinear (covariance GEMM), dispatch-ready.

Structs§

Pca
A fitted PCA. components holds the principal axes as rows (n_components × p), ordered by descending explained variance; explained_variance[k] is the variance (eigenvalue) along component k.

Functions§

fit
Fit PCA to a row-major n × p matrix. None-equivalent failures are returned as LearningError (fail closed): InvalidDimension, InsufficientData (n < 2), or Singular if the eigensolver cannot decompose the covariance.