๐Ÿงฎ Brain Teaser

The Bias-Variance Tradeoff Is an Exact Decomposition

Let f^(x)\hat{f}(x) be any estimator (fitted model) of a true function f(x)f(x), trained on a random dataset. For a fixed test point x0x_0, define the expected prediction error under squared loss:

EPE(x0)=E[(Yโˆ’f^(x0))2]\text{EPE}(x_0) = \mathbb{E}\left[(Y - \hat{f}(x_0))^2\right]

where Y=f(x0)+ฮตY = f(x_0) + \varepsilon with ฮตโˆผ(0,ฯƒ2)\varepsilon \sim (0, \sigma^2) (mean-zero noise, independent of everything), and the expectation is over both the randomness in the training data and the noise ฮต\varepsilon.

Show that EPE decomposes exactly as:

EPE(x0)=ฯƒ2+Bias2(f^(x0))+Var(f^(x0))\text{EPE}(x_0) = \sigma^2 + \text{Bias}^2(\hat{f}(x_0)) + \text{Var}(\hat{f}(x_0))

where:

  • ฯƒ2\sigma^2 is irreducible noise,
  • Bias(f^(x0))=E[f^(x0)]โˆ’f(x0)\text{Bias}(\hat{f}(x_0)) = \mathbb{E}[\hat{f}(x_0)] - f(x_0),
  • Var(f^(x0))=E[(f^(x0)โˆ’E[f^(x0)])2]\text{Var}(\hat{f}(x_0)) = \mathbb{E}\left[(\hat{f}(x_0) - \mathbb{E}[\hat{f}(x_0)])^2\right].

Then answer: why can't any single model simultaneously minimize all three terms? Give a concrete example illustrating the tradeoff.

bias-variance tradeoffexpected prediction errormodel complexitysquared loss

Answer: Bias-Variance Decomposition

Key Idea / Intuition

The expected prediction error has three distinct sources: noise you can never escape (ฯƒ2\sigma^2), systematic error from model assumptions being wrong (bias), and sensitivity to the particular training data you got (variance). The decomposition is just a careful application of "add and subtract the mean" โ€” the same trick that gives E[X2]=Var(X)+(E[X])2\mathbb{E}[X^2] = \text{Var}(X) + (\mathbb{E}[X])^2. The tradeoff is inevitable because making a model more flexible reduces bias but amplifies variance, and vice versa.


Formal Proof / Solution

Step 1: Separate noise from estimation error.

Write Y=f(x0)+ฮตY = f(x_0) + \varepsilon. Since ฮต\varepsilon is independent of f^(x0)\hat{f}(x_0) (which depends only on training data, not on the new noise):

EPE(x0)=E[(f(x0)+ฮตโˆ’f^(x0))2]\text{EPE}(x_0) = \mathbb{E}\left[(f(x_0) + \varepsilon - \hat{f}(x_0))^2\right]

Let u=f(x0)โˆ’f^(x0)u = f(x_0) - \hat{f}(x_0), so we need E[(u+ฮต)2]\mathbb{E}[(u + \varepsilon)^2]. Expanding:

E[(u+ฮต)2]=E[u2]+2E[uโ€‰ฮต]+E[ฮต2]\mathbb{E}[(u + \varepsilon)^2] = \mathbb{E}[u^2] + 2\mathbb{E}[u\,\varepsilon] + \mathbb{E}[\varepsilon^2]

Since ฮต\varepsilon is independent of f^\hat{f} (and hence of uu), and E[ฮต]=0\mathbb{E}[\varepsilon] = 0:

E[uโ€‰ฮต]=E[u]โ‹…E[ฮต]=0\mathbb{E}[u\,\varepsilon] = \mathbb{E}[u]\cdot\mathbb{E}[\varepsilon] = 0

Therefore:

EPE(x0)=E[(f(x0)โˆ’f^(x0))2]+ฯƒ2\text{EPE}(x_0) = \mathbb{E}\left[(f(x_0) - \hat{f}(x_0))^2\right] + \sigma^2

Step 2: Decompose the mean squared error term.

Now add and subtract ฮผ:=E[f^(x0)]\mu := \mathbb{E}[\hat{f}(x_0)] inside the square:

E[(f(x0)โˆ’f^(x0))2]=E[(f(x0)โˆ’ฮผ+ฮผโˆ’f^(x0))2]\mathbb{E}\left[(f(x_0) - \hat{f}(x_0))^2\right] = \mathbb{E}\left[(f(x_0) - \mu + \mu - \hat{f}(x_0))^2\right]

Let a=f(x0)โˆ’ฮผa = f(x_0) - \mu (a constant with respect to the expectation) and b=ฮผโˆ’f^(x0)b = \mu - \hat{f}(x_0) (zero-mean random variable since E[b]=0\mathbb{E}[b] = 0):

=E[(a+b)2]=a2+2aโ€‰E[b]+E[b2]=a2+0+E[b2]= \mathbb{E}[(a + b)^2] = a^2 + 2a\,\mathbb{E}[b] + \mathbb{E}[b^2] = a^2 + 0 + \mathbb{E}[b^2]

Substituting back:

=(f(x0)โˆ’E[f^(x0)])2โŸBias2+E[(f^(x0)โˆ’E[f^(x0)])2]โŸVar(f^(x0))= \underbrace{(f(x_0) - \mathbb{E}[\hat{f}(x_0)])^2}_{\text{Bias}^2} + \underbrace{\mathbb{E}\left[(\hat{f}(x_0) - \mathbb{E}[\hat{f}(x_0)])^2\right]}_{\text{Var}(\hat{f}(x_0))}

Step 3: Collect everything.

EPE(x0)=ฯƒ2+Bias2(f^(x0))+Var(f^(x0))\boxed{\text{EPE}(x_0) = \sigma^2 + \text{Bias}^2(\hat{f}(x_0)) + \text{Var}(\hat{f}(x_0))}


Why can't we minimize all three simultaneously?

  • ฯƒ2\sigma^2 is irreducible โ€” no model can remove measurement noise.
  • Bias decreases as model complexity increases (e.g., high-degree polynomial fits the training signal closely).
  • Variance increases as model complexity increases (a high-degree polynomial is very sensitive to which exact training points were drawn).

Concrete example โ€” polynomial regression:

| Model | Bias | Variance | |-------|------|----------| | Constant fit (f^=yห‰\hat{f} = \bar{y}) | High | Very low | | Degree-nn polynomial (interpolates all data) | ~0 | Huge | | Degree-2 fit for truly quadratic ff | 0 | Moderate |

As you increase the degree beyond the true complexity, bias keeps dropping toward zero but variance explodes. The optimal model lives at the sweet spot where ddฮป[Bias2+Var]=0\frac{d}{d\lambda}[\text{Bias}^2 + \text{Var}] = 0. This is the fundamental reason regularization (ridge, LASSO) and cross-validation exist: they deliberately introduce a little bias to dramatically cut variance, reducing total EPE.

The punchline: The decomposition is exact and additive โ€” there is no "free lunch." Any change to the model that reduces bias must work against reducing variance, making the tradeoff a mathematical inevitability, not just a heuristic.

Source: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, 2nd ed., Section 2.9 / 7.3

Type: ML/StatsSource: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, 2nd ed., Section 2.9 / 7.3Edit on GitHub โ†—