Lesson 5.4 · 10 min read · about 55 min to master at a very slow pace

Ridge Regression (L2)

Ridge adds a penalty on the sum of squared coefficients. Its closed-form solution, why it shrinks, why it always has a solution, how it handles correlated predictors, and two worked examples.

Not startedJump to quiz

Ridge objective and solution

The intercept is not penalised (center the data, or exclude it from the penalty).

Show the derivation

Why it shrinks

Adding makes the "denominator" bigger. In the simplest case (orthonormal predictors):

Every coefficient is divided by something larger than 1. In general all coefficients move towards zero as grows, and as . They never become exactly zero.

Example A: one predictor, by hand

Centred data , . , .

026
slope210.50
training RSS024.58 (= TSS)

As grows, the slope shrinks and training RSS rises.

Example B: two correlated predictors

OLS: , so .

Ridge, : , , so .

Ridge shrinks the large coefficient and shares credit with its correlated twin. The sum barely moves (1.26 vs 1.12), while the split is much more even and stable.

Properties

  • Always solvable: is invertible for any , even when is singular (, perfect collinearity). Adding to every eigenvalue makes them all positive.
  • Bias–variance: as increases, bias increases and variance decreases.
  • Correlated predictors: shares the credit instead of producing huge opposite-sign coefficients.
  • Cons: many small but non-zero coefficients (no variable selection), and no convenient significance test for coefficients.

Cheatsheet

Ridge

; . Orthonormal: .

Ridge properties

Shrinks, never zero. Always solvable. Shares credit among correlated predictors. Bias ↑, variance ↓ with λ.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1calculateRidge with one centred predictor: and . What is the slope at ?
Q2calculate and . What is the ridge solution at ?
Q3conceptWhich statement about ridge regression is true?
Q4conceptWhy does ridge always have a unique solution when ?
Q5interpretWhat happens to a ridge model as ?