Skip to content
ML to LLMs
Cheat sheets

Regularization

Every technique that fights overfitting, what it does, and when to reach for it.

TechniqueWhat it doesWhere
L2 (ridge, weight decay)adds λ∑w2\lambda\sum w^2; shrinks weights smoothlylinear models, neural nets (AdamW)
L1 (lasso)adds λ∑∣w∣\lambda\sum\lvert w\rvert; zeroes weightssparse linear models
Elastic netL1 + L2correlated features with sparsity
Early stoppingkeep the best validation checkpointboosting, neural nets
Dropoutrandomly zero activations (scale by 1/(1−p)1/(1-p))neural nets
Data augmentationlabel-preserving variationsvision, audio, text
Tree constraintsmax depth, min samples per leaf, pruningtrees and ensembles
Shrinkagesmall learning rate per boosting roundgradient boosting
Baggingaverage models on bootstrap samplesrandom forests
Normalizationbatch/layer norm stabilizes activationsdeep nets
Smaller model / fewer featuresreduce capacityanywhere
More datathe most reliable fix for varianceanywhere

Diagnose first: a large train-validation gap means overfitting (regularize); both errors high means underfitting (add capacity, features, or train longer).

Always: scale features before L1/L2; tune strength by cross-validation on a log scale; never tune on the test set.

Lessons: Overfitting and bias-variance · Regularization for linear models · Training and regularization