Interactive Fit Canvas
Blue points are noisy samples from a hidden cubic. Click empty space to add a point, drag points to move them, then slide the degree to refit by least squares. The orange curve animates to the new fit.
Add at least two points by clicking the chart to fit a curve.
Error vs Degree: the U-Curve
Training error (blue) always falls as degree rises, but holdout error (orange) traces a U: high in the underfit zone, lowest at the sweet spot, and rising again as the model overfits noise.
Worked Example: Degree 1 vs 3 vs 12
Same data, three models. These mini charts refit whenever you edit the points above.
Degree 1: Underfit
A straight line cannot bend with the cubic signal. High bias: both train and holdout error stay large.
Degree 3: Good fit
Matches the true generating process. Low bias, low variance: holdout error is near its minimum.
Degree 12: Overfit
The curve threads through noise. Train error is tiny but holdout error explodes: high variance.
Check Your Understanding
Five quick questions with instant feedback.
Overfitting FAQ
What is overfitting?
Overfitting is when a model fits noise in the training data instead of the underlying pattern, so training error is low but performance on new data is poor.
How do I detect overfitting?
Compare training error with error on held-out data. A large gap, or holdout error rising while training error keeps falling, signals overfitting.
How do I fix underfitting?
Increase model capacity: higher polynomial degree, more features, or a more expressive model class, until holdout error stops improving.
Why does holdout error form a U shape?
At low capacity, bias dominates. At high capacity, variance dominates. Total expected error is their sum, minimized in between: the bias-variance tradeoff.