IncrementalPCA<T>

Models & Types ยท AiDotNet.Preprocessing.DimensionalityReduction

Incremental Principal Component Analysis for large datasets.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> โ†’ IncrementalPCA<T>

For Beginners

Regular PCA needs all data in memory at once. Incremental PCA processes data in chunks:

  • Feed data in batches (e.g., 1000 rows at a time)
  • Updates its understanding of the data with each batch
  • Produces similar principal components as regular PCA
  • Uses much less memory for large datasets

How It Works

IncrementalPCA processes data in batches, making it suitable for datasets too large to fit in memory. It produces similar results to standard PCA but with lower memory requirements.

The algorithm updates the covariance matrix incrementally as each batch is processed, then computes principal components from the final estimate.

Constructors

Constructor Summary
IncrementalPCA(int nComponents, int batchSize, bool whiten, int[] columnIndices) Creates a new instance of IncrementalPCA.

Properties

Property Summary
Matrix<T> Components { get; } Gets the principal components.
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.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
bool Whiten { get; } Gets whether whitening is applied.
int BatchSize { get; } Gets the batch size for incremental updates.
int NComponents { get; } Gets the number of components to keep.
int NSamplesSeen { get; } Gets the number of samples seen during fitting.

Methods

Method Summary
string[] GetFeatureNamesOut(string[] inputFeatureNames) Gets the output feature names after transformation.
void PartialFit(Matrix<T> batch) Partially fits the model with a new batch of data.