Foundations to Frontier
Tests
D. Classical Machine Learning › D0 Core Concepts (concept pages)

Bias–Variance Trade-off, Under- and Overfitting, and Learning Curves

A model can fail in two opposite ways. It can be too simple to capture the pattern (underfitting, high bias), or so flexible that it memorises noise in the training data (overfitting, high variance). This page turns the bias–variance theory of B1.3 into practical diagnosis: validation curves show error against model complexity, learning curves show error against training-set size, and together they tell you whether to collect more data, add features, increase or decrease capacity, or regularise. In the exercises you build validation and learning curves for polynomial regression and estimate bias and variance by simulation; then you test whether a power law fitted to a learning curve predicts the error with 13 times more data, and whether the diagnosis picks the right fix.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Too stiff or too wobbly

Imagine tracing a hill’s outline with a ruler: it is too stiff and misses the curve, however carefully you trace. That is underfitting. Now trace it with a wobbly string that passes through every pebble: it copies every bump, and a new photo of the same hill would look completely different. That is overfitting. A good model is flexible enough for the hill but not for the pebbles.

Learning curves: underfitting and overfitting
noise floor σ² = 0.09123210032000.20.40.6training examples n (log scale)
■ training error 0.287 · ■ validation error 0.305 at n = 320
diagnosis: high bias: both curves plateau well above the noise floor — more data will not help; use a richer model
Validation error is capped at 0.6 on the plot. Degree 0–1 cannot bend like a sine (high bias); degree 3 is about right; degree 9 fits noise when data are scarce (high variance) but converges as n grows.
Why engineers care

Knowing which failure you have decides what to spend money on. More flight tests won’t fix a model that is too simple. A more complex model won’t fix one that already memorises your few test campaigns. Learning curves answer this question before you spend.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A straight line fitted to a sine wave is…
  2. 2. A model that is perfect on training data but poor on new data is…
  3. 3. In the demo, more data helps most for…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Two diagnostic plots

  • Validation curve: error against complexity, such as degree, depth or 1/λ. Training error keeps falling. Validation error first falls, then rises, and the minimum marks the best complexity.
  • Learning curve: error against the number of training examples, for a fixed model. Training error rises and validation error falls as n grows, and they meet at a plateau.
Symptom Diagnosis Remedies
high training error, small gap high bias (underfit) richer model, better features, less regularisation
low training error, large gap high variance (overfit) more data, simpler model, regularisation, ensembling, early stopping
both low and close to the target good stop
from sklearn.model_selection import learning_curve, validation_curve
sizes, tr, va = learning_curve(model, X, y, train_sizes=[0.1, 0.3, 0.6, 1.0], cv=5, scoring="neg_mean_squared_error")
tr2, va2 = validation_curve(model, X, y, param_name="poly__degree", param_range=range(1, 12), cv=5)
📝 Quick check (Level 1)
0/3 answered
  1. 1. Training error 0.30, validation error 0.31, target 0.1: diagnosis?
  2. 2. Training error 0.01, validation error 0.40: remedy?
  3. 3. A validation curve plots error against…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

The decomposition behind the plots

For squared loss at a point x, averaging over training sets (B1.3):

E[(y − f̂(x))²] = bias²(x) + variance(x) + σ², where bias(x) = E f̂(x) − f(x) and variance(x) = Var f̂(x).

Bias falls and variance rises as capacity grows. Variance shrinks roughly as 1/n as data grow, which is why learning curves of flexible models converge. The noise σ² is a floor no model can beat. An asymptote well above it means bias.

Learning curves of many models follow a power law in n: err(n) ≈ a + b·n^(−c). Here a is the irreducible-plus-bias floor. Fitting it to small-n points lets you estimate what more data would buy.

🐍 Exercise 1: validation curves, learning curves and bias–variance
Fit polynomials of several degrees to noisy samples of sin(2πx); compute the validation curve, a learning curve for degree 9, and bias² and variance by refitting on 300 simulated training sets; write a rule that diagnoses high bias, high variance or a good fit.
📝 Quick check (Level 2)
0/3 answered
  1. 1. With σ = 0.3, the lowest possible expected MSE is…
  2. 2. Variance of a flexible model typically shrinks as…
  3. 3. In err(n) = a + b n^(−c), a is…

Level 3: Advanced

★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.

Beyond the classical U-curve

  • Regularisation moves you along the trade-off continuously (D1.5, D1.6). Ensembles cut variance (bagging) or bias (boosting) (D7).
  • Model selection with CV finds the bottom of the validation curve, but noisily (D0.4). Prefer the simplest model within one standard error of the best.
  • Very over-parameterised models can show double descent: test error falls again past the interpolation threshold (B4.4). The classical picture still holds within a fixed model family and moderate size.
  • For classification with 0–1 loss, bias and variance do not add simply, but the diagnostic logic is the same.

Interview questions.

  • Your model has 99% training and 70% validation accuracy. What do you do? High variance: get more data, regularise, simplify, use early stopping or ensembles.
  • Why doesn’t more data fix underfitting? Bias does not depend on n; the curves have already converged above the target.
📝 Quick check (Level 3)
0/3 answered
  1. 1. The 'one-standard-error rule' picks…
  2. 2. Bagging mainly reduces…
  3. 3. Double descent appears…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Can a learning curve predict the value of data?

Exercise 1. With 30 training points, validation error is lowest at degree 3. Over 300 simulated training sets:

  • degree 1 has bias² 0.177 and variance 0.023;
  • degree 9 has bias² 0.0002 but variance 0.235, more than twice the noise σ² = 0.09.

Exercise 2: extrapolating learning curves. Median validation errors at n = 20–150 (60 repetitions each) are fitted with err(n) = a + b·n^(−c) and extrapolated to n = 2000.

Degree Train / val error at n = 150 Fitted plateau a Predicted at n = 2000 Actual at n = 2000
1 0.282 / 0.291 0.287 0.287 0.288
3 0.092 / 0.097 0.098 0.098 0.095
9 0.083 / 0.095 0.095 0.095 0.091

Extrapolating 13× beyond the data, the power law predicts errors to within 0.3–4%. It slightly overestimates for flexible models, which keep improving towards the noise floor (0.09) more slowly than the fit expects. For degree 1, both curves sit on a plateau 3× above the noise floor with almost no gap, which says high bias before any extra data is collected.

Which fix? At n = 30, validation errors:

Model Validation error Doubling the data Switching to degree 3
degree 1 (high bias) 0.310 0.296 0.105
degree 9 (high variance) 0.126 0.103 0.105

The diagnosis predicts the right remedy. Extra data barely help the biased model, while a richer model cuts its error threefold. For the high-variance model, more data and a simpler model help about equally.

🐍 Exercise 2 (research): predicting the payoff of more data
Measure median learning curves of polynomial models at small n; fit a power law a + b·n^(−c) and extrapolate to n = 2000; compare with the actual error; then, at n = 30, compare doubling the data with changing the model for an underfitting and an overfitting model.

Bias and variance in AI, robotics and aerospace

  • System identification: too few parameters miss dynamics (bias); too many fit sensor noise (variance). Learning curves guide how many test flights to plan.
  • Perception models: learning curves of detection error against labelled images decide labelling budgets.
  • Scaling laws for large models are learning curves in n and model size (B4.10).

References

  1. S. Geman, E. Bienenstock, R. Doursat (1992). “Neural networks and the bias/variance dilemma.” Neural Computation 4(1).
  2. T. Hastie, R. Tibshirani, J. Friedman (2009). The Elements of Statistical Learning, 2nd ed., chapter 7. Springer.
  3. C. Perlich, F. Provost, J. Simonoff (2003). “Tree induction vs. logistic regression: a learning-curve analysis.” JMLR 4.
  4. J. Hestness et al. (2017). “Deep learning scaling is predictable, empirically.” arXiv:1712.00409.
  5. A. Ng (2018). Machine Learning Yearning, chapters on bias and variance.