Many weak models, added up
Gradient boosting builds a strong model as a sum of weak ones. It starts from a constant, then adds one small regression tree per round, each trained on what the model so far still gets wrong. No single tree is good, but together they can fit almost anything, which is also their danger.
This page boosts on scikit-learn's diabetes data: 442 patients, ten baseline measurements, and as the target a measure of disease progression one year later (331 patients to fit, 111 held out). The main runs use a single feature, body mass index, so that every tree is a step function of one number and everything the method does can be drawn on a plane.
Residuals are the gradient
With squared loss , the derivative of the loss with respect to the model's prediction is . Its negative, the residual , is the direction in which each prediction should move. Boosting is gradient descent in the space of functions: at round it fits a tree to the residuals and steps along it,
where is the learning rate, or shrinkage. Here is the mean progression, 151.9, and the training loss before any tree is 6,253. The What tree m is fitted to panel shows the residuals at every round with the new tree drawn as dark steps, and the thin steps are times that tree, what the round actually adds. Other losses give other gradients, for example for classification with log loss, but the loop is the same.
One tree, a few coarse statements
Each tree here has depth 2, so at most four leaves. It is grown greedily: at each node scikit-learn tries every threshold between neighbouring feature values and keeps the one with the largest Friedman improvement , the split that best separates high residuals from low ones. A leaf then predicts the mean residual of its patients. The first tree splits BMI at 27.75 and then at 25.65 and 33.15; its leaves say "−42.8 for the 171 leanest patients, +115 for the 24 heaviest". The Tree m panel draws every round's tree with these numbers, and the colours of the residuals show which leaf each patient falls in.
Shrinkage and when to stop
With each round closes only a tenth of the gap a tree finds, so the ensemble creeps towards the data and later trees can correct earlier ones. Test loss falls from 4,965 to its lowest, 3,981, at round 9; after that the trees chase individual patients, training loss keeps falling (2,545 after 200 rounds) and test loss climbs back to 4,871. With the first tree is taken whole: test loss is best at round 2 (4,417) and ends at 6,759. The Train and test loss chart shows both runs; the gap between their curves is overfitting, round by round.
Body mass index alone cannot say much about progression, so the useful part is learned quickly. With all ten features the picture is the same but stretched: depth-3 trees at are best at round 13 (test loss 3,522) and end with a training loss of 35, almost memorizing the 331 patients; needs 156 rounds to reach 3,488; and stumps, depth-1 trees that each look at one feature, do best of all here, 3,337 at round 41: a sum of one-feature steps is an additive model, which has less room to fit noise. Friedman's stochastic variant, which fits each tree on a random half of the patients, reaches 3,432 at round 12. Measured by how much their splits lower the loss, log triglycerides (36 %) and BMI (24 %) matter most, yet the later trees split on every feature in turn, chasing whatever residual is left.
Where it came from
Boosting began as a question in learning theory: can weak learners that are only slightly better than chance be combined into a strong one? AdaBoost (Freund and Schapire) answered yes by reweighting the examples each round. Friedman then recast boosting as gradient descent on any differentiable loss, with trees as the steps and shrinkage as the step size, which is the algorithm on this page and the core of XGBoost and LightGBM. A ResNet block has the same shape: each block adds a correction to what the layers before it computed.
Papers
- Greedy function approximation: A gradient boosting machine Gradient boosting: fit each tree to the negative gradient of the loss, shrink it, add it; the residuals of squared loss and the split criterion scikit-learn uses.
- Stochastic gradient boosting Fitting each tree on a random subsample, the subsample 0.5 run on this page.
- A Decision-Theoretic Generalization of On-Line Learning and an Application to Boosting AdaBoost, the first practical boosting algorithm, which reweights examples instead of fitting residuals.
- XGBoost: A Scalable Tree Boosting System Second-order gradient boosting with regularized trees, the form most used in practice.
- Least angle regression The diabetes data this page fits, introduced as the running example of the paper.