ML
intermediate
Overfitting & Regularization
Interactive demonstration of overfitting and how regularization techniques (L1, L2, Dropout) help.
Overfitting & Regularization
Learn how regularization prevents overfitting and improves generalization
Gap: 0.18
Regularization Method
Strength Parameter
0.50
WeakMediumStrong
L2 Regularization (Ridge)
Adds squared weights to loss. Encourages small weights - prevents any single weight from dominating.
Loss = MSE + λ · Σw²
Current Metrics
Training Error
0.2500
Validation Error
0.4268
Without Regularization
Overfitting
L2 Regularization
Applied
Bias-Variance Tradeoff
Training Error:
0.250
Validation Error:
0.427
🟢 Gap reduced - model generalizes better to unseen data
How L2 Regularization (Ridge) Works
L2 regularization adds λ·Σw² to the loss function:
- Shrinks all weights: Prevents large weight values
- Distributed complexity: All features stay active but smaller
- Smoother decisions: Penalizes sharp, complex boundaries
Overfitting Signs
- ✗ Low training error, high validation error
- ✗ Wiggly model fit curves
- ✗ Large gap between errors
When to Regularize
- ✓ Limited training data
- ✓ Complex model architecture
- ✓ High variance/large error gap
λ Tuning Tips
- λ=0: No regularization (overfitting)
- λ=0.5: Balanced (ideal)
- λ=1: Strong (underfitting)
L1 or L2?
Sort
Sort each property by the penalty it describes.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
L1 (Lasso)
Drop items hereL2 (Ridge)
Drop items here6 pieces left to place
Test your knowledge
20 questions
Question 1 of 20
Score: 0
Overfitting is when a model…
Learn these first
Interview Questions
Goldman Sachs
Citadel
BlackRock
JPMorgan
Wells Fargo
FICO
Apple
Google
Waymo
Amazon
Uber
Twitter
Tesla
Waymo
Cruise
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required