MML204

Ridge Regression

⏱7 min read👁️Eye-Care Reading Mode

What you'll learn

  • Why Ordinary Least Squares (OLS) produces massive variance and erratic coefficients when predictors are multicollinear.
  • How adding an L2L_2 squared magnitude penalty shrinks coefficients toward zero without discarding features.
  • The step-by-step matrix derivation of the closed-form Ridge estimator β^Ridge=(XTX+λIp)−1XTy\hat{\boldsymbol{\beta}}_{\text{Ridge}} = (\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p)^{-1}\mathbf{X}^T\mathbf{y}.
  • The mathematical proof of why adding λIp\lambda \mathbf{I}_p guarantees strict positive definiteness and invertibility.
  • The geometric tangency between the elliptical OLS contours and the circular L2L_2 constraint boundary.
  • The Bias-Variance Trade-off and why accepting small bias dramatically reduces total prediction error.
  • Why feature standardization (ZZ-score scaling) is mandatory prior to running Ridge Regression.

Explained in detail

1. The Problem: Why Do We Need Ridge Regression?

In standard Ordinary Least Squares (OLS), our only goal is to minimize training error:

min⁡β∑i=1n(yi−y^i)2\min_{\boldsymbol{\beta}} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2

When features are uncorrelated and the sample size nn is vastly larger than the number of predictors pp, OLS is optimal. However, fitting the observed training data with zero bias is not the true goal of machine learning. Our ultimate objective is generalization—making accurate predictions on brand new, unseen test data.

When predictors are strongly correlated with one another (multicollinearity), OLS breaks down disastrously.

What correlation between predictors means: two features carrying overlapping information

What Is Multicollinearity?

Suppose we want to predict a person's blood pressure using two features:

  1. Weight in kilograms (x1x_1).
  2. Weight in pounds (x2x_2).

Because x2≈2.2×x1x_2 \approx 2.2 \times x_1, these two predictors carry virtually identical information. In matrix terms, the columns of the design matrix X\mathbf{X} are nearly linearly dependent.

When you attempt to solve the normal equations:

XTXβ^=XTy\mathbf{X}^T\mathbf{X}\hat{\boldsymbol{\beta}} = \mathbf{X}^T\mathbf{y}

The matrix XTX\mathbf{X}^T\mathbf{X} becomes ill-conditioned (its determinant is near zero, and its smallest eigenvalue approaches zero).

The variance of the OLS coefficient vector is given by:

Var(β^OLS)=σ2(XTX)−1\text{Var}(\hat{\boldsymbol{\beta}}_{\text{OLS}}) = \sigma^2 (\mathbf{X}^T\mathbf{X})^{-1}

When XTX\mathbf{X}^T\mathbf{X} is nearly singular, the entries of its inverse (XTX)−1(\mathbf{X}^T\mathbf{X})^{-1} explode to enormous magnitudes!

Simulation showing severe instability in OLS coefficient estimates across random samples

As shown in the simulation above, running OLS on slightly different random samples of the same population produces wild oscillations: one sample might estimate β^1=+520\hat{\beta}_1 = +520 and β^2=−510\hat{\beta}_2 = -510, while the next yields β^1=−340\hat{\beta}_1 = -340 and β^2=+355\hat{\beta}_2 = +355. The model overfits sample noise, resulting in poor out-of-sample predictive performance.


2. Ridge Intuition: Shrinkage and Regularization

How do we tame this extreme sensitivity? We introduce regularization: we restrict how large the coefficients are allowed to grow.

Instead of letting OLS assign massive canceling coefficients (+500+500 and −500-500) to collinear features, Ridge Regression imposes a penalty on the total squared magnitude of the coefficient vector.

What Is Shrinkage?

Shrinkage pulls estimated coefficients toward zero. By restraining coefficient sizes:

  • The model becomes far less sensitive to tiny fluctuations or measurement noise in the training sample.
  • Coefficients become stable and interpretable.
  • The model trades a slight increase in training error (bias) for a massive reduction in parameter sensitivity (variance).
⚠️

What Ridge Is Not: Ridge Regression shrinks coefficients continuously toward zero, but it never sets coefficients exactly to zero. Ridge keeps all pp features in the model. If you require sparse feature selection (eliminating variables completely), you need Lasso (L1L_1) Regularization.


3. Mathematical Foundation: The Ridge Cost Function

Ridge Regression augments the classical OLS Residual Sum of Squares (RSS) with an L2L_2 penalty (proportional to the squared Euclidean norm of the coefficient vector):

J(β)=∥y−Xβ∥22⏟RSS (Data Fit)+λ∥β∥22⏟L2 Penalty (Complexity)J(\boldsymbol{\beta}) = \underbrace{\|\mathbf{y} - \mathbf{X}\boldsymbol{\beta}\|_2^2}_{\text{RSS (Data Fit)}} + \underbrace{\lambda \|\boldsymbol{\beta}\|_2^2}_{L_2\text{ Penalty (Complexity)}}

In explicit summation notation across nn samples and pp features:

J(β)=∑i=1n(yi−∑j=1pXijβj)2+λ∑j=1pβj2J(\boldsymbol{\beta}) = \sum_{i=1}^{n} \left( y_i - \sum_{j=1}^{p} X_{ij}\beta_j \right)^2 + \lambda \sum_{j=1}^{p} \beta_j^2

Deconstructing the Objective Function

  • ∥y−Xβ∥22\|\mathbf{y} - \mathbf{X}\boldsymbol{\beta}\|_2^2 (Data Fit): Measures how poorly the model predicts the observed training targets.
  • ∑j=1pβj2\sum_{j=1}^{p} \beta_j^2 (Model Complexity): Measures the overall size of the coefficient vector. Large slopes receive a heavy quadratic penalty.
  • λ≥0\lambda \ge 0 (Tuning Hyperparameter): Controls the balance between fitting the data and keeping coefficients small.
Penalty LevelValue of λ\lambdaOptimization Behavior
Zero Penaltyλ=0\lambda = 0Penalty vanishes; objective is identical to unregularized OLS.
Small PenaltySmall λ>0\lambda > 0Mild shrinkage; stabilizes ill-conditioned matrix without hurting fit.
Optimal PenaltyModerate λ\lambdaMinimizes total test-set prediction error (lowest MSE).
Infinite Penaltyλ→∞\lambda \to \inftyPenalty dominates data fit; all coefficients shrink to zero (β^→0\hat{\boldsymbol{\beta}} \to \mathbf{0}).

Why Is It Called an L2L_2 Penalty?

The Euclidean length of a vector is its L2L_2 norm: ∥β∥2=∑βj2\|\boldsymbol{\beta}\|_2 = \sqrt{\sum \beta_j^2}. Ridge penalizes the square of this norm: ∥β∥22\|\boldsymbol{\beta}\|_2^2. Squaring ensures the penalty is smooth, continuously differentiable, and convex, yielding an exact analytical closed-form solution.


4. Step-by-Step Derivation of the Ridge Estimator

Let us derive the exact matrix formula for β^Ridge\hat{\boldsymbol{\beta}}_{\text{Ridge}} step by step. (We assume here that features are standardized and the intercept is handled separately).

Step 1: Write the Matrix Objective

J(β)=(y−Xβ)T(y−Xβ)+λβTβJ(\boldsymbol{\beta}) = (\mathbf{y} - \mathbf{X}\boldsymbol{\beta})^T (\mathbf{y} - \mathbf{X}\boldsymbol{\beta}) + \lambda \boldsymbol{\beta}^T\boldsymbol{\beta}

Step 2: Expand the Residual Product

Using the matrix transpose identity (A−B)T=AT−BT(\mathbf{A} - \mathbf{B})^T = \mathbf{A}^T - \mathbf{B}^T:

J(β)=(yT−βTXT)(y−Xβ)+λβTβJ(\boldsymbol{\beta}) = (\mathbf{y}^T - \boldsymbol{\beta}^T\mathbf{X}^T)(\mathbf{y} - \mathbf{X}\boldsymbol{\beta}) + \lambda \boldsymbol{\beta}^T\boldsymbol{\beta}

Distributing terms:

J(β)=yTy−yTXβ−βTXTy+βTXTXβ+λβTβ\begin{aligned} J(\boldsymbol{\beta}) &= \mathbf{y}^T\mathbf{y} - \mathbf{y}^T\mathbf{X}\boldsymbol{\beta} - \boldsymbol{\beta}^T\mathbf{X}^T\mathbf{y} \\ &\quad + \boldsymbol{\beta}^T\mathbf{X}^T\mathbf{X}\boldsymbol{\beta} + \lambda \boldsymbol{\beta}^T\boldsymbol{\beta} \end{aligned}

Because the scalar quantity yTXβ\mathbf{y}^T\mathbf{X}\boldsymbol{\beta} equals its transpose βTXTy\boldsymbol{\beta}^T\mathbf{X}^T\mathbf{y}:

J(β)=yTy−2βTXTy+βTXTXβ+λβTβ\begin{aligned} J(\boldsymbol{\beta}) &= \mathbf{y}^T\mathbf{y} - 2\boldsymbol{\beta}^T\mathbf{X}^T\mathbf{y} + \boldsymbol{\beta}^T\mathbf{X}^T\mathbf{X}\boldsymbol{\beta} \\ &\quad + \lambda \boldsymbol{\beta}^T\boldsymbol{\beta} \end{aligned}

Step 3: Combine Quadratic Terms

Using the p×pp \times p identity matrix Ip\mathbf{I}_p, we write λβTβ=βT(λIp)β\lambda \boldsymbol{\beta}^T\boldsymbol{\beta} = \boldsymbol{\beta}^T(\lambda \mathbf{I}_p)\boldsymbol{\beta}. Factoring out β\boldsymbol{\beta}:

J(β)=yTy−2βTXTy+βT(XTX+λIp)βJ(\boldsymbol{\beta}) = \mathbf{y}^T\mathbf{y} - 2\boldsymbol{\beta}^T\mathbf{X}^T\mathbf{y} + \boldsymbol{\beta}^T (\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p) \boldsymbol{\beta}

Step 4: Differentiate with Respect to β\boldsymbol{\beta}

Applying standard matrix differentiation rules:

∂(−2βTXTy)∂β=−2XTy\frac{\partial (-2\boldsymbol{\beta}^T\mathbf{X}^T\mathbf{y})}{\partial \boldsymbol{\beta}} = -2\mathbf{X}^T\mathbf{y}

Because XTX+λIp\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p is symmetric:

∂∂β[βT(XTX+λIp)β]=2(XTX+λIp)β\frac{\partial}{\partial \boldsymbol{\beta}} \left[ \boldsymbol{\beta}^T (\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p) \boldsymbol{\beta} \right] = 2(\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p)\boldsymbol{\beta}

Combining gives the gradient:

∂J∂β=−2XTy+2(XTX+λIp)β\frac{\partial J}{\partial \boldsymbol{\beta}} = -2\mathbf{X}^T\mathbf{y} + 2(\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p)\boldsymbol{\beta}

Step 5: Set Gradient to Zero & Solve

At the global minimum:

−2XTy+2(XTX+λIp)β^=0-2\mathbf{X}^T\mathbf{y} + 2(\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p)\hat{\boldsymbol{\beta}} = \mathbf{0}(XTX+λIp)β^=XTy(\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p)\hat{\boldsymbol{\beta}} = \mathbf{X}^T\mathbf{y}

Multiplying both sides by the inverse (XTX+λIp)−1(\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p)^{-1}:

β^Ridge=(XTX+λIp)−1XTy\hat{\boldsymbol{\beta}}_{\text{Ridge}} = (\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p)^{-1}\mathbf{X}^T\mathbf{y}

This is the celebrated Closed-Form Ridge Regression Estimator!


5. Why Does Adding λIp\lambda \mathbf{I}_p Guarantee Invertibility?

Notice the profound difference between OLS and Ridge:

  • OLS: (XTX)−1XTy(\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^T\mathbf{y} requires XTX\mathbf{X}^T\mathbf{X} to be non-singular (fails when p>np > n or multicollinear).
  • Ridge: (XTX+λIp)−1XTy(\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p)^{-1}\mathbf{X}^T\mathbf{y} is always invertible for any λ>0\lambda > 0!

Proof of Strict Positive Definiteness

For any non-zero vector v≠0\mathbf{v} \ne \mathbf{0}:

vT(XTX+λIp)v=vTXTXv+λvTv=(Xv)T(Xv)+λ∥v∥2=∥Xv∥2+λ∥v∥2\begin{aligned} \mathbf{v}^T (\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p) \mathbf{v} &= \mathbf{v}^T \mathbf{X}^T\mathbf{X} \mathbf{v} + \lambda \mathbf{v}^T\mathbf{v} \\ &= (\mathbf{X}\mathbf{v})^T(\mathbf{X}\mathbf{v}) + \lambda \|\mathbf{v}\|^2 \\ &= \|\mathbf{X}\mathbf{v}\|^2 + \lambda \|\mathbf{v}\|^2 \end{aligned}

Even if Xv=0\mathbf{X}\mathbf{v} = \mathbf{0} (collinear features), the second term λ∥v∥2>0\lambda \|\mathbf{v}\|^2 > 0 strictly exceeds zero whenever λ>0\lambda > 0.

In terms of eigenvalues: if the eigenvalues of XTX\mathbf{X}^T\mathbf{X} are d1,…,dp≥0d_1, \dots, d_p \ge 0, then the eigenvalues of XTX+λIp\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p are:

d1+λ,d2+λ,…,dp+λd_1 + \lambda, \quad d_2 + \lambda, \quad \dots, \quad d_p + \lambda

Every single eigenvalue is shifted strictly away from zero by λ\lambda, guaranteeing that the matrix is non-singular, well-conditioned, and invertible.

A Tiny Numerical Demonstration

Consider an extreme case with two identical, perfectly collinear predictors:

X=[112233]y=[246]\begin{aligned} \mathbf{X} &= \begin{bmatrix} 1 & 1 \\ 2 & 2 \\ 3 & 3 \end{bmatrix} \\[6pt] \mathbf{y} &= \begin{bmatrix} 2 \\ 4 \\ 6 \end{bmatrix} \end{aligned}

Computing XTX\mathbf{X}^T\mathbf{X}:

XTX=[14141414],det⁡(XTX)=14(14)−14(14)=0\begin{aligned} \mathbf{X}^T\mathbf{X} &= \begin{bmatrix} 14 & 14 \\ 14 & 14 \end{bmatrix}, \\ \det(\mathbf{X}^T\mathbf{X}) &= 14(14) - 14(14) = 0 \end{aligned}

OLS is completely paralyzed; it cannot invert XTX\mathbf{X}^T\mathbf{X}.

Now apply Ridge with λ=1\lambda = 1:

XTX+λI2=[15141415]\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_2 = \begin{bmatrix} 15 & 14 \\ 14 & 15 \end{bmatrix}det⁡=152−142=225−196=29>0\det = 15^2 - 14^2 = 225 - 196 = 29 > 0

The system inverts effortlessly! By symmetry, Ridge divides the influence equally: β^1=β^2=2830≈0.933\hat{\beta}_1 = \hat{\beta}_2 = \frac{28}{30} \approx 0.933.


6. The Regularization Parameter λ\lambda & Coefficient Paths

As we vary λ\lambda continuously from 00 to large values, we trace the coefficient shrinkage paths:

Paths traced by regression coefficients as the regularization penalty increases

  1. At λ=0\lambda = 0: Coefficients start at their unconstrained OLS values (often wildly dispersed).
  2. As λ\lambda increases: All coefficients shrink toward zero at rates governed by the eigenvalues of the feature correlation matrix.
  3. As λ→∞\lambda \to \infty: All coefficients asymptotically approach zero, but never become strictly zero at any finite λ\lambda.

7. Geometric Intuition: The Circular L2L_2 Constraint

Ridge Regression can be equivalently formulated as a constrained optimization problem (Lagrangian duality):

min⁡βRSS(β)subject to∑j=1pβj2≤s\min_{\boldsymbol{\beta}} \text{RSS}(\boldsymbol{\beta}) \quad \text{subject to} \quad \sum_{j=1}^{p} \beta_j^2 \le s

where ss is a budget constraint inversely related to λ\lambda.

Geometric illustration of Ridge Regression: RSS contour ellipses meeting the circular constraint boundary

In 2D parameter space (β1,β2)(\beta_1, \beta_2):

  • The OLS Contours (Blue Ellipses): Centered at the unconstrained minimum β^OLS\hat{\boldsymbol{\beta}}_{\text{OLS}}. Each ellipse represents parameter combinations with equal RSS.
  • The Ridge Constraint (Green Circle): The inequality β12+β22≤s\beta_1^2 + \beta_2^2 \le s defines a smooth circle (disk) centered at the origin.
  • The Ridge Solution (Red Dot): The constrained optimum is the point where the expanding RSS ellipse first touches the circular boundary.
💡

Why Ridge Doesn't Sparsify: Because the L2L_2 constraint boundary is a smooth circle with no sharp vertices on the coordinate axes, the elliptical contour touches the circle along its smooth arc rather than precisely on the axis. Thus, both β1\beta_1 and β2\beta_2 remain non-zero!


8. The Bias-Variance Trade-Off

Why would we deliberately add bias to our estimates? The answer lies in the Mean Squared Error (MSE) decomposition of an estimator:

MSE(β^)=E[∥β^−β∥2]=Bias2(β^)+Variance(β^)\begin{aligned} \text{MSE}(\hat{\boldsymbol{\beta}}) &= \mathbb{E}\left[\|\hat{\boldsymbol{\beta}} - \boldsymbol{\beta}\|^2\right] \\ &= \text{Bias}^2(\hat{\boldsymbol{\beta}}) + \text{Variance}(\hat{\boldsymbol{\beta}}) \end{aligned}

The Bias-Variance Trade-off: total error curve reaches a minimum at optimal lambda

  • At λ=0\lambda = 0 (OLS): Bias=0\text{Bias} = 0, but when predictors are correlated, Variance\text{Variance} is enormous. Total error is high.
  • As λ\lambda increases: We introduce a small amount of bias (coefficients are shrunk toward zero). In exchange, parameter variance drops precipitously.
  • At λ∗\lambda^* (Sweet Spot): The reduction in variance far outstrips the minor gain in bias, yielding the lowest total prediction error!
  • As λ→∞\lambda \to \infty: Bias becomes dominant (underfitting), causing total MSE to rise again.

9. Feature Standardization: Why Must We Scale Predictors?

The Ridge penalty adds λ∑j=1pβj2\lambda \sum_{j=1}^{p} \beta_j^2. Notice that the penalty treats all coefficients symmetrically!

Suppose feature x1x_1 is household income in dollars (\80,000)andfeature) and feature x_2isnumberofbedrooms( is number of bedrooms (3$).

  • A one-unit change in bedrooms corresponds to a large slope (e.g., β2=30,000\beta_2 = 30,000).
  • A one-unit change in dollar income corresponds to a tiny slope (e.g., β1=0.5\beta_1 = 0.5).

If features are unscaled, the penalty β22=(30,000)2=900,000,000\beta_2^2 = (30,000)^2 = 900,000,000 will dwarf β12=0.25\beta_1^2 = 0.25! Ridge will brutally penalize the bedroom coefficient simply because of the units used to measure it.

Standardization brings all features to mean zero and variance one

Standardization Formula (ZZ-Score)

Before applying Ridge Regression, every predictor must be scaled to mean 00 and standard deviation 11:

zij=xij−xˉjsjz_{ij} = \frac{x_{ij} - \bar{x}_j}{s_j}

Never Penalize the Intercept!

The intercept β0\beta_0 represents the baseline target value when all features are zero. Penalizing β0\beta_0 would unfairly force predictions toward zero simply because of the vertical origin of yy. In practice:

  1. We center the target: yi←yi−yˉy_i \leftarrow y_i - \bar{y}.
  2. Or we omit β0\beta_0 from the penalty matrix: diag(0,λ,λ,…,λ)\text{diag}(0, \lambda, \lambda, \dots, \lambda).

10. Choosing Optimal λ\lambda via Cross-Validation

How do we pick the best value for λ\lambda? Because λ\lambda is a hyperparameter, it cannot be learned by minimizing training error (which would always choose λ=0\lambda = 0).

Instead, we use KK-Fold Cross-Validation:

K-Fold Cross-Validation workflow: splitting into folds and testing on validation holdouts

  1. Split training data into KK equal subsets (folds).
  2. For a grid of candidate λ\lambda values: train on K−1K-1 folds and evaluate validation MSE on the remaining fold.
  3. Average validation errors across all KK iterations.
  4. Select the λ∗\lambda^* that achieves the minimum average cross-validation MSE.

Figure 3.4: Ridge Geometry & Smooth Shrinkage

β̂_Ridge:[1.90, 0.86]ᵀ
||β̂||₂² (Norm):4.36
Est. Variance:1.42
Est. Bias²:0.23
Regularization Penalty (λ = 3.0)3.00
025

Interactive Ridge Regularization. The Ridge solution is the tangency point where the elliptical OLS contours meet the smooth circular L₂ penalty boundary ||β||₂² ≤ s. As λ increases, the circle shrinks toward zero.

What to try

  • Drag the λ\lambda Slider from 00 to 2020:
    • In Geometric Contours View: Watch the green circular constraint disk shrink toward the origin. Notice how the red tangency point β^Ridge\hat{\boldsymbol{\beta}}_{\text{Ridge}} glides along the trajectory path from β^OLS\hat{\boldsymbol{\beta}}_{\text{OLS}} toward (0,0)(0, 0).
    • In Coefficient Shrinkage Paths View: Observe how both β1\beta_1 and β2\beta_2 decay smoothly toward zero without ever abruptly dropping to zero.
  • Inspect the Live Readouts:
    • At λ=0\lambda = 0: Variance is high (≈4.2\approx 4.2), Bias2=0\text{Bias}^2 = 0.
    • At λ≈4.0\lambda \approx 4.0: Variance drops by over 70%70\%, while Bias2\text{Bias}^2 increases only slightly, giving a superior overall model.
  • Click the Presets: Switch between Unregularized OLS, Balanced Ridge, and Heavy Regularization.

Key ideas at a glance

Summary Reference Table

ConceptOrdinary Least Squares (OLS)Ridge Regression (L2L_2)
Objective Functionmin⁡∥y−Xβ∥22\min \|\mathbf{y} - \mathbf{X}\boldsymbol{\beta}\|_2^2min⁡∥y−Xβ∥22+λ∥β∥22\min \|\mathbf{y} - \mathbf{X}\boldsymbol{\beta}\|_2^2 + \lambda \|\boldsymbol{\beta}\|_2^2
Closed-Form Solutionβ^=(XTX)−1XTy\hat{\boldsymbol{\beta}} = (\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^T\mathbf{y}β^=(XTX+λIp)−1XTy\hat{\boldsymbol{\beta}} = (\mathbf{X}^T\mathbf{X} + \lambda \mathbf{I}_p)^{-1}\mathbf{X}^T\mathbf{y}
Matrix InvertibilityRequires full column rank (rank(X)=p\text{rank}(\mathbf{X}) = p)Always invertible for any λ>0\lambda > 0
Multicollinearity ImpactWild coefficient instability and massive varianceStabilizes estimates; shrinks coefficients smoothly
Constraint ShapeNone (unconstrained)Smooth circle/sphere (∑βj2≤s\sum \beta_j^2 \le s)
Feature SelectionNone (all features retained)None (coefficients shrink near zero, but never exact zero)
Feature ScalingScale-invariant (coefficients adjust units)Mandatory (unscaled units cause unequal penalties)
Intercept TreatmentIntercept included in parametersIntercept β0\beta_0 is never penalized

Check your understanding

🧩

Ready to test yourself?

15 questions · explanations shown after


Teach & Solidify

🎓
Feynman Teaching Card

Teach This: Ridge Regression (L2 Regularization)

Core Intuition

Ridge prevents multicollinear overfitting by penalizing squared slopes: β̂_Ridge = (XᵀX + λI)⁻¹Xᵀy, trading a tiny pinch of bias for a massive drop in parameter variance.

Key Concepts to Explain

  • 1Multicollinearity causes XᵀX to be nearly singular, making OLS coefficients wildly unstable.
  • 2Ridge adds λ∑βⱼ² (L₂ penalty), shrinking coefficients smoothly toward zero.
  • 3Adding λI shifts all eigenvalues of XᵀX by +λ, guaranteeing invertibility for any λ > 0.
  • 4Geometrically, Ridge is the tangency between elliptical OLS contours and a circular constraint disk.
  • 5Features must be standardized first, and the intercept β₀ is never penalized.

⚠️ What Most Students Get Confused About

Assuming Ridge performs automatic feature selection. Ridge shrinks coefficients close to zero, but retains every single predictor in the model.

✍️
Active Recall Practice

Explain Ridge Regression in your own words

Imagine you are explaining this idea to a friend or classmate with no math background. Writing it out forces your brain to bridge gaps in your intuition.

Saved locally on your device

Resources & GitHub

🎯

Mastered this concept?

Tick this box when you feel confident explaining it.

📁
Study Notes & Files3 files

Topic Resources

GitHub↗
📐

Ridge_Regression_Notes.tex

LaTeX Source

34.5 KB · Modified Latest

📝

Ridge_Regression_Summary.md

Markdown Note

1.7 KB · Modified Latest

📕

Ridge_regression.pdf

PDF Note

877.7 KB · Modified Latest

Was this clear?