How do you derive the bias–variance decomposition of the expected squared error E[(y−f^(x))2], where f^ is the model fitted to a random training set?

Foundations, Bias and variance
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can do the add-and-subtract trick cleanly, and be precise about which expectations are over the training set and which are over the noise.

Key idea

Assume y=f(x)+ε, where f is the true function and ε is noise with E[ε∣x]=0 and Var⁡(ε∣x)=σ2, drawn fresh at test time and so independent of the training set. Add and subtract the average prediction fˉ(x)=ED[f^(x)], where ED averages over training sets D. The cross terms vanish because ε is independent of D and f^(x)−fˉ(x) has mean zero.

Steps

  1. Fix a test point x. State the model y=f(x)+ε, and note that f^ depends on the random training set D.
  2. Write y−f^=(f−fˉ)+(fˉ−f^)+ε. Adding and subtracting fˉ splits the error into pieces that are easy to average.
  3. Square, then take expectations over D and ε. Show that each cross term is zero.
  4. Arrive at E[(y−f^(x))2]=(f(x)−fˉ(x))2+ED[(f^(x)−fˉ(x))2]+σ2, that is, bias² + variance + noise.
  5. Interpret each term. Note that averaging over x gives the overall test MSE (mean squared error).

Common mistakes

How long your answer should be

A half-page derivation; about 5 minutes at a whiteboard.

Read this

Previous in Foundations: Cross-validation for polynomial regression of degree 1 to 6 gives these mean errors (standard error in brackets): degree 1: 0.300 (0.030); degree 2: 0.180 (0.020); degree 3: 0.115 (0.020); degree 4: 0.100 (0.020); degree 5: 0.095 (0.025); degree 6: 0.110 (0.030). Which degree does the one-standard-error rule choose, and why prefer it to the plain minimum?
Next in Foundations: For a single weight w and a number z, solve min⁡w12(w−z)2+λ∣w∣ and min⁡w12(w−z)2+λ2w2. Why does this show that L1 regularisation gives sparse solutions and L2 does not?