Tutorials › Exam PA - Predictive Analytics › Translating Root-To-Leaf Paths Into Rules

Exam PA · Single Trees and Rule-Based Prediction · Tutorial 497 of 966

Translating Root-To-Leaf Paths Into Rules

Turn each route through a fitted tree into an unambiguous rule, with all split conditions joined to identify the terminal-node prediction.

Intermediate 10 min read

What You'll Learn

  • Express a root-to-leaf path as a conjunction of branch conditions.
  • Translate numeric split directions and boundary values precisely.
  • Write categorical split conditions using the correct group and its complement.
  • Combine repeated conditions on a predictor without changing their meaning.
  • Distinguish a terminal node’s prediction from the conditions that lead to it.
  • Check that a rule routes an observation to the intended leaf.

From a Tree Path to an If-Then Rule

A fitted decision tree makes a prediction by starting at its root, checking a split condition, and following the corresponding branch until it reaches a terminal node. A readable rule states those same branch conditions in one place: if all of the conditions are satisfied, then use the prediction stored in that terminal node. This translation is useful when explaining a tree to a colleague, checking an individual prediction, or documenting model logic.

A path is not a list of alternatives. Every decision along the route must be followed, so its conditions are joined by “and.” The rule also needs the branch direction at each split. Reversing one direction can send an observation to a different terminal node even if every other condition is copied correctly.

Definition: A root-to-leaf path is the sequence of branches from the tree’s root to one terminal node. The corresponding if-then rule is the conjunction of the conditions defining those branches, followed by the terminal node’s prediction. For example, “if \(X \leq c\) and \(Z > d\), then predict \(r\)” means both conditions must hold for the observation to receive prediction \(r\).

The prediction at the end depends on the type of tree and what the terminal node stores. A regression tree may store a numeric prediction, while a classification tree may store a predicted class, class probabilities, or both. Those values are the rule’s conclusion; they are not additional split conditions.

Reading Each Condition Precisely

For a numeric split at threshold \(c\), one branch commonly contains values less than or equal to \(c\), and the other contains values greater than \(c\). Copy the comparison and its direction exactly. In particular, \(X=c\) goes to the \(\leq\) branch, not the \(>\) branch. Tree descriptions can use different branch conventions, so the rule should reflect the fitted tree as stated rather than an assumed convention.

A categorical split may send a specified set of levels down one branch and all remaining levels down the other. If the left branch is \(G \in \{\text{North},\text{East}\}\), the right branch means \(G \notin \{\text{North},\text{East}\}\), assuming those are the possible levels. Writing “not North” would be wrong if East also follows the left branch.

Sometimes the same predictor appears more than once along a path. Keep both conditions first, then check whether they can be stated more simply without changing their meaning. For example, \(X>10\) and \(X\leq18\) is equivalent to \(10<X\leq18\). Do not discard either bound: together they describe the path.

$$ \text{path conditions } C_1,C_2,\ldots,C_k \quad\Longrightarrow\quad (C_1 \text{ and } C_2 \text{ and }\cdots\text{ and }C_k) \ \Longrightarrow\ \text{terminal-node prediction} $$

The rule describes the fitted model’s routing, not a causal claim about the predictors. It applies under the tree’s stated split and routing conventions. If the model has a special procedure for missing values or unseen factor levels, that procedure must also be considered; the simple rules below assume the inputs satisfy the stated conditions and have defined routes.

Why the Conditions Must Be Joined by “And”

The conjunction follows directly from how a tree routes an observation. At the root, an observation must satisfy the condition for the chosen branch. At the next node, it must satisfy that node’s branch condition as well. Repeating this process adds one required condition at each step.

1
Start at the root.
An observation follows exactly one outgoing branch, according to the root split.
2
Apply the next split.
To continue along the selected path, the observation must also satisfy the condition for the next chosen branch.
3
Continue to the terminal node.
Each successive branch adds another required condition. Reaching that leaf therefore requires satisfying every condition on the path.

More formally, suppose the path contains conditions \(C_1,\ldots,C_k\). An observation reaches the chosen leaf only if it follows the selected branch at every split, which is equivalent to satisfying \(C_1\land\cdots\land C_k\). If even one condition fails, it takes a different branch at that split and cannot follow this path to this leaf. This is why replacing “and” with “or” would describe a different and generally much larger set of observations.

Worked Example: Writing Rules for Repair-Cost Leaves

Hypothetical scenario. A regression tree predicts a vehicle’s repair cost. The root splits on annual mileage: vehicles with mileage \(\leq 12{,}000\) go left; those with mileage \(>12{,}000\) go right. Each branch then splits on vehicle age: age \(\leq4\) years goes left, and age \(>4\) years goes right. The four leaves, in left-to-right order, predict \$310, \$510, \$620, and \$890. Write the rules for the \$620 and \$890 leaves, and route a vehicle with 12,000 miles and age 7 years.

Method. Trace each requested leaf from the root, recording both the split condition and the direction taken. Join the recorded conditions with “and.”

Rule for \$620. The path first takes the right branch at the root, so mileage \(>12{,}000\). At the next split it takes the left branch, so age \(\leq4\). The rule is: if mileage \(>12{,}000\) and age \(\leq4\), predict \$620.

Rule for \$890. This path also starts with mileage \(>12{,}000\), then takes the right age branch, so age \(>4\). The rule is: if mileage \(>12{,}000\) and age \(>4\), predict \$890.

Route the specified vehicle. Its mileage is exactly 12,000, so \(12{,}000\leq12{,}000\) and it goes left at the root. Its age is 7, which is \(>4\), so it then goes right. It reaches the \$510 leaf. The result is checked against the path: it does not satisfy the \(>12{,}000\) condition for either right-root rule.

Common mistake avoided: Treating 12,000 as part of the \(>12{,}000\) branch. The stated boundary puts equality in the \(\leq\) branch.

Worked Example: Combining Categorical and Numeric Conditions

Hypothetical scenario. A classification tree predicts whether a small-business account will need additional review. At the root, accounts with channel in \(\{\text{broker},\text{web}\}\) go left; all other channels go right. The left branch splits on prior late payment: Yes goes left and No goes right. The leaf reached by broker or web accounts with no prior late payment has review probability 0.09 and predicts “No review” at a 0.50 classification threshold. Write its rule. Then determine the conclusion for a web account with no prior late payment.

Method. Translate the root’s grouped levels as one set-membership condition, then add the condition for the selected branch at the second split. Keep the leaf’s probability and class conclusion distinct from the rule conditions.

Rule. The path requires channel \(\in\{\text{broker},\text{web}\}\) and prior late payment = No. Thus: if channel is broker or web, and prior late payment is No, then the model assigns review probability 0.09 and predicts No review.

Check the account. Web belongs to the specified channel set, and the account has no prior late payment. Both conditions hold, so it reaches that leaf. Since \(0.09<0.50\), the stated threshold yields the class prediction “No review.” The rule applies; the probability is the leaf’s output, not a third condition.

Common mistake avoided: Rewriting the channel condition as “channel is broker.” That omits web, which follows the same branch, and would incorrectly exclude the account in the question.

Repeated Predictors and Complete Rules

A tree can split on the same predictor more than once along a path. In that case, the rule includes the conditions from both nodes. Simplification is appropriate only after checking that the combined condition preserves the exact values admitted by the path, including equality at each boundary.

Worked Example: Combining Two Mileage Bounds

Hypothetical scenario. A regression tree estimates the annual service cost for a delivery vehicle. At the root, annual mileage \(>10{,}000\) goes right. That branch splits again on mileage: values \(\leq18{,}000\) go left to a leaf predicting \$740; values \(>18{,}000\) go right. Write the \$740 rule, simplify its mileage condition, and route a vehicle with 10,000 miles.

Method. Record the condition at each split on the path before simplifying. The first right branch requires mileage \(>10{,}000\). The next left branch requires mileage \(\leq18{,}000\). Therefore, the complete rule is: if mileage \(>10{,}000\) and mileage \(\leq18{,}000\), predict \$740.

These two inequalities can be written \(10{,}000<\text{mileage}\leq18{,}000\). This is the same condition: it excludes 10,000, includes 18,000, and includes every value between them. Thus a vehicle with exactly 18,000 miles reaches the \$740 leaf, while one with more than 18,000 takes the next right branch.

For the vehicle with 10,000 miles, the root condition \(10{,}000>10{,}000\) is false. It does not enter the path to the \$740 leaf, so this rule does not apply. The equality is excluded from this path even though it might satisfy some other branch elsewhere in the tree.

Common mistake avoided: Dropping the root condition and writing only mileage \(\leq18{,}000\). That would include values at or below 10,000 that never reach the \$740 leaf.

Checks Before Reporting a Rule

A useful rule should be both complete and faithful to the tree. Before reporting it, verify the starting node, every branch direction, each comparison sign, any grouped factor levels, and the terminal-node output. If simplifying a repeated condition, check its endpoints explicitly. Finally, if a particular observation is being classified by the rule, test every condition rather than stopping at the first one that appears to fit.

The rule is a concise description of how the fitted tree maps inputs to a leaf. It should not be interpreted as evidence that a condition causes the prediction, and the terminal-node prediction should not be described as a guaranteed outcome. These distinctions matter when explaining model output in actuarial work. This topic is aligned with the SOA Exam PA (Predictive Analytics) syllabus.

Key takeaway: For each terminal node, trace the route from the root and write every selected branch condition joined by “and.” Preserve boundary and category details, then state the prediction stored in that leaf.

Check Your Understanding

For each problem, translate the specified path or use its rule to identify the terminal-node conclusion.

  1. A hypothetical tree first sends policyholders with 2 or fewer service calls left and those with more than 2 right. The left branch then sends tenure \(>3\) years to a leaf predicting an annual cost of \$460. State the rule for that leaf. (Answer: If service calls \(\leq2\) and tenure \(>3\) years, predict \$460.)
  2. A classification tree sends channels in \(\{\text{agent},\text{mobile}\}\) left and all others right. The left branch sends “prior cancellation = Yes” left and “No” right. That right-hand leaf has cancellation-risk probability 0.12 and predicts “No” at a 0.40 threshold. What is the rule and conclusion for a mobile-channel account with no prior cancellation? (Answer: If channel is agent or mobile and prior cancellation is No, assign probability 0.12 and predict No; the account satisfies both conditions.)
  3. A hypothetical tree reaches a leaf only after annual mileage \(>15{,}000\), followed by mileage \(\leq22{,}000\), followed by vehicle age \(\leq6\) years. The leaf predicts \$830. Write the complete rule and its simplified mileage bounds. (Answer: If mileage \(>15{,}000\), mileage \(\leq22{,}000\), and age \(\leq6\), predict \$830; equivalently, \(15{,}000<\text{mileage}\leq22{,}000\) and age \(\leq6\).)
  4. A tree’s root sends region in \(\{\text{North},\text{East}\}\) left and other regions right. The right branch splits on a risk flag: Yes goes left to a leaf predicting “Review,” and No goes right. State the rule for the Review leaf. (Answer: If region is neither North nor East and the risk flag is Yes, predict Review.)
  5. A regression-tree path requires claim count \(>1\), then claim count \(\leq3\), then policy tenure \(<5\) years. Its leaf predicts \$1,250. Does an account with 3 claims and tenure exactly 5 years satisfy the rule? (Answer: No. It satisfies \(1<\text{claim count}\leq3\), but tenure \(5\) is not \(<5\), so the complete rule does not apply.)
Clinical Biostats