Skip to main content

Module ridge

Module ridge 

Source
Expand description

Ridge regression (ISL ch 6.2.1, PRML ch 3) — L2-penalized least squares.

Minimise ‖y − Xβ‖² + λ‖β‖² (the intercept is not penalized). Centering y and the predictors removes the intercept from the penalized solve, leaving (XcᵀXc + λI)β = Xcᵀyc, solved with linear_algebra::cholesky (the penalty makes the system positive-definite even for collinear predictors — ridge’s whole point). Kernel-class DenseLinear, dispatch-ready.

Structs§

RidgeModel
A fitted ridge model: slope coefficients (predictor-aligned) plus an un-penalized intercept.

Functions§

fit
Fit ridge regression with penalty lambda ≥ 0. lambda = 0 reproduces OLS. Fails closed on shape mismatch / n < 2.