Deriving bias-variance decomposition and explaining tradeoff
The expected squared prediction error breaks down into irreducible error (noise), squared bias, and variance:
E[(f̂(x) - Y)^2] = [Bias(f̂(x))]^2 + Var(f̂(x)) + σ². This follows from expanding the error using Y = f(x) + ε and zero-mean noise ε independent of the estimator. As model complexity rises, bias decreases because the model fits the true function better, but variance increases due to sensitivity to training data. The optimal complexity lies where the sum of squared bias and variance (plus constant noise) is minimized, typically found via validation methods.
A convenient way to see where the different contributions to prediction error come from is to fix a test point (x), write down the squared loss at that point and take expectations over all the sources of randomness.
Assume there is a fixed but unknown regression function (f(x)) and that the observed responses are
[
Y = f(X) + \varepsilon,
]
with (\mathbb{E}[\varepsilon\mid X]=0) and (\operatorname{Var}(\varepsilon\mid X)=\sigma^2). Let (\hat f) denote the function returned by some learning algorithm when trained on a random training sample. Consider the squared prediction error at (x),
[
\bigl(\hat f(x) - Y\bigr)^2 = \bigl(\hat f(x) - f(x) - \varepsilon\bigr)^2.
]
Taking the expectation over the randomness in the training sample and the test noise, and using that (\varepsilon) is independent of (\hat f) and has zero mean, gives
[
\mathbb{E}\bigl[(\hat f(x) - Y)^2\bigr]
= \mathbb{E}\bigl[(\hat f(x) - f(x))^2\bigr] + \sigma^2.
]
The first term can be further decomposed by adding and subtracting (\mathbb{E}[\hat f(x)]) inside the square:
[
\mathbb{E}\bigl[(\hat f(x) - f(x))^2\bigr]
= \mathbb{E}\bigl[(\hat f(x) - \mathbb{E}[\hat f(x)] + \mathbb{E}[\hat f(x)] - f(x))^2\bigr]
= \underbrace{\mathbb{V}!ar[\hat f(x)]}{\text{variance}} + \underbrace{\bigl(\mathbb{E}[\hat f(x)]-f(x)\bigr)^2}{\text{squared bias}}.
]
Putting these pieces together yields the familiar bias–variance decomposition at (x):
[
\mathbb{E}\bigl[(\hat f(x) - Y)^2\bigr] = \sigma^2 ;+; \bigl(\mathbb{E}[\hat f(x)]-f(x)\bigr)^2 ;+; \mathbb{V}!ar[\hat f(x)].
]
Averaging over the distribution of (X) gives the same decomposition for the expected generalisation error.
The “trade‑off” language comes from how the bias and variance terms behave as you vary the flexibility of the model class. A very simple model (e.g. a linear function for a highly nonlinear (f)) cannot represent the true relationship, so (\mathbb{E}[\hat f(x)]) is far from (f(x)): high bias. On the other hand, because there are few parameters to estimate, (\hat f) doesn’t change much from one training sample to the next: low variance. A very flexible model can approximate many functions, so its bias is small, but it can fit idiosyncrasies of the training sample, leading to large variability in (\hat f) and thus high variance. The irreducible noise term (\sigma^2) is fixed by the data-generating process.
The optimal complexity is at the “sweet spot” where the sum of squared bias and variance is minimised. You cannot reduce (\sigma^2), so you choose a model rich enough to keep bias down but not so rich that variance dominates. In practice this optimal point is found by evaluating the total error on held‑out data or via cross–validation and selecting the model complexity that minimises the estimated test error.