From a Tree Diagram to a Prediction Rule
A regression tree is often presented as a diagram: start at the root, answer a sequence of split questions, and stop at a terminal node. To use the tree without redrawing it, express each route as a rule: if all the conditions on a route hold, use the prediction at the terminal node that route reaches. This translation is useful for explaining a fitted tree, checking a particular prediction, and identifying exactly which predictor values lead to a given result.
The focus here is how to read the routes, not how to choose the splits. Assume a fitted binary regression tree is fixed. Each internal node tests one predictor, and its two branches divide the cases according to that test. Under the common numeric convention used in these examples, the left branch means \(X_j \le c\), and the right branch means \(X_j > c\), where \(X_j\) is a predictor and \(c\) is the node’s threshold. Always check a diagram’s stated convention before translating it.
A route with three decisions therefore has three conditions, not three alternative ways to reach the node. For example, “mileage is at most 12,000 and driving experience is at most five years” requires both conditions to hold. A case satisfying only one of them follows a different route.
Why a Path Becomes a Set of Conditions
At each split, the current cases are divided into two groups. Reaching the next node requires belonging to the selected group at that split. Reaching a terminal node requires making the selected choice at every split between the root and that terminal node. The rule is therefore an intersection of the branch conditions along the route.
Here \(m\) is the number of decisions on that path. This intersection explains why every condition must be included: omitting even one can admit cases that would leave the path at an earlier split. At a given split, the two branches are complementary. For a numeric test \(X_j \le c\), the other branch is \(X_j > c\), not \(X_j \ge c\). Consequently, each case follows exactly one branch at that node, including a case whose value equals the threshold.
When a predictor is tested more than once on the same path, collect its conditions. For example, \(X \gt 10\) at one node and \(X \le 18\) later on the route together require \(10 < X \le 18\). This simplification describes the same cases as the two original conditions; it does not change either boundary.
Worked Example: Writing Rules for a Two-Level Tree
A hypothetical insurer fits a regression tree to predict annual claim cost in dollars. The root tests annual mileage: left if mileage is at most 12,000, right if it is greater than 12,000. The left child tests years licensed: left if at most 5, right if greater than 5. The right child is terminal. The four terminal nodes have training responses as follows: for the low-mileage, shorter-tenure node, \(900, 1{,}100, 1{,}000\); for the low-mileage, longer-tenure node, \(1{,}300, 1{,}700\); for the high-mileage node, \(1{,}800, 2{,}000, 2{,}200, 2{,}000\). Translate the paths into prediction rules.
Method. For each terminal node, record every branch choice from the root. Then calculate that node’s sample mean, because this fixed tree uses squared-error predictions at its terminal nodes.
Path 1: low mileage, shorter tenure. The conditions are mileage \(\le 12{,}000\) and years licensed \(\le 5\). The node mean is \( (900+1{,}100+1{,}000)/3 = 3{,}000/3 = 1{,}000 \).
Path 2: low mileage, longer tenure. The conditions are mileage \(\le 12{,}000\) and years licensed \(>5\). The node mean is \( (1{,}300+1{,}700)/2 = 3{,}000/2 = 1{,}500 \).
Path 3: high mileage. The condition is mileage \(>12{,}000\). There is no further split on this route, so years licensed is not part of its rule. The node mean is \( (1{,}800+2{,}000+2{,}200+2{,}000)/4 = 8{,}000/4 = 2{,}000 \).
The prediction rules are therefore: mileage \(\le 12{,}000\) and years licensed \(\le 5\) gives \(\$1{,}000\); mileage \(\le 12{,}000\) and years licensed \(>5\) gives \(\$1{,}500\); mileage \(>12{,}000\) gives \(\$2{,}000\). As a check, these paths divide the cases first by the root threshold, then divide only the low-mileage group by years licensed. The high-mileage rule correctly has no tenure condition.
Common mistake avoided: Adding a years-licensed condition to the high-mileage rule would be incorrect. That branch ends at a terminal node immediately, so no such condition was tested along its path.
Trace the Route Before Simplifying It
For a particular observation, evaluate the root condition first, follow the indicated branch, and continue until a terminal node is reached. Do not choose a prediction by looking for the closest-looking leaf label: the route determines the result. After tracing it, the path rule provides a useful independent check.
Write down the predictor test and identify which of its two branch conditions the observation satisfies.
At each internal node, evaluate that node’s test using the observation’s predictor value.
Keep every selected branch condition, including conditions on predictors tested again later.
Use that node’s prediction and check that the observation satisfies every condition in its path rule.
Worked Example: Following a Path at the Threshold
A hypothetical claim-cost tree has the following structure. The root sends policies with utilization at most \(0.70\) left and those with utilization greater than \(0.70\) right. The right child is terminal with prediction \(\$2{,}400\). The left child splits on prior claims: at most 1 goes to a terminal node with prediction \(\$800\), and greater than 1 goes to a second split on deductible. At that second split, a deductible at most \(\$1{,}000\) leads to prediction \(\$1{,}600\); a deductible greater than \(\$1{,}000\) leads to prediction \(\$2{,}100\). Find the prediction for a policy with utilization \(0.70\), 2 prior claims, and a \(\$1{,}000\) deductible, and state its path rule.
Root. Since \(0.70 \le 0.70\), the policy follows the left branch. Equality belongs to the “at most” branch.
Prior claims. Since \(2>1\), it follows the branch to the deductible split.
Deductible. Since \(\$1{,}000 \le \$1{,}000\), it reaches the terminal node with prediction \(\$1{,}600\).
The complete path rule is: utilization \(\le 0.70\), prior claims \(>1\), and deductible \(\le \$1{,}000\) gives a predicted annual claim cost of \(\$1{,}600\). Checking the recorded values against the three conditions confirms that the policy satisfies the rule.
Common mistake avoided: Sending the policy to the greater-than branch because its utilization equals \(0.70\) would reverse the boundary convention. The root’s right branch requires a value strictly greater than \(0.70\).
Combine Repeated Conditions Carefully
A path may test the same predictor at multiple nodes. Its rule must retain all those tests, but they can often be combined into a single interval. This is particularly helpful when explaining which predictor values lead to a terminal node. A condition that is not tested on the path should not be added merely because the predictor appears elsewhere in the tree.
Categorical splits can be translated in the same way. If a node sends categories in \(\{\text{North},\text{West}\}\) left, then the right branch takes the remaining categories represented at that node, such as \(\{\text{Central},\text{South}\}\). The rule uses membership in the specified set rather than a numeric inequality. When translating such a split, use the categories and branch labels shown in the tree.
Worked Example: Combining Repeated Conditions and Checking a Prediction
A hypothetical tree predicts a portfolio’s annual claims cost. At the root, risk score \(\le 650\) goes left and risk score \(>650\) goes right. On the right, a split sends scores \(\le 780\) to a terminal node with prediction \(\$3{,}100\); scores \(>780\) go to another split on income, where income \(\le \$90{,}000\) predicts \(\$4{,}200\), and income \(>\$90{,}000\) predicts \(\$5{,}600\). On the left, tenure \(\le 4\) predicts \(\$1{,}200\); tenure \(>4\) proceeds to a split on vehicle value, with value \(\le \$25{,}000\) predicting \(\$1{,}800\) and value \(>\$25{,}000\) predicting \(\$2{,}400\). Translate all five terminal paths. Then find the prediction for a portfolio with risk score 740, income \(\$82{,}000\), tenure 6, and vehicle value \(\$30{,}000\).
Left-side paths. The first terminal path is risk score \(\le 650\) and tenure \(\le 4\), predicting \(\$1{,}200\). The next two paths are risk score \(\le 650\), tenure \(>4\), and vehicle value \(\le \$25{,}000\), predicting \(\$1{,}800\); or vehicle value \(>\$25{,}000\), predicting \(\$2{,}400\). Each left-side rule retains the root condition and every condition tested after it.
Middle right-side path. The score must first be \(>650\), then \(\le 780\). Combining those conditions gives \(650 < \text{risk score} \le 780\), with prediction \(\$3{,}100\).
Upper right-side paths. The score must be \(>650\) and \(>780\), which simplifies to risk score \(>780\). If income is \(\le \$90{,}000\), the prediction is \(\$4{,}200\); if income is \(>\$90{,}000\), it is \(\$5{,}600\).
Trace the specified portfolio. Its risk score \(740\) is \(>650\), so it goes right at the root. Since \(740 \le 780\), it reaches the terminal node with prediction \(\$3{,}100\). The income, tenure, and vehicle-value values are not tested on this route and do not alter the prediction. The applicable combined rule is \(650 < \text{risk score} \le 780\), which the score 740 satisfies.
Check. The five rules account for the tree’s five terminal nodes. The repeated risk-score conditions combine without changing the boundary: a score of 650 is on the left side, while a score of 780 is in the middle right-side interval.
Common Translation Traps
- Reversing equality. If the left branch is \(X_j \le c\), equality goes left. The complementary right branch is \(X_j > c\).
- Dropping an earlier condition. A lower split only applies to cases that reached that node. Include the conditions that led there as well as the new split.
- Treating conditions as alternatives. A path is a conjunction: all its conditions must hold.
- Adding conditions not on the route. A predictor used on a different branch does not restrict this path.
- Combining ranges incorrectly. When a path requires \(X>650\) and \(X\le780\), the result is \(650<X\le780\), not \(650\le X\le780\).
- Confusing a branch rule with its prediction. The conditions identify which terminal node applies; the prediction is the value attached to that node.
A useful final check is to take one observation satisfying each proposed rule and mentally follow it from the root. If it reaches a different terminal node, a condition or boundary has been mistranslated. Also check that rules branching from the same node use complementary conditions; this helps detect gaps and overlaps.
Check Your Understanding
For each problem, write or apply the path conditions using the stated branch convention.
- A tree’s root sends duration \(\le 8\) left and \(>8\) right. The left child splits on channel: “online” is terminal with prediction 12, and “agent” is terminal with prediction 16. The right child predicts 20. State all three path rules and identify the prediction for duration 8 through the online channel. (Answer: duration \(\le8\) and online gives 12; duration \(\le8\) and agent gives 16; duration \(>8\) gives 20; the specified case predicts 12.)
- At the root, balance \(\le 40\) goes left and \(>40\) goes right. The right child splits again on balance, sending values \(\le 75\) to a terminal node predicting 30 and values \(>75\) to one predicting 45. State the simplified rules and the prediction at balance 75. (Answer: balance \(\le40\) goes left; \(40<\text{balance}\le75\) predicts 30; balance \(>75\) predicts 45; balance 75 predicts 30.)
- A tree splits first on distance, with \(\le 15\) left and \(>15\) right. The left child predicts 500 if account age is \(\le3\), and 700 otherwise. The right child predicts 900. Give the rules and predict for distance 12 and account age 4. (Answer: distance \(\le15\) and account age \(\le3\) predicts 500; distance \(\le15\) and account age \(>3\) predicts 700; distance \(>15\) predicts 900; the specified case predicts 700.)
- A root sends utilization \(\le0.60\) left and \(>0.60\) right. The right child sends utilization \(\le0.85\) to a node predicting 1,100; above 0.85, a tenure split sends tenure \(\le5\) to 1,500 and tenure \(>5\) to 1,900. State the right-side rules and predict for utilization 0.85 and tenure 7. (Answer: \(0.60<\text{utilization}\le0.85\) predicts 1,100; utilization \(>0.85\) and tenure \(\le5\) predicts 1,500; utilization \(>0.85\) and tenure \(>5\) predicts 1,900; the specified case predicts 1,100.)
- A root sends score \(\le500\) left and \(>500\) right. The left child predicts 400. The right child splits on score again: values \(\le700\) predict 800; values \(>700\) split on segment, where segment A predicts 1,200 and all other segments predict 1,600. State the right-side rules and find the prediction for score 720 in segment B. (Answer: \(500<\text{score}\le700\) predicts 800; score \(>700\) and segment A predicts 1,200; score \(>700\) and segment not A predicts 1,600; the specified case predicts 1,600.)