Statistics · medium

Explain the bias-variance tradeoff.

Asked in ML Engineer interviews, in the Statistics round.

Short answer

Bias is underfitting error, variance is overfitting error, and the goal is the lowest total generalization error.

Bias, variance and total error against model complexity Error Simple Sweet spot Complex Bias² Variance Total error
Total error is the sum of the two, so the best model sits in the middle.

How to answer it

Definition

Prediction error splits into three pieces: bias, variance and irreducible noise. Bias is error from a model too simple to capture the pattern; variance is error from a model so flexible it fits the noise in the training sample. The chart above shows the sum.

Formula

Expected error  =  bias^2  +  variance  +  irreducible noise

Only the first two are yours to trade. The third is a property of the problem.

What each looks like

High bias, low variance     underfitting
  train error high, test error high, and the two are close
  example: a straight line through a curve

Low bias, high variance     overfitting
  train error very low, test error much higher
  example: a deep tree that memorised the training set

The gap between training and test error is the practical read on variance. A model that is excellent in training and mediocre in test has a variance problem, not a bias one.

Moving along the curve

Ensembles are worth naming because they attack different terms. Bagging and random forests average many high-variance models to cut variance. Boosting builds sequentially on the errors of the last model to cut bias.

Key points

FAQ

The 30-second answer

Prediction error breaks into bias, variance and irreducible noise. Bias is error from a model too simple to capture the real pattern, so it underfits. Variance is error from a model so flexible it fits the noise in the particular sample it trained on, so it overfits. Total error is the sum, which makes it U-shaped in complexity, and the best model sits in the middle.
In practice I read it off the gap between training and test error. A large gap means variance, so I would add data, regularise, or simplify. Both errors high and close together means bias, so I would use a richer model or better features.
It is also why regularisation works: it deliberately adds a little bias to remove more variance than it adds.

In the interview

Practice this for real