Before you readYour first model predicts too high for some rows and too low for others. Could a second model learn just the correction?
Watch: Gradient Boost Part 1: Regression Main Ideas · StatQuest with Josh Starmer
Bagging trains trees separately. Boosting trains them in sequence: each new tree tries to improve the prediction made by the trees already fitted. The final model adds their contributions.
For gradient boosting with squared error, start with F0, the mean target. At round m, calculate the residual ri=yi−Fm−1(xi) for each training row. Fit a small regression tree hm to those residuals, not to the original targets. Then update:
Fm(x)=Fm−1(x)+ηhm(x).
The learning rateη controls how much of the correction to use. A positive residual means the prediction is too low; a negative one means it’s too high.
Start at the mean: 6Predictions: 6, 6, 6, 6
The dots are targets: 2, 4, 8, 10. The pink line predicts them; dashed gaps are the residuals. At each round, a one-split tree fits the previous gaps and the model adds half its prediction on each side.
With squared error, fitting a correction means fitting residuals. For a different loss, gradient boosting instead fits that loss’s negative gradients with respect to the current predictions. Another method, AdaBoost, gives misclassified rows more weight in the next round and combines classifiers with a weighted vote. Both build on what the previous rounds got wrong.
Recall
What does the next tree fit in gradient boosting with squared error?
Recall
Why can't you fit boosting's trees separately like bagging's?
Exercise
A model predicts 8 for a row with target 5. What is its residual? If the next tree predicts −2 for that row and η=0.5, what is the updated prediction? Give both numbers in order.
Exercise
Two rows fall in the same leaf of a tree fitted to residuals −4 and 2. With squared error and η=0.5, how much does the ensemble add to each row's prediction?