The Gradient Boosting Secret: Why Each Tree Fits Residuals
You are building a regression model with squared error loss .
Gradient boosting works by starting with an initial model and then iteratively adding new trees :
At each step , gradient boosting fits the new tree to the negative gradient of the loss evaluated at the current prediction .
Show that for squared error loss, the negative gradient at observation is exactly the residual .
Then explain: why is this a surprising and powerful idea? In particular, what does it reveal about gradient boosting as a general framework?
(Hint: think about what happens when you replace squared error with, say, absolute error or log-loss โ can you still "fit residuals"?)
Answer: Gradient Boosting Secret: Why Each Tree Fits Residuals
Key Idea / Intuition
For squared error loss, the negative gradient with respect to the current prediction is literally the residual โ so fitting trees to "pseudo-residuals" (negative gradients) is just fitting trees to actual residuals. The surprise is that this residual-fitting story generalizes: for any differentiable loss, we can define "pseudo-residuals" as negative gradients and run the same algorithm. This turns boosting from an ad hoc trick into a gradient descent in function space.
Formal Proof / Solution
Step 1: Compute the Negative Gradient
Define the pointwise loss at observation as a function of the current model output :
The negative gradient with respect to is:
So the pseudo-residual equals the true residual.
Step 2: Why Is This Surprising?
The naive story: "boosting fits trees to residuals because residuals capture what the current model missed." This sounds like a clever but specific trick.
The deeper story: gradient boosting is gradient descent, but in function space.
In ordinary gradient descent on parameters , we update:
In gradient boosting, the "parameter" is the function itself, living in an infinite-dimensional space. We can't move in the direction of directly (that would require adding an arbitrary function), so we project the negative gradient onto the space of trees by fitting a tree to it.
The pseudo-residuals for other losses:
| Loss | | Pseudo-residual | |---|---|---| | Squared error | | True residual | | Absolute error | | (direction only) | | Log-loss (classification) | | Residual in probability |
For absolute error, the pseudo-residuals are signs โ this gives a boosting algorithm robust to outliers (since large residuals don't dominate). For log-loss, pseudo-residuals are , connecting gradient boosting to logistic regression.
Step 3: The Unifying Framework
Total loss:
At step , define pseudo-residuals:
Fit a regression tree to , then update:
This is Friedman's gradient boosting machine (2001). The key insight: once you recognize boosting as gradient descent, you can "boost" with any differentiable loss function โ the algorithm structure is identical, only the pseudo-residuals change.
This reveals that residual fitting is not the cause of boosting's success; it is a special case of a much more general principle.
Source: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman (2nd ed.), Chapter 10