Bayesian Ridge and ARD Regression
Run BayesianRidge and sparse ARDRegression in JavaScript or TypeScript with posterior uncertainty and sklearn-style APIs.
View as MarkdownBayesian linear regression
Algorithm overview
Bayesian linear models place probability distributions over coefficients. They are useful when you want regularized predictions plus uncertainty, or automatic relevance determination that prunes weak features.
JavaScript implementation
BayesianRidge learns a shared coefficient precision and supports predictStd. ARDRegression learns one precision per feature and zeros coefficients whose precision crosses thresholdLambda.
Interactive Bayesian regression playground
Compare Bayesian Ridge and ARD Regression while changing the data and iteration budget. The live curve and holdout metrics come from the selected @kanaries/ml model running in your browser.
Bayesian Ridge playground
Adjust the data and model, then click the chart to add a training observation.
Quick start
import { Linear } from '@kanaries/ml';
const X = [[0], [1], [2], [3]];
const y = [1, 3, 5, 7];
const model = new Linear.BayesianRidge();
model.fit(X, y);
const mean = model.predict([[4]]);
const standardDeviation = model.predictStd([[4]]);
console.log({ mean, standardDeviation });Detailed API reference
Both estimators accept maxIter, tol, Gamma-prior hyperparameters, and fitIntercept, and expose coef, intercept, alpha, lambda, sigma, and nIter.