Quiz: bagging and random forests
Before this unit: Decision trees (previous unit); Day 2: Edges, blobs and ridges.
See also: Day 12: Thresholding; Day 16: Measurements.
Short questions to test your understanding. Try each on paper first, then open the answer.
Q1. A bootstrap sample of 1000 training points is drawn. About how many distinct points does it contain?
About 37 % are left out.
About 1000 \cdot (1 - 0.368) \approx 632. The sample still has 1000 entries: the missing ones are made up by points drawn two or more times.
Q2. Why does bagging use deep trees rather than stumps?
Which part of the error does averaging reduce?
Averaging reduces the variance but leaves the bias unchanged. Deep trees have low bias and high variance: exactly what averaging fixes. Averaging stumps would give an average of biased, simple models that are all wrong in the same way (that is what boosting addresses, by growing them in sequence).
Q3. Your forest’s OOB error stops improving after 80 trees. You add 400 more. What happens to the error, and to the training and prediction time?
More trees never hurt accuracy.
The error stays about the same (it does not get worse: a forest does not overfit by adding trees). Training and prediction take six times longer.
Q4. What does the random subset of m features per split do that bootstrap samples alone do not?
What does every bagged tree ask first?
With all features available, every bagged tree picks the same strong feature at the root and similar splits below: the trees are highly correlated, so averaging them gains little. A random subset forces other features in, the trees differ more, and the correlation floor \rho\sigma^2 of the average drops.
Q5. 63 of 90 trees vote “mitotic” for a cell. What does the forest report? Is it 70 % sure the cell is mitotic?
Where do vote fractions go wrong?
P(\text{mitotic}) = 63/90 = 0.7, label mitotic. It is a vote share, not a calibrated probability: trees are correlated, and far from the training data they can all agree for no good reason. Use it as a ranking of confidence, and check calibration on held-out data before reading it as “70 % of such cells are mitotic”.
Q6. Why is the out-of-bag error an honest estimate for independent samples, without a separate validation set?
Which trees vote on a training point?
Each training point is predicted only by the trees whose bootstrap sample did not contain it: for those trees it is new data. If the samples are independent, that is like a validation set of the full size (with a forest of about a third of the trees).
Q7. (math) \sigma^2 = 4, \rho = 0.25. What is the variance of the average of 15 such predictors, and the smallest variance reachable with many?
\rho\sigma^2 + (1 - \rho)\sigma^2/B.
0.25 \cdot 4 + 0.75 \cdot 4/15 = 1 + 0.2 = 1.2. The floor is \rho\sigma^2 = 1.
Q8. Bagging or boosting: which grows its trees independently, and which reduces mainly the bias?
Boosting looks at the previous trees’ mistakes.
Bagging (and random forests) grow trees independently, each on its own bootstrap sample, and reduce the variance. Boosting grows shallow trees one after the other, each focusing on what the previous ones got wrong, and reduces mainly the bias.