ContentsChapter 4 · Regression4 of 4

4.4

Regularisation

In this chapter
  1. 4.1Least squares
  2. 4.2Basis functions
  3. 4.3Overfitting and bias–variance
  4. 4.4Regularisation
Before you readCan you stop a degree-9 polynomial from chasing noise without lowering its degree?
Watch: Regularization Part 1: Ridge (L2) Regression · StatQuest with Josh Starmer

Ridge regression adds a penalty for large weights to the least-squares objective:

∥y−Φw∥2+λ∥w∥2.\|y-\Phi w\|^2 + \lambda\|w\|^2.

λ\lambda sets the trade-off between fitting the data and keeping the weights small. The solution is

w=(ΦTΦ+λI)−1ΦTy.w = (\Phi^T\Phi + \lambda I)^{-1}\Phi^T y.

For λ>0\lambda > 0 the matrix is always invertible, even if the design matrix has dependent columns. With Gaussian observation noise and an isotropic zero-mean Gaussian prior on ww ridge gives the MAP estimate.

Lasso replaces the squared L2L_2 penalty with the L1L_1 penalty λ∑j∣wj∣\lambda\sum_j |w_j| It can set some weights exactly to zero, leaving a sparse model.

-4-2024-1-0.500.51
‖w‖ = 453.42Train MSE = 0Test MSE = 1.65
The polynomial degree stays at 9. Raise λ to shrink the weights; watch the test error on the hollow points fall, then rise again.
Recall
What penalty does ridge add to least squares?
Recall
How does ridge change the normal equations?
Recall
What happens to the weights as the ridge penalty grows without bound?
Exercise
Fit y=wxy = wx by ridge regression to (1,3)(1,3) and (2,5)(2,5) with λ=3\lambda = 3 Give ww
Exercise
Which penalty can set some fitted weights exactly to zero to make a sparse model?