Bias-Variance Decomposition: Concepts, Math, and Model Choices
Machine LearningModel answerLast updated
Derive the bias-variance-noise decomposition of MSE, and explain how polynomial degree, dataset size, and L2 regularization shift each term.
The Decomposition of Prediction Error
When you evaluate a regression model's expected test error at a point x, the mean squared error can be split into three separate, non-negative terms: one that captures systematic error from model assumptions, one that captures sensitivity to which training sample you happened to draw, and one that no model can ever remove.
Answer all three parts below.
Part 1 — Definitions
Give precise conceptual definitions of bias and variance in predictive modeling. Make clear:
- What each term measures
- What causes each one to be large or small
- How they relate to the underlying true function versus the observed targets
Part 2 — Polynomial Degree on a Small Dataset
You have n = 15 training points drawn from a smooth nonlinear function. You fit polynomial regression models of increasing degree (1, 2, 3, … up to 14).
Describe what happens to bias and variance as degree increases. Explain:
- Why does bias decrease?
- Why does variance increase?
- What shape does the test error curve take, and why does training error not reflect this?
Part 3 — Effect of More Training Data and Regularization
Using the mathematical decomposition
E[(y - f_hat(x))^2] = Bias(f_hat(x))^2 + Var(f_hat(x)) + sigma^2
explain:
- Which terms are affected when you increase the size of the training set, and which are not — and why.
- How L2 (ridge) regularization shifts the balance between bias and variance, and why this can still lower total test error relative to the unregularized model.
Reference notation:
f_hat(x): the model fitted on one training setf(x): the true underlying functiony = f(x) + epsilon: the observed target, whereepsilonis zero-mean noise with variancesigma^2- The expectation in the decomposition is taken over independently drawn training sets of size n
Hints
Hint 1
For Part 1, ask yourself: if you trained the same algorithm on many independent datasets of the same size, what would the spread of predictions look like versus their average? Bias and variance describe those two separate things.
Hint 2
For Part 2, recall that OLS with p parameters fitted to n points has an average prediction variance proportional to sigma^2 * p/n. Think about what happens to that ratio as degree approaches n.
Hint 3
For Part 3, ridge regression replaces (X^T X)^-1 with (X^T X + lambda*I)^-1. Think about what that shift does to directions in feature space where the data gives weak information — and how that affects each term in the decomposition separately.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
What a strong answer covers
A strong answer (a) states clearly what expectation is being taken, (b) derives the decomposition rather than just citing it, and (c) uses the decomposition to reason concretely about each scenario.
Part 1 — Definitions
Fix a test point x. Imagine running your learning algorithm on many independently drawn training sets of size n. Each run produces a different fitted model f̂.
Bias is the gap between the average prediction and the truth:
Bias(f̂(x)) = E_D[f̂(x)] - f(x)
It measures systematic, persistent error. If the model family cannot represent f — for example, fitting a straight line to a sinusoidal target — no amount of additional data or averaging fixes it. The model is structurally wrong.
Variance is how much predictions fluctuate across those training sets:
Var(f̂(x)) = E_D[(f̂(x) - E_D[f̂(x)])^2]
It measures sensitivity to which particular sample you happened to draw. A high-variance model memorises the noise in one training set and would look very different if retrained on another.
Irreducible noise σ² is Var(ε), the inherent randomness in y given x. Because it belongs to the data-generating process, no model can remove it.
A useful analogy: bias is a rifle whose sights are miscalibrated — shots cluster consistently away from the target. Variance is a shaky hand — shots scatter widely around wherever the sights point.
Derivation of the decomposition
Write y = f + ε (suppressing x for clarity), with E[ε] = 0, Var(ε) = σ², and ε independent of the training set D.
Step 1 — isolate the noise:
E[(y - f̂)^2] = E[(f - f̂ + ε)^2]
= E[(f - f̂)^2] + 2·E[ε]·E[f - f̂] + E[ε^2]
= E[(f - f̂)^2] + σ^2
The cross-term drops because ε has mean zero and is independent of f̂.
Step 2 — add and subtract the mean prediction f̄ = E_D[f̂]:
E[(f - f̂)^2] = E[(f - f̄ + f̄ - f̂)^2]
= (f - f̄)^2 + 2(f - f̄)·E[f̄ - f̂] + E[(f̂ - f̄)^2]
= Bias^2 + 0 + Var(f̂)
The cross-term drops because E[f̂ - f̄] = 0 by definition of f̄.
Result:
E[(y - f̂(x))^2] = Bias(f̂(x))^2 + Var(f̂(x)) + σ^2
Part 2 — Polynomial degree on a small dataset (n = 15)
| Degree | Bias | Variance | Character |
|---|---|---|---|
| 1–2 | High | Low | Underfits; both train and test error are high |
| ~3–5 | Low-moderate | Moderate | Near the sweet spot |
| 14 | ≈ 0 on training points | Very high | Interpolates noise; wildly unstable between points |
Why bias falls: polynomial classes are nested — degree d+1 strictly contains degree d. A higher-degree family can approximate any smooth f more closely, so the best-in-class fit moves closer to the truth.
Why variance rises: for OLS with p = d+1 parameters, the average prediction variance across training inputs equals σ²·p/n. As p approaches n, the Vandermonde matrix becomes ill-conditioned and variance explodes. At degree 14 with 15 points the model has just enough freedom to pass through every training observation, fitting noise perfectly.
Training error decreases monotonically with degree because the model simply has more room to fit the observed points. Test error is U-shaped: it falls as bias drops at low degrees, reaches a minimum, then rises as variance dominates at high degrees. Training error is therefore not a reliable proxy for generalisation quality.
Part 3 — More data, and L2 regularisation
Effect of more data (fixed model class):
- σ²: unaffected. It is a property of the data-generating process, not the model.
- Bias: roughly unchanged for a fixed hypothesis class. A degree-3 polynomial is still a degree-3 polynomial; more data cannot make it cubic in a different sense.
- Variance: decreases as O(1/n). Parameter estimates are averages over more independent points, so by the law of large numbers they concentrate near their expectation. For OLS, average variance is σ²p/n, which shrinks directly with n.
Total error therefore falls toward Bias² + σ², but cannot go below it.
There is also a second-order benefit: because variance shrinks with n, you can afford a more complex model class without test error rising. The optimal polynomial degree increases with n, which also lowers bias. This is why large datasets unlock flexible models.
L2 (ridge) regularisation:
Ridge minimises ‖y − Xβ‖² + λ‖β‖², giving:
β̂_ridge = (X^T X + λI)^{-1} X^T y
Using the SVD X = UDVᵀ, ridge shrinks the coefficient along singular direction j by the factor d_j²/(d_j² + λ). Directions with small singular values — those where the data provide weak information — are shrunk most aggressively.
- Bias increases with λ: E[β̂_ridge] ≠ β because estimates are pulled toward zero. The model can no longer represent the true function exactly.
- Variance decreases with λ: shrinkage dampens exactly the directions that would otherwise amplify noise through a near-singular X^T X.
- Effective degrees of freedom: df(λ) = Σ d_j²/(d_j² + λ), running from p at λ = 0 down toward 0 as λ → ∞.
A key result: there always exists some λ > 0 whose total MSE is lower than unregularised OLS. The small bias introduced is more than offset by the variance reduction, because OLS is at a corner of the tradeoff where variance is at its highest for that model class. Cross-validation selects the λ that minimises estimated test error.
Common mistakes
- Forgetting what the expectation is over. Variance here is over training sets, not over residuals in a single fit.
- Claiming more data reduces bias for a fixed model class. It does not, in general.
- Treating low training error as evidence of low bias. Training error measures fit to one sample, not the expected gap from the truth.
- Assuming the bias-variance tradeoff always produces a clean U-curve. Heavily overparameterised models such as deep networks can exhibit double descent past the interpolation threshold: variance eventually falls again as the model count grows far beyond n. The decomposition still holds, but variance is not monotone in parameter count.
- Concluding that σ² can be modelled away. It can only be reduced by adding features that convert unexplained noise into explained signal — which changes the problem itself.