Skip to main content

Module dimensionality_reducer

Module dimensionality_reducer 

Source
Expand description

§Dimensionality Reducer

PCA-based dimensionality reduction for embedding vectors. Implements power-iteration PCA for top-k eigenvector extraction, plus a thin Truncated SVD wrapper.

§Algorithm

  1. Center the data (subtract column means).
  2. Compute the covariance matrix.
  3. Use power iteration with deflation to extract the top-k eigenvectors.
  4. Project data onto the component subspace.

Structs§

PcaReducer
PCA dimensionality reducer using power-iteration eigenvector extraction.
ReductionResult
Output of a fit_transform call.
TruncatedSvd
Truncated SVD: operates on the raw (uncentered) data matrix.

Enums§

ReductionError
Errors from dimensionality reduction operations.

Functions§

center_data
Center the data by subtracting column means. Returns (centered_data, column_means).
dot_product
Compute the dot product of two equal-length slices.
mat_vec_mul
Multiply matrix mat (m × n) by vector vec (n) → result (m).
normalize
Normalise a vector in-place (L2 norm). No-op for zero vectors.