SparsePCA<T>

Models & Types · AiDotNet.Preprocessing.DimensionalityReduction

Sparse Principal Component Analysis using L1 regularization.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → SparsePCA<T>

For Beginners

Sparse PCA creates “simpler” principal components:

  • Standard PCA: Component = 0.3Feature1 + 0.2Feature2 + 0.1*Feature3 + …
  • Sparse PCA: Component = 0.5Feature1 + 0Feature2 + 0.4Feature3 + 0…
  • Zeros make it easier to interpret what each component represents

How It Works

SparsePCA finds sparse principal components by applying L1 regularization (LASSO-like penalty) to the component loadings. This results in components where many loadings are exactly zero, making them more interpretable.

Unlike standard PCA where each component is a combination of ALL features, sparse PCA produces components that depend on only a subset of features.

Constructors

Constructor Summary
SparsePCA(int nComponents, double alpha, double ridge, int maxIter, double tol, int? randomState, int[] columnIndices) Creates a new instance of SparsePCA.

Properties

Property Summary
Matrix<T> Components { get; } Gets the sparse components (each row is a component).
Vector<T> Error { get; } Gets the reconstruction error for each iteration.
Vector<T> Mean { get; } Gets the mean of each feature.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
double Alpha { get; } Gets the sparsity regularization parameter.
double Ridge { get; } Gets the ridge regularization parameter.
int NComponents { get; } Gets the number of components.

Methods

Method Summary
string[] GetFeatureNamesOut(string[] inputFeatureNames) Gets the output feature names after transformation.