@kanaries/ml
API Reference

JavaScript Machine Learning APIs

Explore machine learning APIs in JavaScript and TypeScript with @kanaries/ml, including clustering, classification, anomaly detection, dimensionality reduction, and workflow utilities.

View as Markdown

Module overview

This page is the entry point to the full @kanaries/ml API catalog. It helps JavaScript and TypeScript teams choose the right algorithm family before diving into individual estimators such as K-Means, Logistic Regression, Isolation Forest, PCA, or k-Nearest Neighbors.

Use this catalog when you already know the kind of problem you need to solve, such as:

  • classification or regression on tabular data
  • clustering or segmentation without labels
  • anomaly detection on product, telemetry, or transaction data
  • dimensionality reduction for embeddings, charts, or preprocessing
  • utility workflows such as non-blocking execution in browser or Node.js apps

JavaScript implementation

@kanaries/ml provides a scikit-learn-like machine learning API for JavaScript and TypeScript so teams can build ML workflows directly in browser applications and Node.js services. Instead of treating ML as a separate Python-only layer, you can keep feature engineering, inference logic, interactive visualizations, and product code inside the same JS stack.

This is especially useful when someone searches for "machine learning in JavaScript", "TypeScript machine learning APIs", or "scikit-learn for JavaScript" and needs a practical module map rather than a single algorithm page.

Quick navigation

  • Clusters: segment unlabeled data with K-Means, Birch, Affinity Propagation, HDBSCAN, and related methods.
  • Decomposition: reduce dimensions or separate latent structure with PCA, Kernel PCA, FastICA, NMF, Incremental PCA, Sparse PCA, and Truncated SVD.
  • Ensemble: use Isolation Forest, AdaBoost, random forest, and bagging models for anomaly detection, classification, and regression.
  • Covariance: estimate empirical, shrunk, robust, or sparse inverse covariance.
  • Feature Selection: select columns with model importance, recursive elimination, or univariate scores.
  • Feature Extraction: turn raw text into sparse count and TF-IDF features.
  • Imputation: estimate correlated numeric values missing from feature matrices.
  • Linear: use classical, robust, Bayesian, quantile, and generalized linear models.
  • Kernel Methods: fit kernel ridge regression or kernel density estimates.
  • Cross Decomposition: model paired blocks with PLS Regression and CCA.
  • Random Projection: reduce dimensions with Gaussian or sparse Johnson-Lindenstrauss maps.
  • Compose: wrap regression targets in invertible preprocessing transformations.
  • Metrics: evaluate classification, regression, clustering, curves, and distance functions.
  • Manifold: build lower-dimensional embeddings for visualization and neighborhood analysis.
  • Neighbors: run k-nearest neighbors and fast nearest-neighbor search structures.
  • SVM: train support vector models for classification and regression.
  • Tree: use interpretable decision tree and extra tree models.
  • Bayes: apply naive Bayes models to binary or categorical features.
  • Neural Network: learn compact representations with Bernoulli RBM.
  • Semi-Supervised: spread labels through partially labeled datasets.
  • Multi-Output: predict related label or regression targets with estimator chains.
  • Utils: use preprocessing, sampling, model selection, statistics, and async workflow helpers.
  • Algebra: use lightweight matrix helpers such as transpose, determinants, and inverse.
  • KMath: compute lightweight descriptive statistics.

Detailed module guide

How to choose a module

  1. Start from the task type: classification, regression, clustering, anomaly detection, embedding, or workflow support.
  2. Open the matching module page and compare one simple baseline against one stronger alternative.
  3. Read the algorithm-specific guidance to balance model quality with browser latency, Node.js throughput, and implementation complexity.
  1. If you are new to the library, start with Linear, Tree, or Clusters.
  2. Move to Ensemble and SVM when simple baselines are not expressive enough.
  3. Use Metrics, Decomposition, Manifold, and Utils to improve evaluation, preprocessing, visualization, and application integration.

sklearn-compatible naming aliases

Canonical sklearn spellings are available alongside the legacy names so existing JavaScript code remains compatible:

Canonical exportLegacy exportNamespace
DBSCANDBScanClusters
HDBSCANHDBScanClusters
KNeighborsClassifierKNearestNeighborsNeighbors
LDALinearDiscriminantAnalysisDiscriminantAnalysis
QDAQuadraticDiscriminantAnalysisDiscriminantAnalysis
LLELocallyLinearEmbeddingManifold

Both names reference the same constructor; aliases do not duplicate estimator coverage or change serialized model names.