Machine Learning Utilities
Use @kanaries/ml JavaScript ML utilities for preprocessing, train/test splitting, cross-validation, statistics, sampling, and Web Worker async execution.
View as MarkdownModule overview
The Utils module contains workflow helpers that make machine learning code easier to integrate into real JavaScript applications. These utilities are useful when the challenge is preparing data, validating models, or making model execution behave well inside browser or Node.js environments.
This module is a strong fit when:
- you need preprocessing, sampling, model selection, or simple statistics
- you need non-blocking execution around training or inference
- application responsiveness matters as much as model quality
- you want ML helpers that work naturally with the rest of a JS stack
JavaScript implementation
@kanaries/ml provides utility helpers in JavaScript and TypeScript so teams can shape data preparation, validation, execution behavior, integration patterns, and developer ergonomics without leaving the main application runtime. These helpers are especially useful in UI-heavy products and services where ML work should not block interaction or event-loop responsiveness.
If someone searches for "machine learning utilities in JavaScript", "preprocessing in TypeScript", or "async ML execution in TypeScript", this module is the right entry point.
Quick navigation
- Preprocessing: scale, normalize, encode, impute, and select features
- Advanced preprocessing: spline bases, target encoding, and multi-label indicators
- Model inspection: permutation importance and partial dependence
- Sampling: sample arrays and create train/test splits
- ModelSelection: run K-fold splits, cross-validation, grid search, and randomized search
- Stat: compute lightweight statistics used in ML workflows
- asyncMode: run synchronous functions in a worker-like async execution path
Detailed module guide
How to use this module
- Start with Preprocessing and Sampling to make training data model-ready.
- Use ModelSelection to compare estimators and tune parameters.
- Use asyncMode when training or inference should not block the main browser thread or Node.js event loop.
- Pair utilities with model modules so application behavior stays predictable under load.
JavaScript deployment notes
- Utilities matter most when ML code runs inside interactive or latency-sensitive product surfaces.
- Use them to keep heavy work off the main thread when responsiveness is part of the user experience.
- Combine them with the rest of the API catalog to build production-friendly JS ML workflows.
Metrics
Compute classification, regression, clustering, ROC/PR curve, and pairwise distance metrics in JavaScript and TypeScript with @kanaries/ml.
Preprocessing Utilities
Scale numeric columns, encode categories, impute missing values, and filter features in JavaScript and TypeScript with utils.Preprocessing from @kanaries/ml.