Bias–Variance Tradeoff
Bias–Variance Tradeoff — Balance underfitting against overfitting.
Every model error splits into two parts: bias (too simple, misses the pattern) and variance (too complex, chases noise). You can’t eliminate both — you can only find the sweet spot between them.
- True function
- Fitted models
- Average model
- Your sample & fit
- Bias²
- Variance
- Total error
Bias–variance controls
The idea in plain words
Refit the same model on many resampled datasets and overlay every fitted curve. A simple model gives a tight bundle that misses the true shape — that consistent offset is bias. A complex model gives curves that scatter wildly around the truth — that spread is variance.
You can’t drive both to zero at once: lowering one usually raises the other. Total error is their sum plus irreducible noise, and the best model sits where the two balance — the quantitative version of overfitting vs underfitting.
Now, the math
Expected prediction error decomposes exactly into three parts:
- the average prediction across all resampled fits.
- the true underlying function.
- irreducible noise — the floor no model can beat.
▸ Show the derivation
Bias² measures how far the average model is from the truth; variance measures how much individual fits jump around that average when the training data changes. Increasing complexity lets the average track the truth (less bias) but makes each fit chase its own sample’s noise (more variance). The slider lets you watch the spaghetti tighten then explode.
Trace it by hand
The repo's decomposition experiment traced with real numbers: resample 50 training sets of 12 points from the true curve f of x equals 2 sin(0.6 x) plus 0.3 x with noise sigma equal to 0.6, fit a degree-d polynomial to each, and average the decomposition over the evaluation grid. Values rounded to 4 decimals.
Step 1 — the floor no model can beat
Every total below contains this 0.36 — it is randomness in the data itself, not a modeling error.
Step 2 — degree 1: a tight bundle in the wrong place
All 50 straight lines agree closely with each other — variance is tiny — but they all miss the sine bend by the same amount, so bias dominates.
Step 3 — degree 9: scattered around the truth
The average of the 50 wiggly fits tracks the truth almost perfectly, but each individual fit chases its own sample's noise: bias fell nearly 200-fold while variance grew more than 6-fold.
Step 4 — degree 3 balances the two
Neither term is at its own minimum, but their sum is: 0.4682 beats 0.9156 for degree 1 and 0.6487 for degree 9.
Step 5 — read the tradeoff
One complexity knob, two opposite responses — that is why total error is U-shaped and the best model sits in the middle.
What just happened: Complexity moved error between the two buckets: degree 1 pays 0.51 in bias squared, degree 9 pays 0.29 in variance, and degree 3 pays the least combined at 0.4682. The 0.36 noise floor stayed untouched throughout — no model choice can spend it away.
Now Break It
Try this: At maximum complexity, train error hits zero but test error explodes — the classic overfitting gap.
Control: Complexity slider (push to either extreme)
What happens: The generalization gap! Train error is near zero but test error is huge — high variance overfitting.
Where bias–variance tradeoff is used
The bias-variance tradeoff is the conceptual backbone of every model-selection decision a practitioner makes, so it shows up everywhere rather than in one application. When a data science team tunes the depth of a decision tree, the number of neighbors in k-nearest neighbors, or the strength of a regularization penalty, they are navigating this tradeoff explicitly. In forecasting demand for retail inventory, an overly simple model misses seasonal swings (high bias), while an overly flexible one memorizes past noise and fails next quarter (high variance). Understanding it guides how much data to collect, whether to add features, and when to use ensembles. Techniques like bagging reduce variance and boosting reduces bias, and knowing which lever to pull is what the bias-variance tradeoff teaches.
A frequent misconception is that bias and variance are properties you can read off a single trained model; in fact they describe how predictions behave on average across many datasets drawn from the same source, which is why they are estimated with resampling like cross-validation. Another pitfall is believing you must always accept a strict tradeoff where reducing one raises the other. Adding more training data, better features, or ensemble methods can lower variance without increasing bias, shifting the whole error curve down. Finally, people conflate underfitting and overfitting with training accuracy alone; the reliable signal is the gap between training and validation error, not either number in isolation.
Frequently asked questions
What is the bias-variance tradeoff?
What is the difference between bias and variance?
How do I tell if my model has high bias or high variance?
How can I reduce variance without increasing bias?
Does irreducible error fit into the tradeoff?
Written & reviewed by the ML Visualization team · Last updated .