← All AI/ML articles

Boosting, visualised.

Start with a very simple guess. Then add one small tree at a time, each one trained only to fix what the model so far still gets wrong. Press play and watch a weak learner become a strong one.

1. Add a tree2. Fix the mistakes3. Know when to stop
training pointvalidation point (hollow)model prediction
Click to add a point · Shift-click (or right-click) a point to remove it. About 1 in 4 points is held out for validation.
Train MSE0
Validation MSE0
Points0
Behind the scenes · 1

Each tree learns the leftovers

The model starts as one number: the average of y. After that, every round computes the residuals (how far each point is from the current prediction) and fits a small tree to those. The tree’s output, shrunk by η, is added to the model. Slide through the rounds to see the pattern.


residual before this roundwhat tree k predicts for it
What the computer does in this round

Residual = y − Fk−1(x). For squared error, the residual is exactly the negative gradient of the loss, which is why this is called gradient boosting. Early rounds have big residuals; later rounds only chase what is left.

Behind the scenes · 2

More rounds: better, then worse

Training error keeps falling with every tree, because the model can always memorise a bit more. Validation error falls too, then turns back up once the trees start fitting noise. The best moment to stop is the lowest point of the pink curve.


train MSEvalidation MSEyour current round
Behind the scenes · 3

Small steps vs big steps

The learning rate η scales each tree’s contribution. Big η learns fast but can overshoot and overfit quickly. Small η needs more trees but usually ends up at a better validation score. Solid lines are training error, dashed lines are validation error, all on your current data.


η = 1.0η = 0.3η = 0.05

This is the classic boosting trade-off: lower the learning rate and raise the number of rounds together. It is the same idea behind libraries like XGBoost and LightGBM.

Experiment

Break it on purpose

Boost too long

Noisy data, deep trees, big steps, 60 rounds. Watch train error crash while validation error climbs.

Tiny learning rate

Set η to 0.02 with only 15 rounds. The model barely moves: it is under-trained, not wrong.

One bad outlier

Add a point that fights the trend. Later trees chase its huge residual and bend the curve.

Check yourself

Three quick questions

Key takeaways

  • Boosting builds the model in stages: each new tree corrects the errors of the ones before.
  • Residuals are the target of each new tree: y minus the current prediction.
  • Learning rate shrinks each tree’s step. Smaller steps plus more rounds is usually safer.
  • Weak learners are enough: shallow trees add up to a flexible curve.
  • Too many rounds overfit. Use a validation set to pick when to stop.
← Back to all articles