Trees, Bagging and Boosting
Impurity and greedy splitting, the exact variance algebra behind bagging, and boosting derived as functional gradient descent.
Trees and impurity
A decision tree partitions by recursive axis-aligned splits and predicts a constant in each leaf. Growing it optimally is NP-hard, so the standard algorithm is greedy: at each node choose the split maximising the decrease in an impurity measure.
For a node with class distribution :
Let be concave on the probability simplex. A split of a node into children with weights and distributions satisfying has
with equality iff is affine along the segment . Entropy and Gini are strictly concave; misclassification error is concave but piecewise affine.
Key idea
This is why entropy and Gini are used and misclassification error is not, despite being the quantity we actually care about: because is piecewise affine, many splits have exactly zero gain under it, and the greedy algorithm has no signal to follow. A strictly concave surrogate always prefers a split that makes the children purer, even when it does not change the majority class in either. The choice of surrogate is driven by the optimisation, not by the statistics — the same pattern as the hinge and logistic losses standing in for the zero-one loss.
Bagging and random forests
Let be predictors each with variance and pairwise correlation at a fixed input. The average has
Key idea
The limit is , not . Averaging removes only the independent part of the variance; the correlated part survives no matter how many trees you grow. So after a few hundred trees, further averaging is wasted, and the only way to improve is to reduce .
That single observation is the entire design of random forests: in addition to bootstrap resampling (which decorrelates through the data), split on a random subset of features at each node (which decorrelates through the algorithm). The cost is an increase in — each tree is worse — and the trade is favourable because the term dominates for large . Breiman's of for classification is a tuning of exactly this trade.
AdaBoost
- Initialise weights .
- For :
- fit a weak classifier minimising the weighted error ;
- set ;
- reweight and renormalise.
- Output , classified by .
Consider minimising
over additive models . Then at each round, the minimising to first order in is the minimiser of the weighted error with weights , and the exact minimising step size is .
Key idea
AdaBoost was invented from a learning-theoretic question ("can weak learners be combined into a strong one?") and only later recognised as coordinate descent on the exponential loss. The recognition is what generalised it: once you know the algorithm is minimising a loss by greedy stagewise fitting, you can swap the loss, and gradient boosting is what you get.
If each weak learner satisfies for some , then the training error of satisfies
Gradient boosting
Let be differentiable in and consider minimising over in the span of a base class . Regard the objective as a function of the vector ; its negative gradient has components
Fitting by least squares to and taking is a projected gradient step in this -dimensional space, with the learning rate.
Reading the residuals for common losses:
| Loss | Negative gradient |
|---|---|
| — the ordinary residual | |
| — residual weighted by uncertainty | |
| — recovers AdaBoost | |
| — robust, ignores outlier magnitude |
Empirical observation — a regularity seen in experiments. No theorem on this page establishes it in general.
Boosted ensembles often continue to improve on test data long after the training error has reached zero, and adding hundreds more rounds frequently does not hurt.
What this does not say
The training-error theorem above says nothing about test error, and a naive capacity argument would predict severe overfitting: rounds of trees is a large hypothesis class. The partial explanation is margin theory: Schapire and co-authors showed that boosting continues to increase the margin distribution after the training error hits zero, and there are margin-based generalisation bounds analogous to the SVM margin bound that are independent of .
This is a genuine explanation but not a complete one: the margin bounds are numerically loose, there are constructed examples where a larger minimum margin gives worse generalisation, and boosting with a very flexible base learner and noisy labels does overfit. The practical rules — shrinkage , shallow trees, early stopping on a validation set — are empirical, and gradient boosting remains the strongest method on tabular data for reasons that are not fully characterised.
Problems
Concave impurity gives non-negative information gainProof · Intermediate · 30 min The bagging variance formulaProof · Intermediate · 30 min AdaBoost as exact line search on the exponential lossProof · Advanced · 30 min AdaBoost drives training error to zero exponentiallyProof · Advanced · 1 hour Gradient boosting fits the negative functional gradientProof · Intermediate · 30 minReferences
- PaperLeo Breiman (1996). Bagging Predictors
- PaperLeo Breiman (2001). Random Forests
- PaperYoav Freund and Robert E. Schapire (1997). A Decision-Theoretic Generalization of On-Line Learning and an Application to Boosting
- PaperJerome H. Friedman (2001). Greedy Function Approximation: A Gradient Boosting Machine
- PaperTianqi Chen and Carlos Guestrin (2016). XGBoost: A Scalable Tree Boosting System
These works are cited as sources to read, not reproduced. All exposition, examples and problems on this site are written independently; where an argument is standard, the citation points to a canonical treatment.
Results stated on this page
- PropositionAny concave impurity gives non-negative information gainproof includedA split can never increase a concave impurity measure in expectation, which is what makes greedy splitting well posed.
- PropositionBagging variance algebraproof includedAveraging B correlated predictors leaves the correlated part of the variance untouched, which is exactly what feature subsampling attacks.
- TheoremAdaBoost is coordinate descent on the exponential lossproof includedThe AdaBoost weights and coefficients are exactly the exact line search and greedy coordinate choice for the exponential loss.
- TheoremAdaBoost drives training error to zero exponentiallyproof includedIf every weak learner beats chance by a fixed margin the training error decays geometrically in the number of rounds.
- PropositionGradient boosting is gradient descent in function spaceproof includedEach round fits a base learner to the negative functional gradient of the loss at the current model.
- Empirical observationBoosting resists overfitting longer than the training error suggestsTest error often keeps improving after training error reaches zero, which margin theory partially explains.
Problems (5)
All problems- AdaBoost drives training error to zero exponentiallyProofAdvanced⏱ 1 hour
- AdaBoost as exact line search on the exponential lossProofAdvanced⏱ 30 min
- The bagging variance formulaProofIntermediate⏱ 30 min
- Gradient boosting fits the negative functional gradientProofIntermediate⏱ 30 min
- Concave impurity gives non-negative information gainProofIntermediate⏱ 30 min