Classical & Statistical Learning

ridge and lasso regularization

/ rij and LASS-oh reg-yuh-luh-ri-ZAY-shun /

Regularization is a leash you put on a model to stop it from over-explaining the past. A model with many features can twist itself to fit the training data perfectly — including its random noise — and then fail miserably on anything new. That's overfitting. Ridge and lasso are two famous leashes: both add a penalty for large weights to the model's goal, so it must justify every bit of complexity. The model is told, in effect: "fit the data, but keep your coefficients small unless they truly earn their size."

The two differ in the shape of the penalty, and that small difference changes everything. Ridge (also called L2) penalizes the sum of the squared weights; it shrinks all the coefficients smoothly toward zero but rarely sets any exactly to zero, so every feature keeps a small say. Lasso (L1) penalizes the sum of the absolute weights, and this has a striking side effect: it pushes the weakest coefficients all the way to exactly zero, effectively switching those features off. Lasso therefore does automatic feature selection, handing you a simpler model that uses only the inputs that matter.

The choice depends on your goal. Use ridge when you believe many features each contribute a little and you just want to tame their influence — especially when features are correlated. Use lasso when you suspect only a few features really matter and you want the model to find and keep them, discarding the rest for a cleaner, more interpretable result. Both have a dial — how hard to pull the leash — that you tune by cross-validation: too loose and you still overfit, too tight and you strangle the model into underfitting, missing real patterns.

You predict house price from 100 features. Plain regression gives wild coefficients that ace the training set but flop on new homes. Add a lasso penalty: it zeroes out 85 weak features (lot orientation, paint color...) and keeps 15 (size, location, age). The leaner model predicts new homes better — and you can read what it relies on.

Lasso zeros out weak features; ridge shrinks them all but keeps them.

The one-line difference worth memorizing: lasso (L1) can zero out features and so selects them; ridge (L2) shrinks everything but keeps it all. The penalty strength is a hyperparameter — too strong and you swing from overfitting to underfitting.

Also called
L2 and L1 regularizationweight penalty岭回归套索回归嶺迴歸套索迴歸L1正则化L2正则化