Prediction Labels
A decision tree follows an instance from a root node to a leaf.
From Instance to Label
A decision tree is a predictor that determines a label for an instance by moving through a tree. The process starts at a root node, applies the splitting rule at that node, and follows the selected child. The tree repeats this process until it reaches a leaf. The label stored in that leaf is the prediction.
A prediction is not produced at the root merely because the tree begins there. The prediction is produced when the path reaches a leaf containing a label.
Following the Tree Path
Think of prediction as following directions. The instance arrives at the root node. A splitting rule examines a feature of that instance and determines which child should be visited next. The chosen child becomes the next point on the path. This continues from node to node until the path ends at a leaf.
Splitting Rules Choose Children
At each visited decision node, the tree applies a splitting rule to the instance. The result of that rule determines which child is visited next. If the selected child is another decision node, the tree applies another rule. If the selected child is a leaf, the traversal ends and the leaf's stored label becomes the prediction.
- Start with the instance at the root node.
- Apply the splitting rule at the current node.
- Move to the child selected by the rule.
- Repeat the process if the child is another decision node.
- Use the label stored in the reached leaf as the final prediction.
Papaya Classification Trace
The papaya example uses color first and softness second to predict either tasty or not-tasty. Color is examined at the first decision point. Only when the color is within the stated range does the tree continue to a softness test. If the color condition sends the instance directly to the not-tasty leaf, the tree stops there and does not perform the softness test.
What do you think happens?
A papaya has a color outside the stated range. Which label does the tree predict?
Reveal answer
Answer: not-tasty
The color condition sends the instance directly to the not-tasty leaf, so the tree stops there and does not need to test softness.
What the Leaf Contributes
A leaf is the endpoint of the decision path. It does not select another child because traversal has finished there. Instead, the leaf contains the label that the tree predicts for the instance that reached it. In the papaya example, reaching the not-tasty leaf produces the not-tasty prediction.
The completed path explains how the tree made its decision, but the reached leaf supplies the final label.
Common Tracing Mistakes
Treating the first splitting rule as the prediction
A splitting rule only determines which child is visited next.
Fix:
Follow the selected child until a leaf is reached, then read the label stored in that leaf.Continuing to test features after reaching a leaf
A leaf is the endpoint of the path, so no additional decision is needed.
Fix:
Stop traversal as soon as the instance reaches a leaf.Reading a label from an unvisited branch
Only the path selected by the instance's feature values determines its prediction.
Fix:
Record each rule result and follow only the corresponding successor child.
Practice the Path
Trace a papaya through the decision tree. Its color satisfies the condition that allows the tree to continue to the softness test. Write the sequence of decisions in order, then identify where the final prediction comes from.
Hints
- Begin with the color test because it is examined first.
- If the color condition allows continuation, move to the softness test.
- The final answer comes from the leaf reached after the relevant tests.
To check your reasoning, make sure your trace distinguishes the tests from the label. Color and softness are feature checks used to choose children. The final prediction is the label stored in the leaf reached after those choices.
Prediction Checklist
- A decision tree starts prediction at a root node.
- Each splitting rule chooses which child to visit next.
- The tree may apply another rule at the selected child.
- Traversal ends when the instance reaches a leaf.
- The label stored in that leaf is the final prediction.
Key Takeaways
- A decision tree predicts a label by following an instance from the root node to a leaf.
- Splitting rules select successor children; they do not directly provide the final label.
- A leaf ends the traversal and contains the prediction label.
- In the papaya example, an out-of-range color sends the instance directly to the not-tasty leaf, so softness is not tested.