
Gradient Boosting With Residuals
Gradient boosting builds a prediction step by step, each shallow tree fitting the errors left by the last. A worked example shows how shrinkage controls each small update.
来源
完整课程摘要
Start with a single number for every house, the mean sale price in your training set. If that mean is 200 thousand dollars, a 90 square metre house that actually sold for 260 has a residual of 60. The residual is the gap between the observed target and the current prediction. For squared-error loss, that residual is also the negative gradient of the loss with respect to the prediction, up to a conventional factor of two. Fitting a model to residuals is therefore a gradient step in function space.
Fit a shallow regression tree, perhaps depth two, to all the residuals rather than to the prices. This tree might learn that larger homes tend to have positive residuals and predict 40 for our 90 square metre house. With a learning rate of 0.1, the update is 0.1 times 40, or 4. The new prediction becomes 204. The same tree adds a negative adjustment where residuals were negative, so a 50 square metre house with a residual of minus 30 might receive an update of 0.1 times minus 25, or minus 2.5, lowering its prediction to 197.5. Notice the tree never sees 260 directly, only the 60 it must explain.
Shrinkage keeps each step modest, so many small trees can combine into a flexible curve without any single tree dominating. After the first update, the 90 square metre house still has a residual of 56, so the next tree has fresh work to do. Repeating this over dozens or hundreds of rounds slowly closes the gap. If you set the learning rate to 0.1 and run twenty rounds, each contribution is reduced, although the sequence may move upward or downward, and each tree contributes a fraction of its fitted value.
Contrast this with fitting many independent trees to the prices and averaging them. Each independent tree sees the full target and they combine in parallel, like a committee voting at once. The sequence matters. Tree two is fitted to what tree one and the mean left unexplained, tree three to what remains after that, and so on. The trees are deliberately weak and dependent on their predecessors.
The neat statement that residuals equal negative gradients holds for squared-error regression. With other losses, such as absolute error, the quantity fitted is a different gradient, and the simple residual arithmetic no longer applies. Also, a very small learning rate needs more trees to travel the same distance, while a large one can overshoot. Shrinkage controls pace, not a guarantee of accuracy.
In class, give pairs a small table of areas and prices and ask them to compute the mean, then residuals, then fit a one-split stump by hand. Have them apply a learning rate of 0.1 and write the new predictions beside the old. Ask each pair to explain in one sentence why their second tree used residuals instead of prices. Post the sentences and compare wording. The visible arithmetic and the written explanations show whether students see boosting as a sequence of corrections rather than a crowd of independent opinions.


