Robust Regression
Fit Huber, RANSAC, Theil-Sen, and quantile regression models in browser or Node.js applications with @kanaries/ml.
View as MarkdownRobust regression
Ordinary least squares can move sharply when targets contain outliers. HuberRegressor softens large residuals, RANSACRegressor fits a consensus set, TheilSenRegressor aggregates many subsample fits, and QuantileRegressor estimates a conditional quantile instead of a mean.
JavaScript implementation
@kanaries/ml exposes sklearn-style constructors and fit/predict methods that run in browser or Node.js. Use Huber for moderate contamination, RANSAC for clear gross outliers, Theil-Sen for small robust datasets, and quantile regression for medians or prediction bands.
Interactive robust regression playground
Switch between Huber, RANSAC, Theil–Sen, and quantile regression, then try the outlier dataset or add extreme points yourself. Each curve is trained live by the selected @kanaries/ml estimator.
Huber playground
Adjust the data and model, then click the chart to add a training observation.
Quick start
import { Linear } from '@kanaries/ml';
const model = new Linear.RANSACRegressor({ randomState: 42 });
model.fit([[0], [1], [2], [3]], [0, 1, 20, 3]);
console.log(model.predict([[4]]));Detailed API reference
HuberRegressor({ epsilon=1.35, alpha=0.0001, maxIter=100, tol=1e-5, fitIntercept=true })exposescoef,intercept,scale, andoutliers.RANSACRegressor({ estimator, minSamples, residualThreshold, maxTrials=100, stopProbability=.99, randomState })exposesestimatorFitted,inlierMask, andnTrials.TheilSenRegressor({ nSubsamples, maxSubpopulation=10000, maxIter=300, tol=1e-3, randomState })exposescoef,intercept, andnIter.QuantileRegressor({ quantile=.5, alpha=1, fitIntercept=true, maxIter=5000, tol=1e-7 })solves the pinball-loss problem with an ADMM optimizer.
RidgeClassifier
Train L2-regularized linear classifiers with the RidgeClassifier JavaScript and TypeScript implementation in @kanaries/ml for browser and Node.js applications.
Bayesian Ridge and ARD Regression
Run BayesianRidge and sparse ARDRegression in JavaScript or TypeScript with posterior uncertainty and sklearn-style APIs.