Bias-Variance Tradeoff Explained With a Shrunken Mean
The bias-variance tradeoff says a model's expected test error at a point splits into three parts: variance, squared bias, and irreducible noise. In words, variance is how much the fit changes between training sets, bias is how far its average prediction sits from the truth, and noise is what nobody can predict. James, Witten, Hastie, and Tibshirani write it as E(y₀ − f̂(x₀))² = Var(f̂(x₀)) + [Bias(f̂(x₀))]² + Var(ε) (their Equation 2.7). They explain variance as "the amount by which f̂ would change if we estimated it using a different training data set." More flexible methods tend to have higher variance and lower bias, so the expected test error traces a U shape as flexibility grows.
Two remarks from the same passage matter. Variance and squared bias are both nonnegative, so the expected test error "can never lie below Var(ε), the irreducible error." And the goal is a method that "simultaneously achieves low variance and low bias," which is why you cannot simply drive one to zero.
Try it by hand. Make the simplest possible model: estimate a single number. The true mean is θ = 2. You see 4 noisy observations, and the noises are independent, mean zero, each with variance 16, so the sample mean has variance 16/4 = 4. A new outcome y₀ has fresh noise, independent of those four, with the same mean zero and variance 16. Your prediction is the shrunken sample mean θ̂ = c × (sample mean). Then the three pieces are Var(ε) = 16, squared bias (c − 1)² × 2² = 4(c − 1)², and variance c² × 4. So the expected test error is 16 + 4(c − 1)² + 4c². With no shrinkage, c = 1, it is 16 + 0 + 4 = 20, all of the excess being variance. With c = 0, always predicting zero, it is 16 + 4 + 0 = 20, all of the excess being bias. With c = 0.5 it is 16 + 1 + 1 = 18. At c = 0.25 and c = 0.75 it is 18.5. That is the U shape. The best c here is 0.5, where the error is 18, and no choice can go below the irreducible 16. I confirmed the formula by simulation: 400,000 trials per value of c reproduced 20, 18.5, 18, 18.5 and 20 to within 0.03.
The estimate with a little bias won because shrinking cut the variance by more than the added squared bias. Shrinking is bias on purpose. Regularization methods such as ridge regression do the same kind of thing.
The trap: thinking an unbiased method is automatically the best. At c = 1 the sample mean has zero bias and a worse test error than the shrunken one.
Prof Rod's rule: when a fit disappoints, ask whether the error is bias, variance, or noise, because the fix is different for each.
The example's numbers are invented, and the algebra and the simulation both use them.