Part V — Non-Linear Models, Trees, Ensembles & Kernel Methods · Chapter 6

Modern boosters: XGBoost & LightGBM

Hook

Plain gradient boosting sets each leaf to the mean of its residuals — free, unregularized, first-order. What changes if the leaf value comes from an actual optimization instead of a shortcut?

Intuition
λ = 0.0 — faint curve is plain GBM (λ=0), bold is regularized

The faint curve is last chapter's plain GBM fit. Drag λ\lambda up and watch the bold curve pull back toward round 1's fit — regularization is literally the ensemble refusing to fully trust round 2's correction.

Formalize

XGBoost and LightGBM both replace "leaf value = mean of residuals" with a second-order (Newton) step on the loss, using each point's gradient and its curvature (Hessian):

wleaf=GH+λ,G=ileafgi,H=ileafhiw^*_{\text{leaf}} = -\frac{G}{H + \lambda}, \qquad G = \sum_{i \in \text{leaf}} g_i, \quad H = \sum_{i \in \text{leaf}} h_i
  • wleafw^*_{\text{leaf}} — the leaf's optimal prediction, replacing "mean of residuals."
  • gig_i — point ii's gradient of the loss with respect to the current prediction; for squared error, gi=F(xi)yig_i = F(x_i) - y_i.
  • hih_i — point ii's Hessian (second derivative) of the loss — how sharply the loss curves at the current prediction.
  • λ\lambda — an L2 regularization strength penalizing large leaf values directly.
  1. Squared error's Hessian is a constant, which is why GBM could skip it

    For squared-error loss, hi=1h_i = 1 for every point, always. At λ=0\lambda = 0 that makes w=G/H=(gi)/n=w^* = -G/H = -\big(\sum g_i\big)/n = mean of residuals — exactly plain gradient boosting's leaf value. Newton boosting doesn't replace GBM here; it generalizes it.

  2. Regularization shrinks every leaf toward zero, not just the extreme ones

    Increasing λ\lambda grows the denominator for every leaf, pulling ww^* toward 0 regardless of how large GG is — a direct brake on how far any single leaf is allowed to move the prediction.

  3. Histogram binning speeds up finding the split, without changing what's optimized

    LightGBM (and XGBoost's histogram mode) bucket each feature into a fixed number of bins before searching for the best split, trading a small amount of split precision for a search that's proportional to the number of bins instead of the number of distinct values — the leaf-value formula above is unaffected.

Play
leaf values: left = -0.750, right = 3.000

Both λ\lambda and a toy per-point Hessian are live. Raising either one shrinks the leaf values — a real curvature signal and an artificial regularization penalty end up looking identical in the formula, which is exactly the point: HH and λ\lambda enter the denominator the same way.

Worked example

Reusing last chapter's round 2 exactly: splitting at x=4.5x = 4.5 gives a left leaf of 4 points with gradients g=[0.5,0.5,2,1]g = [0.5, -0.5, 2, 1] and a right leaf of 1 point with g=3g = -3.

  1. Left leaf: G = 3, H = 4 (at hessian=1)

    G=0.50.5+2+1=3G = 0.5 - 0.5 + 2 + 1 = 3. With λ=0\lambda = 0: w=3/4=0.75w^* = -3/4 = -0.75 — identical to plain GBM's leaf value.

  2. Add regularization: lambda = 1

    w=3/(4+1)=0.6w^* = -3/(4+1) = -0.6 — a smaller step than before, exactly as λ\lambda is supposed to do.

  3. Add curvature: toy Hessian = 2 per point

    Now H=4×2=8H = 4 \times 2 = 8.

    • At λ=0\lambda=0: w=3/8=0.375w^* = -3/8 = -0.375.
    • At λ=1\lambda=1: w=3/9=1/3w^* = -3/9 = -1/3.
  4. The right leaf shrinks the same way

    G=3G = -3, and H=1×hH = 1 \times h for whatever the per-point Hessian hh is:

    • h=1,λ=0h=1,\lambda=0: w=(3)/(1+0)=3w^*=-(-3)/(1+0)=3 (matches GBM)
    • h=1,λ=1h=1,\lambda=1: w=3/(1+1)=1.5w^*=3/(1+1)=1.5
    • h=2,λ=1h=2,\lambda=1: H=1×2=2H=1\times2=2, so w=3/(2+1)=1w^*=3/(2+1)=1
Checkpoint

Round 2’s left leaf has G = 3 over 4 points. With λ = 1 and a toy Hessian of 2 per point, compute w* = −G / (H + λ).

Pick a value to try it
Summary
wleaf=GH+λw^*_{\text{leaf}} = -\frac{G}{H + \lambda}

Plain gradient boosting's "fit the mean of the residuals" was never a separate idea from this — it's the special case where HH is always 1 and λ\lambda is 0. Making the Hessian and the regularizer explicit is what lets a modern booster take a smaller, more careful step exactly where the loss is curving sharply or a leaf is trying to move too far, instead of taking the same size step everywhere.