Guess the mean. Fit a tree to what's left over. Add a shrunken slice. Repeat.
AdaBoost's idea generalized: fit the gradient of the loss. For squared error, the gradient is just the residual.
y - F(x) — the leftover.A 1-D curve, y = sin(x) + 0.25x + noise, 120 points. A sum of shallow trees is
a staircase — watch it build toward the curve.
Additive model, built one tree at a time:
FM(x)=F0+νm=1∑Mhm(x)Squared-error loss, and its negative gradient at the current prediction:
L(y,F)=21(y−F)2 ri=−∂F∂L(yi,F)F=Fm−1(xi)=yi−Fm−1(xi)The negative gradient is the residual. Fit a tree to it, take a shrunken step:
Fm(x)=Fm−1(x)+νhm(x)One boosting round per frame, learning rate 0.1. Top: F(x) creeping toward the
curve. Bottom: the residuals collapsing. Train MSE 1.007 → 0.069 over 50 rounds.
Test MSE vs. trees on real data, three learning rates. Small rate: lower floor, more trees, forgiving. Big rate: fast then overfits off a cliff.
100 trees, lr 0.1, depth 3 on diabetes. Scratch R² 0.3766, sklearn R² 0.3916 — neck and neck. A single depth-3 tree scores 0.2564; boosting a hundred of them buys the climb to 0.38.