Basis Lab

Trees, and Committees of Them

Knowing When to Stop Growing

Last timeGrowing a Whole Tree

A tree grown until every leaf is pure memorises its training data exactly, so growth has to be limited, and cutting back after growing works better than stopping early.

The tree that remembers everything

Remove the stopping rules from the growing procedure and it keeps splitting until every leaf is pure. On data with no exactly duplicated rows, that means most leaves hold a single training row.

Such a tree predicts every training row perfectly. Its training score is one hundred per cent, every time, on any data set. The score is therefore not a measurement of anything: it is a property of the procedure.

FIG 1The same data, trees of four sizes
leavescorrect on the training rowscorrect on held back rows
depth 127472
depth 388684
depth 6419779
grown without limit31210071
Percentages, on a data set of four hundred rows. The last row is the whole lesson: perfect on what it was grown on, worse than a tree of depth one on anything else. The middle rows show the two scores separating, which is the shape from the seventh lesson of the previous course appearing again in a model with no knobs in it at all.

What has happened is worth saying precisely. The tree has not learned a bad relationship. It has learned no relationship: each leaf is a record of one observation, and a new case is answered by whichever training row happens to be nearest in the particular sequence of questions the tree asked. That is a lookup table with extra steps.

FIG 2Accuracy against tree size
0.000.070.150.220.301.010.820.530.340.0number of leaves
on the rows it was grown onon rows it has never seen
The lower curve goes to zero and stays there. The upper one has a lowest point around a dozen leaves and climbs steadily after it. The distance between the two curves at any size is the amount of memorisation, and reading only the lower curve gives a tree of maximum size every time.

Three limits

Growth is limited in three ways, and implementations offer all three.

A maximum depth caps how many questions may be asked in a row. It is blunt, because it limits every branch equally whether or not each branch needs it, and it is the easiest to reason about.

A minimum number of rows in a leaf refuses to create a leaf resting on fewer than that many observations. This is the most directly meaningful of the three, because it is a statement about evidence: a prediction must be supported by at least this many cases before the model will make it.

A minimum improvement refuses a split whose value, in the sense of the first lesson, is below a threshold. It stops the tree spending depth on questions that barely clean anything up.

The lesson stops here

3 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01Splitting on One Question
  2. 02Growing a Whole Treeopening only
  3. 03Knowing When to Stop Growingyou are here
  4. 04One Tree Is Unstableopening only
  5. 05Averaging Many Treesopening only
  6. 06Each Tree Fixing the Lastopening only
  7. 07Which Input Actually Matteredopening only
  8. 08When to Reach for a Treeopening only

Read alongside