KatInterview

How Bagging and Boosting Trade Off Bias Against Variance

Machine LearningModel answer
HardModel answerMachine Learningbias-variancerandom-forestgradient-boosting

Last updated

Explain how random forests and gradient boosting reshape the bias-variance decomposition, derive the variance of correlated averages, and say when each ensemble is the better choice.

Ensembles Through the Lens of Error Decomposition

For squared loss, the expected prediction error at a point can be split into squared bias, variance, and irreducible noise. Two popular ensemble families, bagging-style methods and boosting-style methods, attack this decomposition from opposite sides.

Write a clear, structured answer covering the following.

  1. Bagging and Random Forests. Explain why averaging many trees lowers error. Derive the variance of the mean of n identically distributed predictors that each have variance sigma^2 and pairwise correlation rho. Explain what happens to bias and what limits the variance reduction.
  2. Random Forests versus plain bagging. Describe how per-split feature subsampling changes rho, and what it costs in return.
  3. Gradient boosting. Explain how fitting learners sequentially to the current errors (the negative gradient of the loss) shapes bias and variance differently from bagging. Explain why an unregularized booster tends to overfit and which tools control this.
  4. Choosing between them. Under what conditions would you prefer a Random Forest, and under what conditions a gradient boosting machine? Frame your answer in terms of bias, variance, noise level, dataset size, and tuning effort.

Mention how you would diagnose, from training and validation error, which side of the trade-off you are on. Point out common misconceptions where relevant.

Hints

Hint 1

Compute the variance of a sum of n correlated terms: n variance terms plus n(n-1) covariance terms, then divide by n squared. Look at what remains as n grows.

Hint 2

Averaging leaves the expected prediction unchanged, so think about which error component it cannot touch, and what that implies about the kind of base tree you want in a forest.

Hint 3

In boosting, ask what the targets of later trees look like once the real signal is fitted. Then ask which knobs (step size, subsampling, number of rounds, depth) make each correction smaller or less noisy.