The idea
Under squared-error loss, a model's expected prediction error at a point can be split into three pieces that add together:
- Bias is how far the model's average prediction, taken over many hypothetical training sets, sits from the true function: . High bias means the model class is too restrictive to represent the pattern — a straight line trying to fit a curve, or a shallow tree trying to separate classes that need several splits.
- Variance is how much the prediction moves when you retrain on a different sample from the same distribution: . High variance means the model is chasing the noise in one particular training set rather than the underlying signal.
- Irreducible noise, , is the floor imposed by randomness in the data-generating process itself. No amount of modeling removes it.
You never observe bias and variance directly — you only ever see one fitted model and its error on one test set. What you can observe is the gap between training error and test error, and that gap is your best working proxy: a model with training error close to test error (both mediocre) is underfitting and needs more capacity; a model with training error far below test error is overfitting and needs less capacity, more data, or more regularization. Increasing model flexibility — deeper trees, more features, weaker regularization, a higher-degree polynomial — typically pushes bias down and variance up. Finding the sweet spot on that curve is what "model selection" means in practice.
Worked example
Fit polynomials of increasing degree to noisy data generated from a smooth underlying curve with irreducible noise variance . Measured mean squared error on a held-out test set looks like this:
| Degree | Train MSE | Test MSE | Diagnosis |
|---|---|---|---|
| 1 (line) | 0.42 | 0.45 | high bias — both errors high and close together |
| 3 | 0.09 | 0.11 | near the sweet spot — small, stable gap |
| 9 | 0.01 | 0.35 | high variance — tiny train error, large gap |
Reading the table the way an interviewer wants:
- From degree 1 to degree 3, both train and test error drop sharply — the model was too simple, so adding capacity reduced bias with only a small variance cost.
- From degree 3 to degree 9, train error keeps falling toward zero, but test error gets worse. The extra capacity is no longer tracking signal; it is memorizing the particular noise draws in this training sample. The growing train/test gap is the variance term taking over.
- Degree 3 is close to the true complexity of the generating process here, so its test error (0.11) is not far above the noise floor () plus the small remaining bias — there just is not much room left to improve without a fundamentally different feature set.
The shape to remember: test error traces a U as capacity increases — bias dominates the left arm, variance dominates the right arm, and the minimum sits wherever their sum is smallest.
Cheat sheet
Formula:
| Symptom | Term | Fix |
|---|---|---|
| Train error high, test error ≈ train error | high bias / underfitting | more capacity, more features, less regularization, longer training |
| Train error low, test error ≫ train error | high variance / overfitting | more data, regularization, simpler model, bagging, early stopping, dropout |
| Both errors high and far apart | often a bug — check leakage, labels, preprocessing; but can be genuine: a misspecified model on noisy data, or train/test distribution shift | debug the pipeline first, then suspect misspecification or distribution shift |
- k-NN: small → low bias, high variance (jagged decision boundary chases every neighbor). Large → high bias, low variance (smoother, more averaged boundary).
- Decision trees: deep, unconstrained trees → low bias, high variance. Shallow trees → high bias, low variance.
- Regularization strength : increasing increases bias and decreases variance; it is a direct dial on this tradeoff.
- Bagging (e.g. random forests) mainly reduces variance, by averaging many decorrelated high-variance learners, without increasing bias much.
- Boosting mainly reduces bias, by sequentially fitting residuals with weak learners, though it can raise variance if left unchecked.
- More training data reduces variance but does nothing for bias — a model that is too simple stays too simple no matter how much data you feed it.
- Underfitting and high bias are the same idea from two angles; overfitting and high variance are the same idea from two angles.