PCA<T>

Models & Types · AiDotNet.Preprocessing.DimensionalityReduction

Principal Component Analysis for dimensionality reduction.

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

For Beginners

PCA transforms your features into new features called “principal components” that are:

  • Uncorrelated with each other
  • Ordered by importance (how much variance they explain)
  • Linear combinations of your original features

Example: 100 features might be reduced to 10 principal components that capture 95% of the information in your data.

How It Works

PCA finds the directions of maximum variance in the data and projects the data onto these principal components. This reduces dimensionality while preserving as much variance as possible.

PCA is useful for:

  • Reducing the number of features while retaining most information
  • Removing multicollinearity between features
  • Visualizing high-dimensional data
  • Noise reduction

Constructors

Constructor Summary
PCA(int? nComponents, double? varianceRatio, bool whiten, int[] columnIndices) Creates a new instance of PCA.

Properties

Property Summary
Matrix<T> Components { get; } Gets the principal components (each row is a component).
Vector<T> ExplainedVariance { get; } Gets the explained variance for each component.
Vector<T> ExplainedVarianceRatio { get; } Gets the explained variance ratio for each component.
Vector<T> Mean { get; } Gets the mean of each feature.
Vector<T> SingularValues { get; } Gets the singular values.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
bool Whiten { get; } Gets whether whitening is applied.
double? VarianceRatio { get; } Gets the target variance ratio to retain.
int NComponentsOut { get; } Gets the number of components after fitting.
int? NComponents { get; } Gets the number of components to keep.

Methods

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