How to Read a Tree
A tree-based model organizes decisions as a sequence of questions about predictor values. Starting with a new observation, you apply the first question, follow its branch, and continue until no further question remains. The final location determines the model's prediction for that observation.
The tree's structure and its predictions are related but distinct. A split determines where observations go; a leaf prediction is the model output attached to the terminal node they reach. For this tutorial, the trees and their leaf outputs are given. The focus is how to read them, not how a fitting algorithm chooses splits or calculates a leaf's output.
A split rule is a test involving one or more predictor values. For example, a rule might send observations with policy tenure less than four years to one child and all others to another. A categorical split might instead separate a specified set of categories from the remaining categories. At every internal node, the rule and its branches must together specify how an observation is routed.
A root-to-leaf path is the ordered sequence of nodes and branches followed from the root to a terminal node. The terminal node reached by a particular observation determines its prediction. A tree therefore has a prediction for an observation only after the observation has been routed all the way to a leaf; a value at an internal node is not the final prediction for cases that continue past it.
A Reliable Traversal Method
To trace a new observation, evaluate only the rule at its current node. Follow the branch whose condition is satisfied, then evaluate the next node's rule using the same observation. Do not skip ahead to a predictor that appears later in the tree: its value matters only if the observation reaches the node that tests it.
Read the root split and locate the observation's value for the predictor used there.
Check the condition, including its equality convention, and follow the corresponding branch.
Use the predictor specified at the current node. Continue until the observation reaches a terminal node.
Report the prediction attached to the reached leaf, with its meaning and units as given.
This procedure works because the branches at an internal node partition the cases that reach it: each such case is directed to one child. In a finite tree, following child nodes must eventually end at a terminal node. Thus, if every split has a complete, unambiguous routing rule, every observation follows one path to one leaf.
The conclusion depends on the tree's rules being fully specified. For a numeric split, the rule must say which side receives equality, such as \(x < c\) versus \(x \ge c\), or \(x \le c\) versus \(x > c\). For a categorical split, the categories assigned to each branch must be stated. If a predictor is missing, the tree's missing-value routing convention is needed; a reader should not invent one.
Worked Example: Tracing a Policy Through Numeric Splits
A hypothetical insurer's fitted tree predicts claim cost in dollars. Its root tests whether policy tenure is less than four years. The less-than-four branch leads to an internal node testing whether prior claims are fewer than two: fewer than two leads to a leaf predicting $6,200, while two or more leads to a leaf predicting $11,800. The tenure of four years or more leads to another internal node testing whether vehicle age is less than six years: less than six leads to a $4,100 leaf, and six or more leads to a $7,300 leaf. Trace a policy with tenure 3.5 years, two prior claims, and a five-year-old vehicle. Then trace a second policy with tenure exactly four years and a six-year-old vehicle.
Method. Start at the root for each policy and evaluate only the split at the current node.
First policy. Tenure is 3.5 years, and \(3.5 < 4\), so follow the less-than-four branch. At the next node, the policy has two prior claims. The rule is fewer than two, and \(2 < 2\) is false, so follow the two-or-more branch. This reaches the leaf predicting $11,800. The vehicle's age does not affect this path because the vehicle-age split is on the other branch of the root.
Second policy. Tenure is exactly four years. Since \(4 < 4\) is false, follow the four-or-more branch. At its internal node, the vehicle age is exactly six years; \(6 < 6\) is also false. The policy reaches the six-or-more leaf, which predicts $7,300.
Check and common mistake. Both routes use the stated strict “less than” rules. Treating equality as though it satisfied a less-than rule would incorrectly send the second policy left at both tests. The predictions are the outputs printed at the reached leaves; they are not calculated from the policy's predictor values here.
Rules Can Use Categories as Well as Numbers
Not every split is a threshold on a numeric variable. A categorical split can group several levels on one branch and send the other levels to another branch. The observation's recorded category must be compared with the categories named in the rule. Do not assume that a category is numeric merely because it has been stored as a number or code.
When a tree has several levels, each split is conditional on having reached its node. For example, a split on annual mileage below the root applies only to observations routed to that mileage node. It does not apply to every observation in the data set. This conditional structure is why a path should be traced in order rather than by scanning all the tree's rules at once.
Worked Example: Combining a Categorical Split and a Numeric Split
A hypothetical equipment service team uses a classification tree to predict whether a work order is assigned “routine” or “specialist” handling. The root sends equipment in the categories commercial or specialty to an internal node; all other equipment types go directly to a leaf predicting “routine.” The internal node tests whether annual operating hours are below 1,200. Below 1,200 leads to a “routine” leaf, while 1,200 or more leads to a “specialist” leaf. Trace a specialty unit with 1,250 annual operating hours, and a standard unit with 1,800 hours.
Method. Check the category at the root first. Use operating hours only if the unit reaches the internal node that tests them.
Specialty unit. Specialty is one of the two categories sent to the internal node. Its operating hours are 1,250, and \(1{,}250 < 1{,}200\) is false. It follows the 1,200-or-more branch and receives the leaf prediction “specialist.”
Standard unit. Standard is not commercial or specialty, so it goes directly to the root's other child and receives the prediction “routine.” Its 1,800 operating hours do not change the route: this observation never reaches the operating-hours split.
Check and common mistake. The first route uses both the categorical and numeric tests; the second uses only the root test. It would be incorrect to route the standard unit to “specialist” just because its operating hours exceed 1,200. That threshold applies only at the internal node reached by the specified categories.
Why a Path Ends at One Prediction
A short justification helps explain why traversal is a complete method rather than a convenient shortcut. Suppose that each internal node has a finite set of outgoing branches, and its rules assign every case reaching that node to exactly one of them. At the root, an observation therefore takes one branch. At the child it reaches, the same property assigns it to exactly one next branch, unless that child is already terminal. Repeating this argument gives one path, not several competing paths.
Because the tree is finite and a branch always moves from a parent to a child, the path cannot continue indefinitely or return to an earlier node. It eventually ends at a node with no children: a leaf. Since a leaf has one attached output, the observation receives that output. If the rule at some node leaves an observation's value unassigned, or assigns it to multiple branches, the path is not well-defined until the routing rule is clarified.
Worked Example: Handling a Boundary Value
A hypothetical account-screening tree has a root that sends utilization below 0.40 to a leaf predicting “low alert.” Utilization of 0.40 or more goes to an internal node. That node sends account age of one year or less to a leaf predicting “review,” and account age greater than one year to a leaf predicting “standard.” Trace an account with utilization exactly 0.40 and age exactly one year. Show the tempting error and its correction.
Method. Follow the written inequalities at each node without rounding or changing their equality conditions.
Correct route. At the root, \(0.40 < 0.40\) is false. The account goes to the 0.40-or-more branch. At the next node, age is one year, and one year satisfies the rule “one year or less.” The account reaches the “review” leaf.
Tempting but wrong route. If the root is misread as “0.40 or less,” the account is sent directly to “low alert.” That changes the stated condition. The correct root rule is strictly below 0.40; equality follows the other branch. The final prediction is therefore “review,” not “low alert.”
Check. The route contains two decisions: equality at the root sends the account right, and equality at the second node sends it to “review.” Both conditions are applied to the value named at their respective nodes.
Common Reading Errors
- Stopping at an internal node. A split node directs the observation onward; its rule is not, by itself, the final prediction.
- Ignoring equality. “Less than” and “less than or equal to” route boundary values differently. Copy the exact condition before deciding.
- Applying every split to everyone. A predictor matters only when the observation reaches a node that tests it.
- Confusing a path with a prediction. The path identifies the leaf; the output attached to that leaf is the prediction.
- Assuming a missing-value convention. If a needed value is missing, use the model's stated routing rule or report that the route cannot be determined from the supplied information.
This way of reading trees is useful whenever a model must be explained for an individual case. A clear explanation names the condition at each visited node, the branch taken, the terminal node reached, and the prediction attached there. The structure can then be checked one decision at a time, without attributing a split or a prediction to a branch the observation never reached. This is aligned with the SOA Exam PA (Predictive Analytics) syllabus.
Check Your Understanding
For each problem, trace the stated observation through the supplied tree and report the prediction at the leaf.
- A tree tests whether service duration is below three years. The below-three branch leads to an internal split: fewer than two service calls predicts “monitor,” while two or more predicts “inspect.” Three years or more leads directly to “routine.” What does the tree predict for duration 2.5 years and exactly two service calls? (Answer: “inspect.”)
- A tree sends product categories {A, C} to an internal node and all other categories to a leaf predicting “standard.” The internal node sends weight below 20 kg to “light handling” and weight of 20 kg or more to “heavy handling.” What is predicted for category C at exactly 20 kg? (Answer: “heavy handling.”)
- A tree first tests whether monthly usage is at most 100 units. The at-most branch predicts “low,” and the above-100 branch tests whether account age is below two years: below two predicts “review,” and two or more predicts “stable.” What is predicted for usage 101 and account age exactly two years? (Answer: “stable.”)
- A tree sends region North or South to a node testing whether claim count is zero. Zero predicts “retain”; one or more predicts “refer.” All other regions go directly to “retain.” What is predicted for a West-region account with three claims, and why? (Answer: “retain”; West takes the root's other branch, so the claim-count split is not reached.)
- A tree sends scores below 0.70 to “pass.” Scores of 0.70 or more reach a second node: tenure of at least five years predicts “pass,” and tenure below five predicts “review.” What is predicted for score exactly 0.70 and tenure exactly five years? (Answer: “pass.”)