• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

Without stopping conditions, a decision tree would keep splitting until every leaf contains exactly one training instance — creating a tree that perfectly memorizes the training data but fails completely on new data. The algorithm must know when to stop growing.

Core Idea

Stopping conditions are the criteria that determine when a node should become a leaf rather than continuing to split. The three primary conditions from the source are: (1) all instances share the same class, (2) no attributes remain to split on, and (3) no instances reach the node.

How It Works

Three stopping conditions are evaluated at each node during recursive tree building:

  1. All same class (purity): If all training instances at the node belong to one class, label the node with that class (“yes” or “no”) and stop. No further splitting can improve purity.

  2. No attributes remaining: If all features have been used on the path from root to this node, no more splits are possible. Label the node with a majority vote of the training instances remaining at that node.

  3. No instances: If the node receives zero training instances (because no training example matched the path to this node), label the node with a majority vote of the parent node’s training instances — using the parent’s context as the best available prior.

Additional practical conditions (not in source but commonly used):

  • Maximum depth: Stop when the tree reaches a pre-specified depth limit
  • Minimum samples: Stop when the node has fewer than a threshold number of instances
  • Minimum impurity decrease: Stop when no attribute provides a meaningful purity improvement

The source explicitly states: “If all positive or all negative training instances remain, label that node ‘yes’ or ‘no’ accordingly.”

Visual Explanation

digraph stopping_conditions {
    rankdir=TB
    node [shape=box style=filled fontname="Helvetica" fontsize=11]
    edge [fontname="Helvetica" fontsize=10]
 
    node [label="Current Node\n(Being evaluated)" fillcolor="#cce5ff"]
    check1 [label="Check 1: All same class?" fillcolor="#e8d5f5" shape=diamond]
    check2 [label="Check 2: No attributes left?" fillcolor="#e8d5f5" shape=diamond]
    check3 [label="Check 3: No instances?" fillcolor="#e8d5f5" shape=diamond]
    leaf1 [label="Leaf: label with class" fillcolor="#d4edda" shape=diamond]
    leaf2 [label="Leaf: majority vote" fillcolor="#ffcccc" shape=diamond]
    leaf3 [label="Leaf: parent's majority vote" fillcolor="#ffcccc" shape=diamond]
    continue [label="Continue splitting\n(recurse)" fillcolor="#ffd700"]
 
    node -> check1 -> check2 -> check3
    check1 -> leaf1 [label="Yes"]
    check1 -> check2 [label="No"]
    check2 -> leaf2 [label="Yes"]
    check2 -> check3 [label="No"]
    check3 -> leaf3 [label="Yes"]
    check3 -> continue [label="No"]
}

Key Properties

  • Necessary for termination: Without stopping conditions, recursion would not terminate
  • Prevent overfitting: Stopping before perfect purity avoids memorizing training noise
  • Hierarchical: Conditions are checked in order; earlier conditions take precedence
  • Fallback logic: Each condition has a default labeling strategy (class, majority vote, parent’s vote)

Connections

Edge Cases & Gotchas

  • Premature stopping: Too aggressive conditions produce shallow, underfit trees
  • Late stopping: Too lenient conditions produce deep, overfit trees
  • Empty node paradox: When no instances reach a node, the prediction is essentially a guess based on the parent
  • Attribute reuse: Some implementations allow reusing attributes, which can prevent the “no attributes” condition from ever triggering