Linear regression with a leash: minimize squared error plus a penalty on the size of the weights.
Tames correlated features and overfit — keeps every feature, just small.
s1 and s2 in the diabetes data are correlated 0.90. OLS trades wild offsetting weights between them; ridge charges rent and picks small, stable ones.
Every frame is one real refit. Turn lambda up; every weight shrinks toward zero, the correlated ones fastest. The bottom panel finds the sweet spot.
Validation MSE bottoms out at lambda ≈ 31.6 — a real U, not "more is better."
Every ridge coefficient is shorter than its OLS twin; none are zeroed. The weight-vector norm drops from 45.5 to 40.6.
Our closed-form ridge and sklearn's Ridge agree to ~1e-13. Ridge beats
unregularized OLS on held-out data.
Test R²: OLS 0.339 → ridge 0.363. Same model class, better generalization.
RidgeCV.