Visual explainer
Gradient Boosting
Fit trees to loss-dependent corrections and add their scaled outputs. Work two squared-loss rounds on four observations, then see why constant leaves cannot extrapolate.
Gradient boosting adds trees that correct the current ensemble according to a chosen loss. With half squared loss, the corrections are ordinary residuals: observed target minus current prediction. Our synthetic, unitless training observations are (1,2), (2,4), (3,6), (4,8). Target rings share a feature axis; the starting prediction is the target mean, , shown by the horizontal line. Dashed segments expose the gaps.
Give Corrections a Sign
The target-minus-prediction residuals are −3, −1, +1, +3. Downward bars require a lower prediction, upward bars a higher one. This residual view uses 30 drawing units per residual unit, with zero in the middle; it is a different vertical quantity from the response plot's 25 drawing units per target unit.
For , the negative derivative with respect to prediction is . The gradient boosting formulation fits new trees to loss-dependent negative gradients. This equality with ordinary residuals depends on the loss.
Fit a Residual Tree
Compare midpoint cuts 1.5, 2.5, and 3.5. Cut 2.5 groups residuals [−3,−1] and [1,3], whose means are −2 and +2. The mint step is the fitted tree ; rings are the residual targets, all on the same signed scale. Its squared residual-fit error is , versus 8 at either alternative cut. A tree leaf gives one shared correction, so it does not copy every residual exactly.
Add a Scaled Correction
Return to the original response scale. With learning rate , update . The left leaf moves ; the right moves . Predictions become 4, 4, 6, 6. The arrows move one response unit; the dotted line retains the old prediction. Targets at feature values 2 and 3 now lie on the fit, but the extreme observations still have residuals −2 and +2.
Measure the Training Error
These bars report mean squared error, without the half factor used to define the fitting loss: . The baseline has . After the first update it has .
For the second correction, fit the new residuals [−2,0,0,2]. A cut at 1.5 gives leaf means −2 and 2/3. Adding half yields 3, 13/3, 19/3, 19/3. Its squared errors are , averaging to 1. Scene 7 pictures that refit. The bar scale is 40 drawing units per MSE unit. This is a computed training trace; no held-out curve or optimal round count is available.
Compare the First Step
Both panels use identical targets and scales, compressed horizontally to place the comparison side by side. The first tree is fixed. Rate 0.5 produces [4,4,6,6], with MSE 2. Rate 1 produces [3,3,7,7], with MSE 1. The full step does not overshoot a target range or necessarily destabilize this fit. Smaller rates often trade more rounds for different generalization behaviour; they are not automatically better on training error. Choose rate and round count together using representative held-out evaluation. Future trees must be refitted for each rate rather than reusing a trajectory learned under another rate.
Recompute Before Refitting
Continue the half-rate run. Rings now show −2,0,0,+2, not the original residuals. Cuts 1.5 and 3.5 tie with squared residual-fit error ; our tie rule chooses the smaller threshold. Cut 1.5 leaves −2 alone and groups [0,0,2] at mean 2/3. The signed step shows those outputs. Cut 2.5 would cost 4, so simply reusing the first split is worse here.
The updated predictor is . The new tree corrects the current ensemble, not just the immediately previous tree. For feature 4, the latest correction is only 1/3 even though its residual is 2, because that leaf also contains two zero residuals.
Sum at Inference Time
A fresh feature value 3.2 lies in the right leaf of both trees. The floating bars show baseline 5, first contribution , and second contribution . Their cumulative height is . The small last bar retains its honest one-third height; the label makes its value explicit. No new tree is fitted for this query, and no observed target is supplied, so this is an inference check rather than evidence of test accuracy.
Change the Loss Target
Both panels return to the initial prediction 5 and use the same 30-units-per-gradient scale. Half squared loss gives targets [−3,−1,+1,+3]. Absolute loss gives negative subgradient targets [−1,−1,+1,+1] at these nonzero residuals: a large miss does not create a larger gradient magnitude. This compares the fit targets, not two completed models.
For absolute loss, leaf outputs also need loss-specific optimization; fitting a tree to signs alone does not mean the final correction in every leaf is exactly ±1. The loss-function discussion describes this adjustment. Ordinary residual fitting cannot be assumed for every boosting objective.
Where It Breaks
Keep the two half-rate trees. This wider view uses 75 drawing units per feature unit and 20 per response unit. The dashed divider is the largest training feature, 4. Both trees route any feature above 4 into the same right leaves; their sum stays at feature 6. If the underlying relation continues as , the target at 6 is 12, shown by the amber ring. The cross is the flat model prediction, with a gap of .
The continued relation is an explicit illustrative assumption, not something proven by four training points. A sum of finite trees with constant leaves remains piecewise constant: adding trees cannot make these far-right leaves extrapolate a rising slope. This boundary applies to constant-leaf trees, not every possible gradient-boosting base learner. Use data covering the intended prediction range or a model with suitable extrapolation assumptions.
The Quick Version
- Start squared-loss fitting from the target mean.
- Residuals carry direction and magnitude.
- Leaves share corrections among their observations.
- Scale each tree before adding its output.
- Measure training loss using a consistent definition.
- Smaller learning rates are not automatically better.
- Refit against the entire current ensemble.
- Inference sums the baseline and learned contributions.
- Loss choice changes gradient targets and leaf updates.
- Constant tree leaves cannot extrapolate a rising slope.