liveBook · Manning

Root node

As explained in Grokking Machine Learning, Second Edition

The topmost node of a tree, representing the entire input dataset before any splits.

A root node is the topmost node in a decision tree. It represents the entire training dataset and asks the tree’s first yes-or-no question. From there, branches lead to further decision nodes or leaves. section 9.0

A root node plays several roles while a tree is built:

  • Start with level 0 and associate the complete dataset with the node. section 9.6
  • Choose the feature that splits its samples most effectively according to a metric such as accuracy, Gini index, or entropy. section 9.6
  • Become a decision node when splitting is allowed, or remain a leaf with the most common label when stopping conditions prevent a split. section 9.6

A first question about the weather

For the jacket example, the root node might ask, “Is it raining?” A yes branch leads directly to wearing a jacket, while a no branch can ask about temperature. A tree with only this root question and two leaves is a decision stump. section 9.0

A learned root split

With Scikit-Learn, fitting a DecisionTreeClassifier to features x_0 and x_1 produces a root corresponding to the first boundary, x_0 = 5. The resulting tree has depth 2, three nodes, and four leaves. section 9.11

Figure 9.2 A regular decision tree with a root node, decision nodes, branches, and leaves. Note that each decision node contains a yes-or-no question. From each possible answer, one branch emanates, which can lead to another decision node or a leaf. This tree has a depth of 2, because the longest path from a leaf to the root goes through two branches.

Use the diagram to trace how the root’s yes-or-no question divides the dataset into branches and lower-level nodes. section 9.0

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Explains initialization, splitting, stopping conditions, and level numbering, but not the internal calculation of split metrics.
Examples
Uses jacket decisions, an app-recommendation tree, and a Scikit-Learn dataset split at x_0 = 5.
What it assumes
Uses features, labels, branches, and yes-or-no questions while defining the tree structure through concrete examples.
What you can do after
Build a decision tree from a labeled dataset and trace predictions from its root to a leaf.
How it connects
Connects decision trees with decision nodes, leaf nodes, branches, decision stumps, and split metrics.

Also explained in

Compare how 8 books explain root node →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning, Second Edition. The section links point to the parts of the book it draws on.