Dimensionality Reduction
Explore PCA, Kernel PCA, FastICA, NMF, Incremental PCA, Sparse PCA, and Truncated SVD in JavaScript and TypeScript with @kanaries/ml.
View as MarkdownModule overview
The Decomposition module reduces feature dimensions while preserving useful signal for visualization, denoising, compression, and downstream modeling. These algorithms are often used before clustering, classification, or charting when raw feature spaces are too large or too noisy.
This module is a strong fit when:
- you need lower-dimensional inputs for charts or interactive analysis
- you want to compress features before training another model
- you need different strategies for dense versus sparse matrices
JavaScript implementation
@kanaries/ml provides decomposition algorithms directly in JavaScript and TypeScript so frontend and full-stack teams can run feature compression in the same runtime that already owns embeddings, visualizations, or data pipelines. This is especially useful when dimensionality reduction is part of a browser-based analytics experience or a Node.js preprocessing step.
If someone searches for "PCA in JavaScript" or "Truncated SVD in TypeScript", this module is the right entry point.
Quick navigation
- PCA: dense feature compression and variance-preserving projections
- Sparse PCA: more interpretable sparse components
- Truncated SVD: latent factors for sparse or vectorized inputs
- Kernel PCA: nonlinear kernel embeddings
- FastICA: independent signal separation
- NMF: non-negative, parts-based latent factors
- Incremental PCA: batch-wise, memory-aware PCA
- Factor Analysis: latent Gaussian factors with per-feature noise
- Latent Dirichlet Allocation: topic mixtures from word counts
Detailed module guide
How to choose an algorithm
- Use PCA for dense numeric features when variance preservation matters most.
- Use Truncated SVD for sparse matrices such as TF-IDF or one-hot vectors.
- Use Sparse PCA when component interpretability matters alongside dimensionality reduction.
- Use Kernel PCA for nonlinear structure, FastICA for independent sources, NMF for non-negative additive factors, or Incremental PCA for streamed batches.
JavaScript deployment notes
- Standardize dense continuous features before PCA-style methods when appropriate.
- Use decomposition to simplify data before charting, clustering, or supervised learning.
- In browser apps, dimensionality reduction is often most valuable when it feeds directly into interactive visualizations.
Categorical Naive Bayes
Learn what Categorical Naive Bayes does, when to use it, and how to run CategoricalNB in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.
PCA
Learn what PCA does, when to use it, and how to run PCA in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.