4.2 Ridge Regression
Shrink coefficients with an L2 penalty.
These notes walk through the lecture slides. The original deck is unchanged; use (slides) on the course hub if you want that PDF.
The figures follow Deisenroth, Faisal, and Ong, Mathematics for Machine Learning, and Theodoridis, Machine Learning: A Bayesian and Optimization Perspective.
1. Shrinkage methods
Among the -norms with , only treats small coordinates with any respect. The others squeeze small values further and spend their attention on large ones.
Regularization is also there to make an estimator easier to interpret.
Least squares fits by
Ridge instead minimizes
with hyper-parameter .
2. What does
The penalty forces the fit to keep the coefficients small. Add it only while training. Evaluate the trained model with the unregularized metric.
| Effect | |
|---|---|
| Ridge is ordinary least squares | |
| Ridge coefficients approach zero (they do not hit zero for finite ) |
The penalty hits , not . If every column of is centered,
3. Geometry

For the ridge constraint is a circle
where is the radius. The RSS contours are ellipses. The ridge estimate is the point where the ellipse and the circle touch.
- : you only shrink the ellipse (inner ellipses have smaller RSS). Highly correlated features make that geometry unpleasant.
- Small : more variance, less bias. Large : some bias, less variance.
4. The closed form
Expand:
Set the derivative to zero:
Then
so
5. Comments
- Ridge gives accurate predictions and reduced variance.
- Penalizing coefficient size controls overfitting: the model is less free to memorize noise.
- Ridge is the usual tool for multicollinearity. Shrinking correlated coefficients stabilizes the estimates.
6. Computational complexity
You can use the closed form or gradient descent, as with linear regression. The closed form inverts an matrix (Cholesky and friends). That gets slow when the number of features is large. If there are too many features, or too many rows to fit in memory, use gradient descent.
7. Practice
-
Why can ridge shrink coefficients but not set them to zero?
-
What happens as , and which coefficient is never penalized?
-
Why does adding help when columns of are highly correlated?