CAB212 · Unit 4: Ensemble learning
Bagging and random forests
8 practice questions
Key points
- Bootstrap = sample with replacement
- ~63.2% unique in-bag, ~36.8% OOB
- Random forest adds random feature subsets
- Bagging reduces variance
Ensemble learning combines many models to get better accuracy than one.
Bagging (bootstrap aggregating): train each model on a bootstrap sample (n draws with replacement from n samples), then average (regression) or vote (classification). It mainly reduces variance.
A bootstrap sample contains about 63.2% of the distinct original samples; the remaining ~36.8% are out-of-bag (OOB) and give a free validation estimate. (Probability a sample is never picked = (1 - 1/n)^n, which tends to 1/e = 0.368.)
Random forest = bagging of decision trees plus random feature subsets at each split (commonly sqrt(d) features for classification). This decorrelates trees, so averaging reduces variance further. Trees are grown deep, unpruned.
Strengths: strong default accuracy, handles mixed features, gives feature importance. Weaknesses: less interpretable, larger and slower than one tree.
Exam pitfall: bagging reduces variance; it does not reduce bias much.
Try two questions
A typical number of features considered per split in a random forest classifier with d features is:
- Always all d features at every split
- Always exactly one feature at every split
- About sqrt(d)
- d squared features at every split
Show the answer
C. A common default.
Bagging mainly reduces:
- Bias
- Number of features
- Variance
- Dataset size
Show the answer
C. Averaging many high-variance models stabilises predictions.