Concepts / ID3 Decision Tree Learning

ID3 Decision Tree Learning

Decision tree learning searches for a tree that minimizes the relevant bound, but solving that search exactly is computationally hard.

  • Programming

The Search Problem

ID3 is a practical approach to decision tree learning. Its goal is related to finding a tree that minimizes the relevant bound, but directly searching for the best complete tree is computationally hard. A learner would need to consider many possible tree structures and split choices rather than only one immediate decision.

Because the exact search is difficult, ID3 does not normally examine every possible complete tree and then select a perfect one. Instead, it grows a tree step by step. At each stage, it evaluates possible actions at the current part of the tree and chooses a locally preferred action according to a gain-based heuristic.

requires consideringleads toproducesBest complete treeFirst split choicecandidate featureNext split choicesdifferent branchesComplete treealternativesmany possible structures
How does the learning problem expand when different complete tree structures and split combinations must be considered?

The Initial Root Leaf

The practical construction begins with a single root leaf. This leaf represents the training examples that currently reach the starting point of the tree. Before any feature-based decision has been made, the learner assigns the leaf the majority label of those examples.

replace by selected splitoutcomeoutcomeRoot leafmajority labelChild branchfeature outcomeDecision structureselected featureChild branchfeature outcome
What does the tree contain before a split, and what replaces the labeled leaf after a feature-based split is selected?

Comparing Candidate Splits

Gain is a measure used to compare the improvement offered by candidate splits. The gain procedure receives a training set and a feature index, then evaluates the gain of splitting according to that feature.

This turns different feature-based decisions into comparable candidates. ID3 can evaluate the available choices at the current stage, identify the candidate with the strongest gain according to the criterion, and use that candidate as the next action. The gain value guides the current comparison; it does not prove that the resulting complete tree will be globally optimal.

chosen by comparisonnot chosenFeature Ahigher gainSelected splitlocally best candidateFeature Blower gain
How does ID3 compare candidate attributes and choose the next split?

Greedy Tree Growth

ID3 uses greedy construction. At the current stage, it chooses a locally best action: select a promising split according to gain, or choose not to split. When a split is selected, the current leaf is replaced by a decision structure whose branches represent the outcomes of the selected feature-based split.

After the replacement, the learning procedure can continue evaluating the leaves in the growing tree. In this way, the tree is built through a sequence of local decisions rather than through an exhaustive examination of every complete tree.

evaluatecompare gainif splitcontinue growingLabeled leafmajority labelCandidate splitscompare gainLocal choicesplit or do not splitChild branchesfeature outcomesGrowing treeevaluate leaves again
What happens to a labeled leaf, its candidate splits, and its branches as ID3 grows the tree?

A Split in Action

Choosing the Next Feature

A current leaf has a majority label. Two available features, Feature A and Feature B, are possible ways to replace that leaf with a decision structure. Their gain values are compared at this stage.

Start with the leaf: The current collection of training examples is represented by one leaf, and that leaf already has the majority label.

Evaluate candidates: The gain procedure evaluates the possible split according to Feature A and according to Feature B, turning both feature-based decisions into comparable candidates.

Choose the local action: Suppose Feature A has the stronger gain in this current comparison. ID3 selects Feature A as the next split rather than Feature B.

Replace the leaf: The labeled leaf is replaced by a decision structure whose branches represent the outcomes of Feature A.

Continue: The learner can now evaluate the resulting leaves as the tree continues to grow.

The example shows the local mechanism of ID3: begin with a labeled leaf, compare candidate gains, choose the locally best split, replace the leaf, and continue evaluating the growing tree.

The example uses Feature A and Feature B only to illustrate the selection process. The important point is not a particular feature name or numerical gain. It is that gain supplies a current comparison, while the complete search problem remains computationally hard.

Local Choice and Global Quality

A locally best split is the action that looks best under the gain criterion at the current stage and current leaf. A globally optimal tree is the best complete tree under the overall search objective. These are different ideas.

Choosing the strongest current gain does not promise that every later branch will produce the best possible complete structure. ID3 accepts this trade-off because constructing the tree through local decisions is practical, whereas finding the globally best tree directly is computationally hard.

build step by steprequires findingLocally best splitbest current gainTree after localchoicenot guaranteed globallybestGlobally optimaltreebest complete structureComplete searchcomputationally hard
How can the best current split differ from the best possible complete tree?

Common Misunderstandings

  • Treating the majority label and the split choice as the same operation.

    The majority vote gives the current leaf a prediction. Gain is separately used to evaluate whether a split should replace that leaf.

    Fix: First identify the label of the current leaf, then compare candidate splits using gain.

  • Assuming that the highest current gain guarantees the globally optimal tree.

    Gain is a criterion for the current comparison, not a promise about the entire tree.

    Fix: Describe the selected feature as locally best at the current stage, while remembering that the complete optimization problem is computationally hard.

  • Imagining that ID3 first lists every complete tree.

    Practical tree learning grows the tree step by step because directly searching all complete trees is computationally hard.

    Fix: Trace the greedy process: evaluate current candidates, choose a local action, replace a leaf if splitting is selected, and continue.

  • Forgetting that a split replaces a leaf with branches.

    After a split, the single leaf is replaced by a decision structure whose branches represent outcomes of the selected feature-based split.

    Fix: Track the structural change from one labeled leaf to a decision structure with child branches.

Practice the Trace

EASY

Trace one ID3 growth step in your own words. Start with a single leaf labeled by majority vote. Then describe what happens when two candidate features are evaluated, one receives the stronger gain, and that feature is selected for splitting.

Hints
  • Name the operation that assigns the leaf its initial label.
  • Explain what the gain comparison receives and evaluates.
  • State why the selected feature is only locally best.
  • Describe what replaces the leaf after the split.

What do you think happens?

After ID3 selects a feature-based split for the current labeled leaf, does the original leaf remain as the same unsplit node?

  • Yes, the split only records an additional label.
  • No, the leaf is replaced by a decision structure with branches.
  • Yes, because gain only changes the leaf's majority label.
Reveal answer

Answer: No, the leaf is replaced by a decision structure with branches.

The selected split replaces the single leaf, and the branches represent outcomes of the selected feature-based split. The learner can then continue evaluating leaves in the growing tree.

Key Takeaways

  1. Finding a globally optimal decision tree is computationally hard because the search involves possible complete tree structures and split combinations.
  2. ID3 begins with one root leaf representing the current training examples and assigns that leaf the majority label.
  3. Gain compares the improvement offered by candidate feature-based splits.
  4. The algorithm grows the tree greedily by making a locally best choice at the current stage or choosing not to split.
  5. A locally best split is not a guarantee of a globally optimal complete tree.

Key Takeaways

  • ID3 avoids exhaustive search for a complete optimal tree because that search is computationally hard.
  • The construction starts with a majority-labeled root leaf.
  • Gain makes candidate splits comparable at the current stage.
  • Greedy growth replaces selected leaves with decision structures and continues evaluating the resulting leaves.
  • The best current split may not produce the globally best complete tree.