What is the closed-form solution of ridge regression, min⁡w∥y−Xw∥2+λ∥w∥2, and, using the singular value decomposition X=UDV⊤, which directions does ridge shrink the most?

Supervised learning, Regularisation
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can derive the ridge solution and explain it as shrinking the least-squares fit most along the directions where the data varies least.

Key idea

w^ridge=(X⊤X+λI)−1X⊤y. With the SVD, the fitted values are Xw^=∑jujdj2dj2+λuj⊤y. Each direction is shrunk by the factor dj2dj2+λ, which is smallest where the singular value dj is small.

Steps

  1. Set the gradient to zero: −2X⊤(y−Xw)+2λw=0, so (X⊤X+λI)w=X⊤y. Here λ>0 is the penalty strength.
  2. Explain why the inverse always exists. In the SVD, U and V have orthonormal columns and D is diagonal with singular values dj≥0. The eigenvalues of X⊤X are dj2≥0, so those of X⊤X+λI are dj2+λ>0. A matrix with no zero eigenvalue is invertible.
  3. Substitute the SVD: X⊤X+λI=V(D2+λI)V⊤, so w^=V(D2+λI)−1DU⊤y.
  4. Fitted values: Xw^=UD(D2+λI)−1DU⊤y=∑jujdj2dj2+λuj⊤y. For plain least squares (λ=0) every factor would be 1, so these factors are exactly the shrinkage.
  5. Interpret. A small dj means the inputs vary little along that direction, so least squares is unreliable there (high variance). Ridge shrinks exactly those directions most. The effective number of parameters is ∑jdj2dj2+λ, which falls from d towards 0 as λ grows.

Common mistakes

How long your answer should be

Half a page; about 5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: How do you derive the normal equations for least-squares linear regression? When is X⊤X singular, what do you do then, and what is a concrete example of a singular design?
Next in Supervised learning: Why does the lasso give coefficients that are exactly zero while ridge does not? When the design is orthonormal (X⊤X=I), what is the lasso solution and how does it compare with ridge?