Boosting: AdaBoost & Gradient Boosting, In Full Depth
Random Forest builds many trees independently and in parallel, then averages them to reduce variance. Boosting builds trees sequentially, where each new tree is trained specifically to fix the previous ensemble's mistakes — trading Random Forest's variance-reduction strategy for a bias-reduction strategy.
Bagging vs. Boosting, Precisely
- Bagging (Random Forest): parallel, independent trees on resampled data, averaged. Reduces variance. Individual trees are usually grown deep (low bias, high variance) since averaging handles the variance.
- Boosting: sequential trees, each correcting the ensemble-so-far's errors. Reduces bias. Individual trees are usually shallow — "weak learners," often just a few splits deep — since the sequential correction process handles building up accuracy over many rounds.
AdaBoost (Adaptive Boosting)
The original boosting algorithm. The core mechanism: reweight the training examples after each round, increasing the weight of examples the ensemble-so-far got wrong, so the next weak learner is forced to focus on exactly those hard cases.
- Start with equal weight on every training example: .
- Train a weak learner (commonly a "stump" — a decision tree of depth 1) on the weighted data.
- Compute the weak learner's weighted error rate , and its voting weight — a learner that does better than random gets a positive (more say in the final vote); a learner near 50% error gets (barely counted).
- Update example weights: increase weight on misclassified examples by a factor of , decrease correctly-classified examples' weight by , then renormalize so weights sum to 1.
- Repeat for rounds. Final prediction: a weighted vote, , across all weak learners.
The intuition, directly from the weight update: examples the ensemble keeps getting wrong accumulate more and more weight round after round, until some weak learner is forced to get them right just to achieve reasonable weighted error — the ensemble's "attention" is adaptively redirected toward its own current weaknesses.
Gradient Boosting: The General Framework
AdaBoost reweights examples. Gradient Boosting generalizes the same "sequentially correct mistakes" idea to work with any differentiable loss function (see Loss Functions), by fitting each new tree to the residual gradient of the loss, not to reweighted labels.
For squared error specifically (regression), the algorithm becomes remarkably intuitive:
- Start with a constant prediction (the mean target).
- Compute the residuals: — exactly the residuals from Linear Regression, just computed against the current ensemble instead of a single linear fit.
- Train a new (shallow) tree to predict these residuals directly.
- Update the ensemble: , where is a small learning rate (shrinking each tree's contribution — see Calculus & Optimization) and is the newly trained tree.
- Repeat for rounds.
Step through a real 5-round fit, on real data — each round a genuine search over every candidate split threshold:
Why "gradient" boosting specifically: for squared-error loss, the residual is exactly the negative gradient of with respect to . Fitting a tree to residuals is, precisely, taking a gradient descent step in function space — instead of updating a fixed set of weights (as in Linear Regression), each round adds an entire new function (tree) that points the whole ensemble further downhill on the loss surface. For other losses (log-loss for classification, etc.), the "residual" generalizes to that loss's actual negative gradient rather than literally .
Key Hyperparameters
- Number of trees (): too few underfits; too many starts overfitting (unlike Random Forest, boosting can overfit by adding more trees, since each one is chasing the training set's remaining errors specifically).
- Learning rate (): smaller values need more trees but generalize better — the classic tradeoff, directly analogous to gradient descent's learning rate.
- Tree depth: kept shallow (often depth 3-8) — deep trees per round tend to overfit fast in a sequential, error-correcting setup.
AdaBoost vs. Gradient Boosting
| AdaBoost | Gradient Boosting | |
|---|---|---|
| Corrects mistakes via | Reweighting examples | Fitting to the loss gradient (residuals) |
| Loss function | Exponential loss (implicitly) | Any differentiable loss — flexible |
| Weak learner | Usually depth-1 stumps | Usually shallow trees (depth 3-8) |
| Sensitive to outliers | Very (outliers get reweighted up repeatedly) | Less, depending on loss choice (e.g. Huber — see Loss Functions) |
Gradient Boosting's flexibility and generally stronger empirical performance are why it — not AdaBoost — became the basis for the modern, dominant implementations: XGBoost, LightGBM & CatBoost.
Minimal Implementation
Gradient boosting for regression, matching the algorithm above exactly:
Next: XGBoost, LightGBM & CatBoost — the production-grade, highly optimized implementations of this exact algorithm that dominate tabular ML today.