01Why it matters
Twenty questions, then many small fixes
A doctor's checklist, a bank's loan rules, the game of twenty questions: each asks one simple question, then picks the next question based on the answer. A decision tree learns such a checklist from data, and anyone can read the result.
One tree is easy to understand but easy to fool. Add up hundreds of tiny trees, each fixing the mistakes of the ones before, and you get gradient boosting, the method that wins most competitions on tabular data.
02Key parts
The pieces you will see
- split
- A yes/no question about one feature, like . It cuts a region of the plane into two boxes.
- Gini impurity
- for the class shares in a region: 0 when it is pure, ½ for an even two-class mix.
- leaf
- A region that isn't split any further. It predicts its majority class.
- residual
- In boosting, what the model still gets wrong: .
- stump
- A tree with a single split: a step, with one value on each side.
03See it work
Grow a tree on XOR
The tree is grown greedily. For a region it tries every threshold on each axis, scores each split by the Gini impurity of the two halves (weighted by their sizes), and keeps the lowest. A single question can't separate XOR, since every cut leaves both classes on both sides, but two levels of questions can: this tree gets 95% of the points right at depth 2.
Deeper isn't always better, though:
04See it work
Boosting: fit what is left
Boosting starts from a flat guess, the mean of . Each round it looks at the residuals, fits one stump to them, and adds times that stump to the model:
Each stump is weak, just one step, but together they build a staircase that follows the curve. Because each one is fitted to the current errors, the training error can only fall.
05Predict
Your turn: which question comes next?
Make 5 predictions: step forward and answer each question before the next step plays.
0 of 5 made06Try it
Change the depth and the learning rate
Use the slider to change the maximum depth, and the buttons to change the data:
- Moons or circles at depth 1, 3 and 5: training accuracy climbs, but the boundary turns into a staircase of tiny boxes.
- Overlapping classes: deeper trees chase individual points into their own leaves.
For boosting, compare Small learning rate (η = 0.2) with Learning rate 1: the small rate falls more slowly but each stump changes the model gently; the full rate fixes big errors fast, then starts chasing noisy points.
07Check yourself
Check yourself
Question 1 of 5
A region holds 3 points of class A and 1 of class B. What is its Gini impurity?
Your answer comes back in Review in a few days, so it sticks.
Question 2 of 5
Why can’t a depth-1 tree solve XOR?
Question 3 of 5
In gradient boosting, what does each new stump fit?
Question 4 of 5
Why multiply each stump by a learning rate η below 1?
Question 5 of 5
A depth-12 tree is 100% right on its training points. What does that tell you about new points?
08Explain it back
Say it in your own words
How does a decision tree choose its splits, and how does gradient boosting turn many weak trees into a strong model?
09Recap
What to remember
- A decision tree asks one question about one feature at a time; each split is the one with the lowest weighted Gini.
- Deep trees fit their training data perfectly and overfit; limit depth and judge on new data.
- Gradient boosting adds shrunk stumps fitted to the residuals, so the training error only falls.
- Small learning rates with more rounds are the usual recipe.