- Introduced by
- MacKay, D. J. C.
- Year
- 1992
- Type
- Probabilistic regularised regression
What does it do?
Bayesian Ridge Regression is a probabilistic form of ridge regression in which the prior precision on the weights (alpha) and the noise precision (beta) are estimated from the data by maximising the marginal likelihood, rather than chosen by cross-validation.
The fit yields a Gaussian posterior over the regression weights and a Gaussian predictive distribution for new inputs. The evidence-based procedure for setting these constants is associated with MacKay's 1992 paper 'Bayesian Interpolation'; the cited abstract credits the underlying framework to Gull and Skilling.
The intuition behind the method
Standard ridge regression shrinks coefficients toward zero with a penalty whose strength the analyst must choose, usually by cross-validation. Bayesian Ridge Regression treats the penalty (alpha) and the noise precision (beta) as unknowns and estimates them from the data using the marginal likelihood, so the amount of shrinkage follows how much signal the data contain. Each prediction comes with a predictive distribution whose width combines the noise level and the uncertainty in the weights. Conditional on the fitted alpha and beta and under the linear-Gaussian assumptions, this width follows from the model. Because alpha and beta are treated as fixed at their fitted values, however, the width may be too narrow when the hyperparameters are poorly determined, for example with few observations.
History
The evidence procedure for setting regularisation and noise constants is associated with David J. C. MacKay's 1992 paper 'Bayesian Interpolation' in Neural Computation (4(3), 415-447). The paper treats regularisation and model comparison in a Bayesian framework and sets regularising constants through their posterior probability distribution. The cited abstract attributes the underlying framework to Gull and Skilling. Chapter 3 of Bishop's 'Pattern Recognition and Machine Learning' (2006) gives a textbook treatment of Bayesian linear regression.
When to use it
Choose Bayesian Ridge Regression when the relationship is approximately linear, the noise is plausibly Gaussian, and you want ridge-type shrinkage without selecting the penalty by cross-validation. It is also a reasonable choice when predictive intervals are needed alongside point predictions, and when the sample is large enough relative to the number of features for the evidence estimates to be stable; with few observations, the hyperparameter estimates and the intervals become less reliable. It assumes a linear mean function, Gaussian noise, and that a spherical prior is a sensible shrinkage assumption, which requires features on comparable scales. Do not use it when a sparse solution is required (ARD regression or Lasso are better suited), when the relationship is strongly non-linear, when the number of features is large enough that the cost of inverting the posterior precision matters, or when errors are heavy-tailed.
Limitations and considerations
- Linearity: the model is linear in its inputs, so non-linear relationships require explicit feature transformations or a different method, such as Gaussian process regression.
- Spherical prior: the isotropic prior applies the same shrinkage to every weight, which fits poorly when feature relevances differ widely; ARD regression relaxes this assumption.
- Point-estimated hyperparameters: alpha and beta are fitted iteratively and then treated as fixed, so the predictive intervals do not include their uncertainty and may be too narrow when the data are few.
- Cost: forming and inverting the posterior precision scales with the cube of the number of features, which becomes burdensome for very high-dimensional inputs unless approximations are introduced.
- Gaussian noise: heavy-tailed errors or outliers can distort the evidence-optimised noise precision, and the Gaussian likelihood gives such points disproportionate influence.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Automatic regularisation: alpha and beta are estimated from the data by the evidence procedure, so no separate cross-validation search is needed for the penalty.
- Separated uncertainty: the predictive variance splits into a noise term (beta^{-1}) and a weight-uncertainty term (x_*' S_N x_*), showing whether the interval width comes from observation noise or from poorly determined coefficients.
- Closed-form posterior: given alpha and beta, the posterior and predictive distributions are analytic, so no MCMC or variational approximation is required.
- Occam-type penalty: through gamma, the evidence rewards fits that the data can determine, a property the cited abstract describes as Occam's razor.
- Per-coefficient diagnostics: posterior variances show which coefficients the data determine well and which they do not.
Applications
- Linear regression with a small number of observations, where cross-validated penalty selection is unstable and the shrinkage is to be set from the data.
- Prediction tasks in which the analyst needs an interval whose width separates observation noise from uncertainty in the coefficients.
- Diagnosing which coefficients the data determine poorly, using posterior variances as a guide to further data collection or model simplification rather than as an automatic selection rule.
- A linear probabilistic baseline before fitting more flexible models such as Gaussian process regression, to see how much a linear model with predictive uncertainty already explains.
How it works
How it works
The responses are modelled as Gaussian, centred on the linear predictor X w, with precision beta (the inverse noise variance). This is the same linear-Gaussian likelihood that underlies ordinary least-squares regression and that is treated in Chapter 3 of Bishop (2006).
Formula
p(\mathbf{y} \mid \mathbf{X}, \mathbf{w}, \beta) = \mathcal{N}(\mathbf{y} \mid \mathbf{X}\mathbf{w},\, \beta^{-1}\mathbf{I})The weight vector w receives a spherical Gaussian prior with precision alpha. This encodes the shrinkage assumption of ridge regression: without data, coefficients are expected to be near zero, and alpha controls how strongly they are pulled there.
Formula
p(\mathbf{w} \mid \alpha) = \mathcal{N}(\mathbf{w} \mid \mathbf{0},\, \alpha^{-1}\mathbf{I})Because the likelihood and the prior are both Gaussian, the posterior over w is Gaussian. Once alpha and beta are fixed, it can be computed in closed form, so no sampling is needed.
Formula
p(\mathbf{w} \mid \mathbf{y}, \mathbf{X}, \alpha, \beta) = \mathcal{N}(\mathbf{w} \mid \mathbf{m}_N,\, \mathbf{S}_N)The posterior precision is alpha I + beta X'X, and the posterior mean m_N = beta S_N X'y equals the ridge estimate (X'X + (alpha/beta) I)^{-1} X'y. The covariance S_N adds a measure of how uncertain each weight remains given the data.
Formula
\mathbf{S}_N^{-1} = \alpha\mathbf{I} + \beta\mathbf{X}^\top\mathbf{X}, \quad \mathbf{m}_N = \beta\,\mathbf{S}_N\,\mathbf{X}^\top\mathbf{y}Integrating the weights out gives the marginal likelihood (evidence) of the data as a function of alpha and beta. Maximising it selects the hyperparameters that best explain the observed responses; this is the evidence procedure described in MacKay's 1992 paper, used here in place of cross-validation. The cited abstract states that this process embodies Occam's razor.
Formula
\ln p(\mathbf{y} \mid \mathbf{X}, \alpha, \beta) = \frac{N}{2}\ln\beta - \frac{N}{2}\ln(2\pi) + \frac{1}{2}\ln\det\mathbf{S}_N - \frac{\beta}{2}\|\mathbf{y}-\mathbf{X}\mathbf{m}_N\|^2 - \frac{\alpha}{2}\mathbf{m}_N^\top\mathbf{m}_NSetting the derivatives of the evidence to zero gives closed-form update equations. The quantity gamma, the sum of lambda_i/(alpha + lambda_i) over the eigenvalues lambda_i of beta X'X, is read as the effective number of parameters determined by the data. Each term lies in [0, 1), so gamma lies between 0 and the number of features M. The updates are applied iteratively from chosen starting values of alpha and beta until both change by less than a small tolerance set by the analyst. Because the converged values can depend on the starting point, the fit should be repeated from several starting values to confirm that alpha and beta are stable. If the iterations do not settle, the estimates should not be reported as a stable Bayesian fit, and the features should be checked for scale and collinearity first.
Formula
\alpha \leftarrow \frac{\gamma}{\mathbf{m}_N^\top \mathbf{m}_N}, \quad \beta \leftarrow \frac{N - \gamma}{\|\mathbf{y} - \mathbf{X}\mathbf{m}_N\|^2}, \quad \gamma = \sum_i \frac{\lambda_i}{\alpha + \lambda_i}The predictive mean is the posterior mean applied to the new input x_*. The predictive variance adds the noise term beta^{-1} to the weight-uncertainty term x_*' S_N x_*. The second term tends to be larger for inputs in directions the training data constrain poorly, so the width signals extrapolation, but only within the linear-Gaussian model.
Formula
p(y_* \mid \mathbf{x}_*, \mathbf{X}, \mathbf{y}) = \mathcal{N}\!\left(y_* \mid \mathbf{m}_N^\top \mathbf{x}_*,\; \beta^{-1} + \mathbf{x}_*^\top \mathbf{S}_N \mathbf{x}_*\right)Common pitfalls
- Reporting only the posterior mean discards the predictive variance, which is the main advantage of the Bayesian formulation over ordinary ridge regression.
- Skipping feature scaling: the spherical prior gives every weight the same prior variance, so unscaled features are shrunk unequally in their original units. Standardise continuous features before fitting.
- Mixing parametrisations: some software reports prior and noise scales as variances rather than precisions, so alpha and beta from one implementation may not match another. Check conventions before comparing results.
- Treating automatic tuning as the end of modelling choices: the linear mean, Gaussian noise and spherical prior are still assumptions that need justification.
- Using this model when sparsity is needed: the spherical prior does not set coefficients to exact zero, so ARD regression or Lasso should be used for variable selection.
Frequently asked questions
How does Bayesian Ridge Regression differ from ordinary ridge regression?
Ordinary ridge regression requires the analyst to choose the penalty parameter lambda (equivalently alpha/beta) via cross-validation. Bayesian Ridge Regression treats alpha and beta as unknowns and estimates them by maximising the marginal likelihood of the observed data. The posterior mean of the weights equals the ridge estimate at the optimised alpha/beta ratio, but the Bayesian formulation also gives a posterior distribution over the weights and predictive intervals.
Do I need to scale my features before fitting?
Yes. The isotropic Gaussian prior assigns equal prior variance to every weight regardless of the scale of the corresponding feature. If features are on very different scales, the prior implicitly applies different amounts of shrinkage in the original feature space. Standardising features to zero mean and unit variance before fitting makes the prior less arbitrary with respect to feature scale and makes the hyperparameter estimation more stable.
When should I use ARD regression instead?
Automatic Relevance Determination (ARD) regression extends Bayesian Ridge Regression by giving each feature its own precision parameter alpha_j, so irrelevant features can be shrunk strongly while relevant ones are penalised less. Use ARD when you expect only a subset of features to matter and want the model to push the others toward zero. ARD has more hyperparameters to estimate, so it is harder to fit reliably in small samples; Bayesian Ridge Regression is the simpler default when sparsity is not the goal.
How do I interpret the predictive uncertainty?
For a new input x_*, the predictive variance adds beta^{-1}, the irreducible noise, to x_*' S_N x_*, which reflects uncertainty in the weights given the finite training set. The second term tends to be larger for inputs in directions the training data constrain poorly. Both terms rest on the linear-Gaussian model and the estimated alpha and beta, so the intervals are only as reliable as those assumptions.
Related methods
Sources
MacKay, D. J. C. (1992). Bayesian Interpolation. Neural Computation, 4(3), 415–447.
Open DOI referenceBishop, C. M. (2006). Pattern Recognition and Machine Learning (Ch. 3). Springer.
ISBN: 978-0-387-31073-2