Concepts / Prediction Labels

Prediction Labels

A decision tree follows an instance from a root node to a leaf.

  • Programming

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.

rule selects childcontinue until leafRoot nodeFirst splitting ruleSelected childNext visited nodeLeafStored label
What happens as an instance moves from the root node to 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.

one rule resultanother rule resultFeature testSplitting ruleChild ASelected for one resultChild BSelected for another result
How does the result of a splitting rule determine the next step?
  • 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.

evaluateoutside stated rangePapayaColor and softnessColorFirst testNot-tastyLeaf label
For a papaya whose color is outside the stated range, how do successive decisions lead to its predicted label?

What do you think happens?

A papaya has a color outside the stated range. Which label does the tree predict?

  • tasty
  • not-tasty
  • The tree cannot produce a label
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.

reachesprovidesCompleted pathInstance reaches leafnot-tastyFinal predictionLeafStored label
How does reaching a leaf turn the completed path into a final prediction label?

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

MEDIUM

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

  1. A decision tree starts prediction at a root node.
  2. Each splitting rule chooses which child to visit next.
  3. The tree may apply another rule at the selected child.
  4. Traversal ends when the instance reaches a leaf.
  5. 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.