Skip to content
mlmentorship

Gradient boosting: fit the next correction

Trace a residual stump, recompute losses after shrinkage, and distinguish loss gradients, binary logits, and regularized Newton leaf weights.

Published · 10 min read ·Core ·Foundation

Visual quick review

Trace one squared-error boosting round from the current ensemble prediction, through signed residual targets, to a shrunken tree correction that moves every prediction toward its target.

One boosting round

A squared-error gradient-boosting residual update

A squared-error gradient-boosting residual update Four ordered samples have targets 2, 2, 8, and 8. The initial constant ensemble predicts 5 for every sample, producing residuals negative 3 for the first pair and positive 3 for the second pair. A decision stump splits after sample two and predicts those residual values. With learning rate one half, the stump contributes negative 1.5 on the left and positive 1.5 on the right. Adding that correction changes the predictions to 3.5, 3.5, 6.5, and 6.5, cutting every remaining target gap in half. 1 · CURRENT ENSEMBLE F₀ F₀ = 5 r = −3 ↓ r = +3 ↑ ○ targets y = [2, 2, 8, 8] 2 · FIT A TREE TO r, NOT TO y sample ≤ 2? yes no h₁ = −3 fit samples 1–2 h₁ = +3 fit samples 3–4 η = 0.5 ⇒ add ηh₁ = −1.5 | +1.5 3 · ADD THE SHRUNKEN CORRECTION old F₀ = 5 F₁ = 3.5 F₁ = 6.5 remaining residuals: −1.5 | +1.5; half as long
Read it this way: start at the flat prediction five. Under half-squared loss, target gaps are the next tree's negative-gradient labels. The stump predicts −3 and +3; shrinkage adds −1.5 and +1.5. Each remaining gap halves, while SSE falls from 36 to 9. Sources: Friedman and the XGBoost tutorial.
Check: Why does the first tree predict -3 and +3 rather than the original targets 2 and 8?
Full explanation 10 min read
Reading depth

Summary

Gradient boosting adds a learner to an existing prediction function. Its training targets are negative loss gradients at current predictions, not generally the original labels. Shrinkage scales the new contribution before addition.

Task: ordered features are , targets , and current prediction . Use per-example loss and learning rate . Fit one residual stump, update all predictions, and recompute total loss. This is a training fixture, not a held-out improvement claim.

The algorithm (Friedman, 2001)

Initialize . For half-squared loss this is the mean; for Bernoulli loss it is finite log-odds when both classes occur. Then repeat:

  1. Compute the negative gradient (pseudo-residuals) at each training point:
  2. Fit a regression tree to .
  3. If required, optimize leaf values against the original objective; squared-error residual means already supply its reference correction.
  4. Update: .

Our gradients give pseudo-residuals . A stump at fits leaf values and . Adding gives . SSE falls from to ; summed half-squared loss falls from to . This split is the diagram’s “sample ≤ 2” rule for these ordered features.

Learning objective: trace one squared-error boosting round from the current prediction, through signed residual targets, to the learning-rate-scaled correction.

One boosting round

Fit current negative loss gradients, shrink the new learner, and recompute the objective

Fit current negative loss gradients, shrink the new learner, and recompute the objectiveBoosting fits negative gradients of the current loss, not the original labels again. Half-squared loss gives signed residuals; this stump fits minus three and three. Shrinkage halves those corrections, reducing training loss from eighteen to 4.5. Smaller steps change the update, not the first fitted stump. Logistic loss uses probability residuals and updates logits. Newton leaf weights also depend on curvature and regularization. Training improvement is not held-out generalization.Fit a correction to the current lossgradientToy: ordered features one to four;targets two, two, eight, eight.Current prediction five.Sample 1: negative gradient -3Sample 2: negative gradient -3Sample 3: negative gradient 3Sample 4: negative gradient 3Residual stump: split after sampletwo-3Half-stepcorrection -1.53Half-stepcorrection 1.5Predictions move toward, not directlyonto, targetsSamples one and twoTarget 2; before five; after 3.5Samples three and fourTarget 8; before five; after 6.5Summed half-squared training loss:eighteen becomes 4.5Quarter steps: 4.25, 4.25, 5.75,5.75; SSE 20.25. Later roundsrecompute gradients.Logistic loss at zero logits:probability 0.5 gives negativegradients minus/plus 0.5, notminus/plus three.Logistic trees update logits. Aseparate Newton leaf with gradientsum one, curvature 0.5 and penaltyone has weight about minus 0.667, notminus 0.5.Training improvement does notestablish held-out generalization.
Read it this way: Boosting fits negative gradients of the current loss, not the original labels again. Half-squared loss gives signed residuals; this stump fits minus three and three. Shrinkage halves those corrections, reducing training loss from eighteen to 4.5. Smaller steps change the update, not the first fitted stump. Logistic loss uses probability residuals and updates logits. Newton leaf weights also depend on curvature and regularization. Training improvement is not held-out generalization. Does logistic boosting reuse the regression gaps?
Reference drawing

One boosting round

Fit current negative loss gradients, shrink the new learner, and recompute the objective

Fit current negative loss gradients, shrink the new learner, and recompute the objectiveBoosting fits negative gradients of the current loss, not the original labels again. Half-squared loss gives signed residuals; this stump fits minus three and three. Shrinkage halves those corrections, reducing training loss from eighteen to 4.5. Smaller steps change the update, not the first fitted stump. Logistic loss uses probability residuals and updates logits. Newton leaf weights also depend on curvature and regularization. Training improvement is not held-out generalization.Fit a correction to the current lossgradientToy: ordered features one to four;targets two, two, eight, eight.Current prediction five.Sample 1: negative gradient -3Sample 2: negative gradient -3Sample 3: negative gradient 3Sample 4: negative gradient 3Residual stump: split after sampletwo-3Half-stepcorrection -1.53Half-stepcorrection 1.5Predictions move toward, not directlyonto, targetsSamples one and twoTarget 2; before five; after 3.5Samples three and fourTarget 8; before five; after 6.5Summed half-squared training loss:eighteen becomes 4.5Quarter steps: 4.25, 4.25, 5.75,5.75; SSE 20.25. Later roundsrecompute gradients.Logistic loss at zero logits:probability 0.5 gives negativegradients minus/plus 0.5, notminus/plus three.Logistic trees update logits. Aseparate Newton leaf with gradientsum one, curvature 0.5 and penaltyone has weight about minus 0.667, notminus 0.5.Training improvement does notestablish held-out generalization.
Derivation
A squared-error gradient-boosting residual update Four ordered samples have targets 2, 2, 8, and 8. The initial constant ensemble predicts 5 for every sample, producing residuals negative 3 for the first pair and positive 3 for the second pair. A decision stump splits after sample two and predicts those residual values. With learning rate one half, the stump contributes negative 1.5 on the left and positive 1.5 on the right. Adding that correction changes the predictions to 3.5, 3.5, 6.5, and 6.5, cutting every remaining target gap in half. 1 · CURRENT ENSEMBLE F₀ F₀ = 5 r = −3 ↓ r = +3 ↑ ○ targets y = [2, 2, 8, 8] 2 · FIT A TREE TO r, NOT TO y sample ≤ 2? yes no h₁ = −3 fit samples 1–2 h₁ = +3 fit samples 3–4 η = 0.5 ⇒ add ηh₁ = −1.5 | +1.5 3 · ADD THE SHRUNKEN CORRECTION old F₀ = 5 F₁ = 3.5 F₁ = 6.5 remaining residuals: −1.5 | +1.5; half as long
Read it this way: start at the flat prediction five. Under half-squared loss, target gaps are the next tree's negative-gradient labels. The stump predicts −3 and +3; shrinkage adds −1.5 and +1.5. Each remaining gap halves, while SSE falls from 36 to 9. Sources: Friedman and the XGBoost tutorial.
Check: Why does the first tree predict -3 and +3 rather than the original targets 2 and 8?
Read it this way: Boosting fits negative gradients of the current loss, not the original labels again. Half-squared loss gives signed residuals; this stump fits minus three and three. Shrinkage halves those corrections, reducing training loss from eighteen to 4.5. Smaller steps change the update, not the first fitted stump. Logistic loss uses probability residuals and updates logits. Newton leaf weights also depend on curvature and regularization. Training improvement is not held-out generalization. Does logistic boosting reuse the regression gaps?

Change the step size

New task: use with the same first stump. Keep its fit and scale the corrections to and . Check: predictions become and SSE becomes . Use when: smaller updates are desired and extra rounds remain affordable. Later rounds must recompute gradients at their changed ensemble predictions.

Change the objective

New task: use labels , Bernoulli cross-entropy, and initial raw logits . Probabilities are , so negative gradients are . Check: they are not the regression gaps or the raw labels. Use when: fitting probabilities instead of numeric responses; trees update logits before the sigmoid.

Newton boosting (xgboost)

For logistic loss, and curvature . In one fixed leaf, the quadratic approximation with L2 leaf penalty is

With positive denominator, differentiating gives . For the two negative labels above, , , and , hence . This Newton weight differs from the first-order leaf mean . Split structure scoring, leaf optimization, and learning-rate shrinkage are separate operations. Curvature does not guarantee faster convergence or better generalization on every workload.

Why it works

When , the learner points downhill locally in prediction space. A finite step still needs suitable scale; approximate fitting is not a guaranteed useful correction on new data. Each tree depends on the current ensemble, unlike independent averaging of separately fitted trees.

Failure: a flexible tree can fit label noise, lowering training loss while validation loss rises. Choose early stopping on validation and restore the selected ensemble; selecting on test outcomes leaks evaluation information.

Reconstruct: what does the first reference update produce at ?

Answer

Predictions equal , giving zero reference training SSE. That exact fit says nothing about unseen points.

The four implementations

LibraryDistinction to inspect in the chosen version
XGBoostRegularized second-order objectives, split methods, and sparse/missing-value routing.
LightGBMHistogram construction, leaf-wise growth, and declared categorical features.
CatBoostOrdered boosting and ordered categorical statistics with their leakage controls.
sklearn GradientBoostingClassifierStagewise gradient boosting; compare separately with its histogram-based estimators.

Benchmark actual data, hardware, objective, category policy, and quality constraints rather than ranking libraries universally.

Hyperparameters that matter

ControlWhat changes
Learning rate and roundsUpdate magnitude and number of dependent corrections.
Depth or leaf countEach learner’s partition complexity.
Minimum leaf support or Hessian weightWhich candidate regions are admissible.
Row and feature samplingObservations and candidate predictors used during fitting.
L1/L2 leaf penaltiesLeaf optimization and associated split scoring.

Names and defaults differ by library. Learning rate and round count interact, but halving one and doubling the other is not an exact equivalence.

When GBDT wins

It can be a useful candidate for heterogeneous features and threshold-based interactions. Measure probability quality, task metrics, latency, and maintenance cost against meaningful alternatives.

When GBDT loses

Raw unstructured inputs may need a different representation; tiny or shifted datasets can invalidate apparent gains. Pairwise/listwise ranking needs its own objective and query grouping, not an ordinary regression interpretation.

Common pitfalls

Fit preprocessing and target-based encodings without validation or test leakage. Compare learning curves and restore best validated weights; neither fixed rounds nor early stopping automatically prevents overfitting. See decision trees for weighted split mechanics and logistic regression for Bernoulli probabilities.