What is the closed-form solution of ridge regression?
Last updated
Setting the gradient to zero gives
ŵ = (XᵀX + λI)⁻¹Xᵀy. The Hessian is positive definite, so this is the unique global minimum for λ > 0.In SVD terms each direction is shrunk by
dᵢ²/(dᵢ² + λ)relative to OLS, so low-variance directions shrink most.Center data to leave the intercept unpenalized, use a linear solve instead of an explicit inverse, and use the dual
Xᵀ(XXᵀ + λI)⁻¹ywhen p ≫ n.