Skip to main content

BayesianRidge

Bayesian ridge regression: a Gaussian linear model whose noise and weight precisions are estimated from the data by evidence maximisation, yielding predictive uncertainty for free.

Algorithm

Gamma hyperpriors on the noise precision (alpha) and weight precision (lambda) are optimised by the iterative evidence-maximisation scheme of Tipping (2001). predict(X, with_std) returns the predictive mean and standard deviation.

Constructor

Skigen::BayesianRidge<Scalar> model(int max_iter = 300, Scalar tol = 1e-3, Scalar alpha_1 = 1e-6, ...);

Parameters

ParameterDefaultDescription
max_iter300Evidence-maximisation iterations.
tol1e-3Convergence tolerance.
alpha_1 / alpha_21e-6Gamma prior on the noise precision.
lambda_1 / lambda_21e-6Gamma prior on the weight precision.
compute_scorefalseTrack the log marginal likelihood.

Methods

MethodDescription
fit(X, y)Optimise the evidence.
predict(X)Predictive mean.
predict(X, with_std)Mean and predictive std-dev.

Fitted Attributes

AccessorDescription
coef()Posterior mean weights.
alpha()Estimated noise precision.
lambda_()Estimated weight precision.

Example

Skigen::BayesianRidge<double> br;
br.fit(X, y);
auto [mean, std] = br.predict(X_test, Skigen::with_std);
Verified against scikit-learn

This estimator is checked by the parity suite. See the generator tests/parity/generate_bayesian_linear_reference.py and the reference fixtures in tests/parity/data/bayesian_ridge/, exercised by tests/parity/parity_bayesian_linear.cpp.

API Reference

For full signatures see the BayesianRidge API Reference.