KatInterview

Bias-Variance Decomposition: Concepts, Math, and Model Choices

Machine LearningModel answer
MediumModel answerMachine Learningbias-variance tradeoffregularizationoverfitting

Last updated

Derive the bias-variance-noise decomposition of MSE, and explain how polynomial degree, dataset size, and L2 regularization shift each term.

The Decomposition of Prediction Error

When you evaluate a regression model's expected test error at a point x, the mean squared error can be split into three separate, non-negative terms: one that captures systematic error from model assumptions, one that captures sensitivity to which training sample you happened to draw, and one that no model can ever remove.

Answer all three parts below.


Part 1 — Definitions

Give precise conceptual definitions of bias and variance in predictive modeling. Make clear:

  • What each term measures
  • What causes each one to be large or small
  • How they relate to the underlying true function versus the observed targets

Part 2 — Polynomial Degree on a Small Dataset

You have n = 15 training points drawn from a smooth nonlinear function. You fit polynomial regression models of increasing degree (1, 2, 3, … up to 14).

Describe what happens to bias and variance as degree increases. Explain:

  • Why does bias decrease?
  • Why does variance increase?
  • What shape does the test error curve take, and why does training error not reflect this?

Part 3 — Effect of More Training Data and Regularization

Using the mathematical decomposition

E[(y - f_hat(x))^2] = Bias(f_hat(x))^2 + Var(f_hat(x)) + sigma^2

explain:

  1. Which terms are affected when you increase the size of the training set, and which are not — and why.
  2. How L2 (ridge) regularization shifts the balance between bias and variance, and why this can still lower total test error relative to the unregularized model.

Reference notation:

  • f_hat(x): the model fitted on one training set
  • f(x): the true underlying function
  • y = f(x) + epsilon: the observed target, where epsilon is zero-mean noise with variance sigma^2
  • The expectation in the decomposition is taken over independently drawn training sets of size n

Hints

Hint 1

For Part 1, ask yourself: if you trained the same algorithm on many independent datasets of the same size, what would the spread of predictions look like versus their average? Bias and variance describe those two separate things.

Hint 2

For Part 2, recall that OLS with p parameters fitted to n points has an average prediction variance proportional to sigma^2 * p/n. Think about what happens to that ratio as degree approaches n.

Hint 3

For Part 3, ridge regression replaces (X^T X)^-1 with (X^T X + lambda*I)^-1. Think about what that shift does to directions in feature space where the data gives weak information — and how that affects each term in the decomposition separately.