Gradient Boosting
Derivation of boosting as functional gradient descent in function space: the additive model framework, residual fitting, gradient boosting for arbitrary differentiable losses, shrinkage, subsampling, and the XGBoost second-order formulation.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- Additive Models and Forward Stagewise Fitting
- Boosting as Functional Gradient Descent
- The Gradient Boosting Algorithm
- Gradient Boosting for Regression (Squared Loss)
- Gradient Boosting for Classification (Log-Loss)
- Regularization Techniques
- XGBoost: Second-Order Formulation
- Common Pitfalls
- Research Perspective
- Summary
- Exercises
Learning Objectives
- Formalize boosting as sequential minimization in function space.
- Derive the gradient boosting update as functional gradient descent.
- Show that for squared loss, gradient boosting fits residuals.
- Derive the XGBoost objective with second-order approximation.
- Explain the roles of shrinkage, subsampling, and tree depth in regularization.
- Compare the bias-reduction mechanism of boosting vs. the variance-reduction of bagging.
Notation
- — additive ensemble
- — -th base learner (weak learner, typically a shallow tree)
- — learning rate (shrinkage)
- — loss function
- — pseudo-residuals
- — first and second derivatives of loss (XGBoost notation)
Core Intuition
While bagging reduces variance by averaging independent models, boosting reduces bias by sequentially correcting errors. Each new weak learner is fit to the mistakes (pseudo-residuals) of the current ensemble. The ensemble builds up a powerful predictor from many simple models, each contributing a small correction.
Gradient Boosting
Additive Models and Forward Stagewise Fitting
The ensemble model is additive:
where is a constant initialization (e.g., the mean of ) and each is a shallow tree.
Forward stagewise fitting: At step , fix all previous terms and optimize only :
Boosting as Functional Gradient Descent
View as a point in function space. The loss functional is . The functional gradient at data points is:
We cannot step directly in this infinite-dimensional direction, so we fit a base learner to approximate the negative gradient:
where are the pseudo-residuals.
The Gradient Boosting Algorithm
- Initialize: .
- For :
- Compute pseudo-residuals: .
- Fit base learner: .
- Update: .
- Output: .
Gradient Boosting for Regression (Squared Loss)
For :
The pseudo-residuals are literally the residuals. Each tree fits the errors of the previous ensemble.
Gradient Boosting for Classification (Log-Loss)
For binary classification with where :
Points that are currently misclassified (large negative ) get pseudo-residuals close to (high weight). Correctly classified points get small pseudo-residuals.
Regularization Techniques
Shrinkage (learning rate ). Using scales each tree's contribution:
Smaller requires more trees but generalizes better (analogous to smaller step size in optimization).
Subsampling (stochastic gradient boosting). Each tree is fit on a random fraction of the training data. Introduces randomness similar to SGD.
Tree constraints: Limit depth (typically 3–8), minimum leaf size, and maximum leaves.
L2 regularization on leaf weights (in XGBoost): penalizes large predictions in individual leaves.
XGBoost: Second-Order Formulation
XGBoost uses a second-order Taylor approximation of the loss at step :
where , , and penalizes tree complexity ( = number of leaves, = leaf weight).
Optimal leaf weight for leaf (containing indices ):
Optimal objective value (used for split scoring):
Split gain: The reduction in objective from splitting leaf into :
Common Pitfalls
Pitfall 1. Overfitting with too many trees and high learning rate. Unlike random forests, gradient boosting can overfit as increases. Use early stopping based on validation loss.
Pitfall 2. Ignoring feature scale. While trees are scale-invariant, the pseudo-residuals and learning rate interact with the loss scale. Standardization is less critical than for linear models but still relevant for convergence speed.
Pitfall 3. Confusing bagging (reduces variance) with boosting (reduces bias). They attack different components of generalization error.
Research Perspective
Boosting was introduced by Schapire (1990) and Freund & Schapire (1995, AdaBoost). Friedman (2001) unified boosting as gradient descent in function space. XGBoost (Chen & Guestrin, 2016) added second-order optimization and systems-level efficiency, becoming the dominant method for tabular data. LightGBM (Ke et al., 2017) and CatBoost (Prokhorenkova et al., 2018) further improved scalability and handling of categorical features.
Summary
- Gradient boosting builds additive models by sequentially fitting pseudo-residuals.
- It is functional gradient descent: each tree approximates the negative gradient of the loss.
- For squared loss, pseudo-residuals = actual residuals; for log-loss, they weight hard examples.
- Shrinkage and subsampling prevent overfitting; early stopping is essential.
- XGBoost uses a second-order Taylor expansion for optimal leaf weights and split scoring.
- Boosting reduces bias (contrast with bagging which reduces variance).
Exercises
Exercise 1. Derive the pseudo-residuals for Huber loss .
Exercise 2. Show that AdaBoost is equivalent to forward stagewise fitting with exponential loss .
Exercise 3. Derive the optimal leaf weights (equation 9) by setting the derivative of the XGBoost objective to zero.
Exercise 4. Prove that gradient boosting with squared loss and depth-1 trees (stumps) is equivalent to fitting residuals with a single-split regressor.
Exercise 5. Explain mathematically why early stopping in gradient boosting acts as regularization (relate to the number of gradient descent steps).