liveBook · Manning

Leaf node

As explained in Grokking AI Algorithms, Second Edition

A leaf node is a terminal tree node that contains examples assigned to a final class or prediction.

A leaf node is the endpoint of a tree: it has no children, so its degree is 0. In the family analogy for tree structures, it is the youngest member with no descendants. section 2.7

In a decision tree, a leaf node holds examples assigned to one class or stores the label counts used for prediction. Decision nodes ask questions; leaves contain the resulting categories. section 8.16 section 8.17

Recognize a leaf node by these properties:

  • Ends a path away from the root and has no child nodes. section 2.7
  • Represents a final category in a classification tree, such as Okay or Perfect. section 8.16
  • Can store counts for each label, allowing the tree to represent its predictions. section 8.17

Following diamond examples to a leaf

A decision tree filters diamond examples with questions such as “Is Carat >= 0.5?” Each answer selects a branch. When no useful split remains, the recursive builder creates an ExamplesNode containing the remaining examples and their label counts. That terminal node is the leaf, such as a group categorized as Okay or Perfect. section 8.16 section 8.17

Figure 2.12 The main attributes of a tree

Use the tree-attributes figure to see how a leaf relates to the root, parent, children, depth, and height. section 2.7

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Defines terminal structure and shows recursive creation from zero information gain, but does not develop prediction beyond stored label counts.
Examples
Illustrates leaves with maze paths, diamond categories, label-count dictionaries, and an ExamplesNode implementation.
What you can do after
Build a terminal decision-tree node when no informative split remains and inspect its stored class predictions.
How it connects
Connects leaf nodes to trees, root nodes, parent nodes, child nodes, decision nodes, classification, and information gain.

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 Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.