@kanaries/ml
API Reference/Multi-Output

RegressorChain

Predict related numeric targets with the @kanaries/ml JavaScript RegressorChain implementation in browser or Node.js.

View as Markdown

Algorithm 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.

Live browser model

RegressorChain playground

Adjust the data and model, then click the chart to add a training observation.

Fitted with @kanaries/ml
-3-2-10123-1.9-0.90.01.01.9feature xtarget y
prediction training holdout your points
Train RMSE0.702
Holdout RMSE0.713
Holdout R²-1.538
Custom points0

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.