Skip to content

Stage 2 · Intermediate · M3

Twenty Questions

The model that wins most tabular competitions is not a neural network.

12 lessons · 113 minSteady

About this chapter

A decision tree asks yes or no questions until it is sure, which is exactly how a person would sort the same data. One tree memorizes almost instantly, so this chapter shows the two great fixes: build many trees on random slices, or build them one after another to correct each other. That second idea, gradient boosting, is still the first thing to try on a table. You also learn to read feature importance without being fooled by it.

What you will be able to do

  1. 1

    A Tree of Questions

    Trace one example down a tree and read the prediction at the leaf.

    8 min
  2. 2

    Which Question to Ask First

    Score a cut by how mixed its two buckets are, and pick the cut that leaves the least mess.

    10 min
  3. 3

    Why Tree Boundaries Are Staircases

    Say why every edge of a tree's boundary is square, and what that costs it.

    8 min
  4. 4

    A Tree That Memorizes

    Grow a tree until it memorizes the training set and see the test error rise.

    9 min
  5. 5

    Pruning and Depth Limits

    Control tree size with depth, leaf size and cost-complexity pruning.

    9 min
  6. 6

    Many Trees, Many Samples

    Explain bagging and why averaging independent errors helps.

    9 min
  7. 7

    Random Forests

    Build a forest and say why it hides columns from every split.

    10 min
  8. 8

    Learning From Your Own Mistakes

    Describe boosting as a chain of small models, each fixing what the last one got wrong.

    10 min
  9. 9

    Gradient Boosting

    Tune the step size, the depth and the number of rounds, and say what each one does.

    11 min
  10. 10

    Feature Importance and Its Traps

    Read an importance chart and name two ways it misleads you.

    9 min
  11. 11

    Crediting Each Feature Fairly

    Explain the SHAP idea and read a single-prediction explanation.

    10 min
  12. 12

    When Trees Beat Deep Learning

    Choose between trees and neural networks from the shape of the data.

    10 min

Before you start

Keep going

All chapters