Incremental PCA
Process numeric data in batches with the @kanaries/ml IncrementalPCA JavaScript implementation for memory-aware browser and Node.js workflows.
View as MarkdownAlgorithm overview
Incremental PCA updates a low-rank SVD one batch at a time. It is useful when a complete dataset should not be retained in memory, while still producing PCA-style projections and inverse transforms.
JavaScript implementation
@kanaries/ml follows sklearn's mean-corrected incremental SVD update. Call partialFit for streamed batches, or fit to let the estimator split an in-memory matrix by batchSize.
Quick start example
import { Decomposition } from '@kanaries/ml';
const batchOne = [[0, 1, 2], [1, 2, 3], [2, 1, 4]];
const batchTwo = [[3, 4, 2], [4, 3, 1], [5, 5, 0]];
const nextBatch = [[2, 3, 2]];
const pca = new Decomposition.IncrementalPCA({ nComponents: 2 });
pca.partialFit(batchOne).partialFit(batchTwo);
const embedding = pca.transform(nextBatch);
console.log(embedding);Detailed API reference
new Decomposition.IncrementalPCA({ nComponents?: number | null, batchSize?: number })partialFit(X: number[][]): thisupdates the retained SVD.fit(X: number[][]): voidresets and processes batches.transformandinverseTransformproject data.components,mean,explainedVariance,singularValues, andnSamplesSeenexpose learned state.
The first partialFit batch must contain at least nComponents samples and features.
Non-negative Matrix Factorization (NMF)
Factor non-negative data into additive parts using the @kanaries/ml NMF JavaScript and TypeScript implementation in browser or Node.js.
Factor Analysis
Fit a latent Gaussian factor model with per-feature noise in browser or Node.js using @kanaries/ml FactorAnalysis.