← All AI/ML articles

Gradient boosting, visualised.

Gradient descent walks downhill by changing numbers. Gradient boosting walks downhill by adding trees: each one is fit to the direction of steepest descent of your loss. Choose the loss, press play, and see how that choice changes everything.

1. Pick a loss2. Follow its gradient3. Survive the outliers
data pointmodel predictionarrow = push the next tree is asked to apply
Click to add a point · Shift-click (or right-click) a point to remove it.
Train loss0
Train MAE0
Points0
Behind the scenes · 1

The loss, and the push it creates

The loss L(e) scores a mistake of size e = y − F. Its negative slope, r = −∂L/∂F, is the pseudo-residual: how hard, and in which direction, the model is told to move at that point. The tree of the next round is trained to predict exactly this push. The white dots mark where your current data sits.


squaredabsoluteHuber (δ = 1)your points right now

Squared loss pushes in proportion to the error, so one huge outlier shouts louder than everyone. Absolute loss pushes with the same force no matter the size. Huber loss is squared for small errors and capped for big ones: the best of both.

Behind the scenes · 2

One round, up close

Each round: compute the push r for every point, grow a small tree that predicts r, then set each leaf’s value to whatever best reduces the real loss inside that leaf (mean for squared, median for absolute). Add the tree, scaled by η. Slide through the rounds.


push r for each pointtree k’s prediction of it
What the computer does in this round
Behind the scenes · 3

Same data, three losses

Here are three models trained on your exact points with the same rounds, learning rate and depth. Only the loss differs. Add an outlier and see which curve gets dragged toward it. The numbers measure each curve’s distance from the hidden true curve the data was drawn around.


squaredabsoluteHuberhidden true curve
Experiment

Break it on purpose

Outliers vs squared loss

Add three wild points and use squared loss. The curve bends toward them.

Rescue with Huber

Keep the outliers, switch to Huber loss. The pushes are capped and the curve calms down.

Stochastic boosting

Noisy data, deeper trees, and each tree sees only half of the points. Compare with subsample 100%.

Check yourself

Three quick questions

Key takeaways

  • Gradient boosting is gradient descent in function space: each tree is a step downhill on the loss.
  • Pseudo-residuals are the negative gradient of the loss. For squared loss they equal the ordinary residuals.
  • Your loss decides the behaviour: squared is sensitive to outliers, absolute and Huber are robust.
  • Learning rate shrinks each step; subsampling adds randomness that reduces overfitting.
  • AdaBoost is the special case with exponential loss and classification stumps.
← Back to all articles