liveBook · Manning

Leaf node

As explained in Statistics Every Programmer Needs

A leaf node is a terminal node in a decision tree that provides a predicted class label or continuous value.

A leaf node is the endpoint of a decision tree. Unlike a root or internal node, it has no further split: it supplies the predicted class for classification or a continuous value for regression. To interpret a prediction, begin at the root, follow the feature condition at each decision node, and read the result at the leaf reached. section 6.3.6 section 6.3

During training, a tree selects splits that separate classes or reduce variation in a continuous target. Growth ends when a stopping criterion is met, such as maximum depth or a minimum number of samples per leaf. A reached leaf is therefore the end of the model’s decision path, not another question to answer. section 6.1 section 6.3.6

Reading a classification path

For a fourth-down conversion attempt, a tree first tests whether TO_GO is at most 3.5. Follow the branch matching the play, then continue through any conditions on PLAY_TYPE or SCORE_DIFFERENTIAL until a leaf predicts success or failure. The first split alone is not necessarily a leaf: training-data counts on its two sides are 268 successes versus 127 failures and 67 successes versus 156 failures, respectively, but later splits can refine either group. section 6.3.6

Figure 6.10 A closer look at the left subtree: two levels of internal nodes (A) and, at the bottom, four leaf nodes (B). When PLAY_TYPE is 0, thereby indicating a running play, the decision tree predicts a successful fourth-down conversion attempt (a); it doesn’t matter if the team on offense is the road or home team. Alternatively, when PLAY_TYPE is 1, indicating a passing play, the decision tree evaluates SCORE_DIFFERENTIAL before making a prediction. If the team on offense is trailing by 22 points or more, the tree predicts a failed fourth-down conversion attempt (b); but if the team on offense is trailing by fewer than 22 points, the decision tree predicts a successful conversion (c).
figure

The left subtree shows how successive conditions end at different leaf predictions for fourth-down conversions. section 6.3.6

A single leaf prediction does not establish how well the tree generalizes. Evaluate classification results against held-out labels using overall accuracy and a confusion matrix. In a random forest, individual trees also reach leaves, but their predictions are aggregated rather than used alone. section 6.5 section 6.0

How Statistics Every Programmer Needs covers it

How deep it goes
Defines terminal nodes, traces plotted decision paths, and identifies tree-growth stopping criteria.
Examples
Uses home-loan approval thresholds and fourth-down conversion paths to show where decisions end.
What it assumes
Introduces tree navigation with a simple age-and-income example before interpreting feature-based sports predictions.
What you can do after
Evaluate/understand it by tracing a plotted tree to its final prediction and checking classification performance on test data.
How it connects
Links decision trees to root nodes, internal nodes, feature splits, stopping criteria, and random forests.

Also explained in

Compare how 10 books explain leaf node →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.