Left alone, a model will chase noise — fitting big, wobbly coefficients that overfit. Regularization adds a penalty on coefficient size to the loss, keeping the model simpler. The two classic penalties, L2 (Ridge) and L1 (Lasso), look almost identical but do something profoundly different to your features.
You fit a model by minimising error. Regularization adds a second term — a penalty on how large the coefficients are — so the model must justify every bit of complexity:
The strength λ dials how hard you push. Crank it up and watch the two penalties shrink the same starting coefficients in very different ways:
Ridge (L2) — shrinks all toward 0, smoothly
Lasso (L1) — drives some to exactly 0
This is the famous picture. The penalty defines a "budget" region the coefficients must stay inside, and the solution is where the error contours first touch it. L2's budget is a circle (smooth) — contours usually touch it at a point where both coefficients are small but non-zero. L1's budget is a diamond with sharp corners on the axes — and contours tend to touch a corner, where one coefficient is exactly zero.
That single geometric difference is why Lasso performs feature selection — it throws features out entirely, giving a sparse, interpretable model — while Ridge keeps every feature but small, which behaves better when features are correlated. (Elastic Net blends both.)
Curated companion: StatQuest — Ridge & Lasso · ISLP Ch.6.