BaggingRegressor
Reduce regression variance with bootstrap aggregation using the BaggingRegressor JavaScript and TypeScript implementation in @kanaries/ml.
View as MarkdownAlgorithm overview
BaggingRegressor fits cloned regressors on random sample subsets and averages their predictions. It is useful for reducing the variance of unstable learners such as regression trees.
JavaScript implementation
Ensemble.BaggingRegressor defaults to decision trees and can clone any registered regressor that implements fit and predict. Seedable sampling makes browser and Node.js runs reproducible.
Interactive bagging regression playground
Vary the ensemble size and sample noise to see bootstrap averaging at work. The curve is fitted live with Ensemble.BaggingRegressor and responds to observations you add.
BaggingRegressor playground
Adjust the data and model, then click the chart to add a training observation.
Quick start example
import { Ensemble } from '@kanaries/ml';
const X = [[0], [1], [2], [3], [4]];
const y = [0, 1, 4, 9, 16];
const model = new Ensemble.BaggingRegressor({ nEstimators: 25, maxSamples: .8, randomState: 42 });
model.fit(X, y);
console.log(model.predict([[2.5]]));Detailed API reference
Constructor options are estimator?, nEstimators? (default 10), maxSamples? (integer or fraction), bootstrap? (default true), and randomState?. Methods are fit(X, y) and predict(X).
BaggingClassifier
Train bootstrap classifier ensembles with the BaggingClassifier JavaScript and TypeScript implementation in @kanaries/ml.
ExtraTreesClassifier
Train extremely randomized classification trees in JavaScript or TypeScript with ExtraTreesClassifier from @kanaries/ml for browser and Node.js.