Regularization
Any technique that discourages a model from becoming too complex, so it generalizes better to new data.
Also L1 · L2 · weight decay
It is like a word limit on an essay. You cannot ramble about every tiny detail, so you have to focus on what really matters.
Where it fits
+All relationships as a list
Is a kind of / part of
Kinds and parts
Siblings
- Accuracy
- Bias-Variance Trade-off
- Cross-Validation
- Curse of Dimensionality
- Data, Features and Labels
- Gradient Descent
- Hyperparameters
- Linear Algebra Basics
- Log Loss (Cross-Entropy)
- Loss Function
- Overfitting
- Precision, Recall and F1
- Probability Basics
- Regression Metrics
- ROC Curve and AUC
- Train, Validation and Test Sets
Uses / built on
How it works
Overfitting happens when a model uses its flexibility to memorize noise. Regularization takes some of that flexibility away.
The classic way is to add a penalty on the size of the weights to the loss. Now the model has two goals: fit the data, and keep the weights small. Large weights are only worth it if they really help.
- L2 (ridge, weight decay) penalizes squared weights. It shrinks everything a little and spreads importance across correlated features.
- L1 (lasso) penalizes absolute weights. It tends to set unimportant weights to exactly zero, giving a simpler model.
Other techniques do the same job differently: dropout randomly disables neurons during training, early stopping halts training before memorization sets in, and data augmentation creates new varied training examples.
Everyday use cases
- Case 01
Predicting with many features
Lasso picks out the handful of useful features among hundreds of candidates in a marketing dataset.
- Case 02
Training neural networks
Weight decay is on by default in most modern training recipes, including for large language models.
Strengths, weaknesses and when to use it
Strengths
- Cheap and simple to add.
- L1 doubles as automatic feature selection.
Weaknesses
- The penalty strength is another hyperparameter to tune.
- Too much regularization causes underfitting.
When to use itWhenever a model has many parameters relative to the amount of training data.
Compare with
Check yourself
- Q01
What does L1 regularization tend to do to weights?
Show answer
B: Push many of them to exactly zero