RegressorChain
Predict related numeric targets with the @kanaries/ml JavaScript RegressorChain implementation in browser or Node.js.
View as MarkdownAlgorithm overview
A regressor chain fits one model per target and appends earlier target values or predictions as features for later members. This can capture dependencies that independent multi-output regressors miss.
JavaScript implementation
@kanaries/ml accepts a registered single-output regressor and supports explicit or seeded random chain order. Set cv to use out-of-fold predictions while building training extensions.
Interactive regressor chain playground
Tune the Ridge base estimator and modify the dataset below. A two-output MultiOutput.RegressorChain is fitted live; the chart displays its first target while both outputs participate in the chain.
RegressorChain playground
Adjust the data and model, then click the chart to add a training observation.
Quick start example
import { Linear, MultiOutput } from '@kanaries/ml';
const X = [[0], [1], [2], [3]];
const targets = [[0, 1], [1, 3], [2, 5], [3, 7]];
const testX = [[4]];
const chain = new MultiOutput.RegressorChain({
estimator: new Linear.RidgeRegression({ alpha: 1 }), order: [1, 0],
});
chain.fit(X, targets);
const predictions = chain.predict(testX);
console.log(predictions);Detailed API reference
Options: estimator, order?: number[] | 'random', cv?: number | null, and randomState. Methods: fit(X, Y), predict(X), and mean-output score(X, Y). Learned chainOrder and estimators are available as defensive arrays. Ridge regression is a safe base choice when true earlier targets make augmented columns collinear.
ClassifierChain
Model dependencies between multiple binary labels with the @kanaries/ml JavaScript ClassifierChain implementation in browser or Node.js.
Metrics
Evaluate classification, regression, clustering, ranking curves, and distance calculations with the @kanaries/ml Metrics JavaScript implementation for browser and Node.js workflows.