XGBoost is regularized second-order gradient boosting. Objective:
L=∑i=1nl(yi,y^i)+∑k=1KΩ(fk) with tree regularization
Ω(f)=γT+21λ∥w∥2 (
T leaves,
w leaf weights,
γ per-leaf complexity penalty,
λ L2 shrinkage on leaf weights). Round
t adds
ft:
y^i(t)=y^i(t−1)+ft(xi); Taylor-expand the loss to second order around
y^i(t−1):
l(yi,y^i(t−1)+ft(xi))≈l(yi,y^i(t−1))+gift(xi)+21hift(xi)2 with first derivative
gi=∂y^i(t−1)∂l(yi,y^i(t−1)) and second derivative
hi=∂(y^i(t−1))2∂2l(yi,y^i(t−1)). Dropping constants, the step-
t objective is
∑i=1n[giwq(xi)+21hiwq(xi)2]+γT+21λ∑j=1Twj2, where
q(x) maps a sample to its leaf. Grouping by leaf with
Ij={i∣q(xi)=j},
Gj=∑i∈Ijgi,
Hj=∑i∈Ijhi, the objective becomes
∑j=1T[Gjwj+21(Hj+λ)wj2]+γT — independent quadratics in each
wj, so the optimal leaf weight is
wj∗=−Hj+λGj, giving the minimal objective
L∗=−21∑j=1THj+λGj2+γT. Splitting node
I=IL∪IR yields the structural gain
Gain=21[HL+λGL2+HR+λGR2−HL+HR+λ(GL+GR)2]−γ; split iff
Gain>0 (
γ acts as a minimum split gain, equivalent to post-pruning). Common losses: squared loss has
gi=2(y^i−yi),
hi=2; logistic log loss has
p^i=σ(y^i),
gi=p^i−yi,
hi=p^i(1−p^i).