← Back to list

Regularized Linear Models Explained with Geometric Intuition

Linear Regression is often the first model we learn in Machine Learning. It’s simple, fast, interpretable — and dangerously easy to…

Roshmita Dey · 2025-11-28 05:06 · 5 claps · 3.4 min read paywalled
#lasso-regression #ridge-regression #linear-models #overfitting #regulari
Open on Medium ↗
Wiki topics: ML · Machine Learning EDU · Education & Learning

Regularized Linear Models Explained with Geometric Intuition

Linear Regression is often the first model we learn in Machine Learning. It’s simple, fast, interpretable — and dangerously easy to overfit.

This is where regularization comes in.

In this article, you’ll learn:

  • Why regularization is necessary
  • How Ridge, Lasso, and Elastic Net work
  • The geometric interpretation that explains everything
  • When to use which model in real-world ML problems

Why Do We Even Need Regularization?

Ordinary Least Squares (OLS) minimizes:

This works well when:

  • You have few features
  • Features are not correlated
  • Noise is low

But in real-world ML:

  • Features are many
  • Data is noisy
  • Multicollinearity is common
  • Overfitting is a serious risk

This leads to:

  • Large, unstable coefficients
  • Poor generalization
  • High variance

Regularization controls model complexity by penalizing large coefficients.

The Core Idea of Regularization

Instead of minimizing only error, we minimize:

Loss = Data Error + λ*Penalty

  • λ (lambda) controls how strong the penalty is
  • Higher λ → simpler model → more bias, less variance
  • Lower λ → complex model → less bias, more variance

This is the bias–variance tradeoff in action.

Ridge Regression (L2 Regularization)

Objective Function

What Ridge Does

  • Shrinks all coefficients smoothly toward zero
  • Handles multicollinearity extremely well
  • Never produces exact zeros
  • Keeps all features, just with smaller weights

It is best when:

  • All features are useful
  • You care about prediction over interpretability
  • Features are highly correlated

Lasso Regression (L1 Regularization)

Objective Function

What Lasso Does

  • Forces some coefficients to become exactly zero
  • Performs automatic feature selection
  • Produces a sparse model
  • Improves interpretability

It is best when:

  • Many irrelevant features exist
  • You want feature selection
  • Model simplicity matters

Elastic Net (L1 + L2)

Elastic Net combines:

  • Lasso’s sparsity
  • Ridge’s stability

It is best when:

  • Features are highly correlated
  • You still want feature selection
  • Lasso alone is unstable

The Geometric Interpretation

This explains why Lasso selects features but Ridge does not.

Assume we have only two coefficients: β₁ and β₂.

Step 1: The Loss Function as Contours

The squared error loss:

||y — Xβ||² = c

Forms elliptical contours in the (β₁, β₂) plane.

Each ellipse = same error.

We want the smallest ellipse that touches the constraint region.

Ridge Geometry (L2 Constraint)

Ridge constrains:

β₁² + β₂² ≤ t

This is a circle.

  • The ellipse expands
  • It touches the smooth boundary of the circle
  • Since the boundary is smooth, the contact point:
  • Almost never lies exactly on an axis

Result:

  • Coefficients become small
  • But not exactly zero

This is why Ridge shrinks but does NOT select features.

Lasso Geometry (L1 Constraint)

Lasso constrains:

| β₁| + | β₂| ≤ t

This is a diamond shape.

  • The ellipse expands
  • It touches one of the sharp corners of the diamond
  • The corners lie on the axes:
  • β₁ = 0 or β₂ = 0

Result:

  • Some coefficients become exactly zero
  • Automatic feature selection happens

This geometric shape is the true reason behind sparsity in Lasso.

Elastic Net Geometry

Elastic Net is a rounded diamond:

  • Part circle (Ridge)
  • Part diamond (Lasso)

This gives:

  • Shrinkage
  • Sparsity
  • Stability for correlated features

When Should You Use What?

Use Ridge when:

  • Your goal is pure predictive performance
  • Features are highly correlated

Use Lasso when:

  • You want feature selection
  • Interpretability is important

Use Elastic Net when:

  • You want both stability + sparsity
  • You are working with high-dimensional correlated data

“Regularized linear models add a penalty to the loss function to prevent overfitting. Ridge regression uses an L2 penalty that shrinks coefficients smoothly and handles multicollinearity, while Lasso uses an L1 penalty that forces sparsity through its diamond-shaped constraint geometry. Elastic Net combines both penalties to provide stability with feature selection for correlated features.”


메타데이터
post_id
003dc63a8ec0
slug
regularized-linear-models-explained-with-geometric-intuition-003dc63a8ec0
url
https://medium.com/@roshmitadey/regularized-linear-models-explained-with-geometric-intuition-003dc63a8ec0
canonical_url
https://medium.com/@roshmitadey/regularized-linear-models-explained-with-geometric-intuition-003dc63a8ec0
author_url
https://medium.com/@roshmitadey
status
ok
fetched_at
2026-06-09 15:37:30