KatInterview

Decompose Prediction Error into Bias and Variance

Statistics & ExperimentsModel answer
MediumModel answerStatistics & Experimentsstatisticsbias-variance tradeoffmodel evaluation

Last updated

Derive the bias-variance decomposition of MSE from first principles and apply it to diagnose a concrete model comparison scenario.

Setting

A team is building a model to predict daily energy consumption (in kWh) for residential buildings. Two candidate models are evaluated on the same held-out test set:

ModelAvg. Squared Error on Test SetNotes
A42Simple linear regression, 3 features
B38Degree-5 polynomial regression, 20 features

A teammate argues: "Model B has lower test error, so we should always prefer it."

A senior colleague pushes back: "That single number doesn't tell the whole story."

What You Are Expected To Do

  1. Derive the bias-variance decomposition of the expected mean squared error (MSE) of a predictor from first principles. Define every term clearly.

  2. Explain what each component (bias, variance, irreducible noise) represents intuitively, and sketch how they each change as model complexity increases.

  3. Identify at least two concrete scenarios in which Model B's lower test-set MSE would not justify choosing it over Model A.

  4. Propose a practical diagnostic procedure — using tools available to a working data scientist — to estimate whether a given model is suffering more from high bias or high variance.

  5. Answer: if you could only run one additional experiment to decide between the two models, what would it be and why?

Hints

Hint 1

Start the derivation by adding and subtracting E[f̂(x)] inside the squared error term, then expand — this is the key algebraic trick.

Hint 2

For the scenarios where lower test error is misleading, think about dataset size, distribution shift, and the cost of complexity in production.

Hint 3

The learning curve (training error vs. validation error as a function of training set size) is one of the most informative single diagnostics for bias vs. variance.