The ID3 algorithm, short for Iterative Dichotomiser 3, is a classic method for building a decision tree from labeled categorical data by choosing, at each node, the attribute that yields the highest information gain. Published by J. Ross Quinlan in 1986, it performs a greedy, top-down search through the space of possible trees without backtracking.
In machine learning, ID3 is the direct ancestor of C4.5 and its successors and the standard teaching example of entropy-based tree induction. Its ideas also underlie the tree learners used in random forests and gradient boosting, although those rely on later variants such as CART that handle numeric features and pruning natively.
How ID3 grows a decision tree
ID3 builds the tree recursively from the root. At each node it measures how well every remaining attribute separates the training examples by class, splits on the best one, and repeats the procedure for each branch using only the examples that reached it. Each attribute is used at most once along any path from the root to a leaf.
- Compute the entropy of the class labels in the current set of examples.
- For each unused attribute, compute the information gain of splitting on it.
- Select the attribute with the largest gain and create one branch per attribute value.
- Partition the examples by value and recurse on each branch.
- Stop and create a leaf when all examples share one class, no attributes remain, or no examples reach the branch.
When a branch receives no examples, ID3 labels the leaf with the majority class of the parent node. When attributes run out while classes are still mixed, the leaf takes the majority class of its own examples. These rules are why ID3 always returns a tree that is consistent with noise-free training data.
Entropy and information gain in ID3
ID3 scores candidate splits with Shannon entropy, the expected number of bits needed to encode the class of a randomly drawn example at the node. The score is zero when one class fills the node and peaks at 1 bit for an even two-class mix, or log2 k bits for k equally frequent classes.
For each attribute, ID3 subtracts the size-weighted average entropy of the child subsets from the entropy of the parent node; the difference is the attribute’s information gain. The winning attribute is the one with the largest difference, a choice that tends to push the most informative tests toward the root and keep the tree shallow.
The table shows entropy values for a two-class node at different class mixes.
| Class split | Proportion of majority class | Entropy in bits |
|---|---|---|
| 10 / 0 | 1.00 | 0.000 |
| 9 / 1 | 0.90 | 0.469 |
| 8 / 2 | 0.80 | 0.722 |
| 7 / 3 | 0.70 | 0.881 |
| 5 / 5 | 0.50 | 1.000 |
Quinlan illustrated the method with a small dataset deciding whether conditions suit an outdoor game. There, the sky-condition attribute separates the cases far better than temperature or wind, so ID3 places it at the root and refines the remaining mixed branches with humidity and wind.
ID3 compared with C4.5 and CART
ID3 is the simplest of the three classic tree learners, and both C4.5 and CART were designed to address its gaps. The differences matter when reading older literature or choosing a library implementation.
| Property | ID3 | C4.5 | CART |
|---|---|---|---|
| Split criterion | Information gain | Gain ratio | Gini impurity or variance |
| Numeric attributes | Not supported directly | Threshold splits | Threshold splits |
| Missing values | Not handled | Fractional instances | Surrogate splits |
| Branching | One branch per value | Multiway or binary | Always binary |
| Pruning | None in the original | Error-based post-pruning | Cost-complexity pruning |
| Task types | Classification | Classification | Classification and regression |
Popular libraries such as scikit-learn implement an optimized CART, not ID3. Setting the criterion to entropy reproduces ID3’s impurity measure, but the tree still uses binary threshold splits, so the resulting structure differs from a textbook ID3 tree.
Bias toward many-valued attributes
Information gain has a well-documented flaw: it favors attributes with many distinct values. An attribute such as a customer ID splits the data into singleton subsets, each with entropy 0, so it achieves the maximum possible gain while carrying no predictive value for new cases.
Quinlan’s later C4.5 corrects this with the gain ratio, a normalized score that penalizes splits producing many small branches. Practitioners applying plain ID3 should remove identifier-like columns and group rare categories before training.
Limitations and practical remedies
Because the original ID3 grows the tree until training data is perfectly classified, it is prone to overfitting, especially with noisy labels or small samples. Its greedy search also cannot reconsider earlier splits, so it may miss a globally smaller tree. The table pairs common problems with standard fixes.
| Weakness | Consequence | Common remedy |
|---|---|---|
| No pruning | Deep trees that memorize noise | Post-pruning or minimum samples per leaf |
| Categorical inputs only | Numeric data must be binned | Discretize or switch to C4.5 or CART |
| No missing-value handling | Incomplete records are dropped | Imputation or C4.5-style weighting |
| Bias to many values | Useless identifier splits | Gain ratio or feature cleanup |
| Greedy search | Locally optimal tree only | Ensembles such as random forest |
Training cost is modest: each level scans the examples once per remaining attribute, giving roughly O(n · m · d) time for n examples, m attributes and depth d. The bigger practical issue is high variance: small changes in the data can produce a very different tree, which is why single ID3-style trees are now mostly used for interpretability and teaching rather than peak accuracy.
Stripped to the essentials
ID3 builds a flowchart of yes-or-no style questions. It learns the questions from past examples. At each step, it asks: which question sorts the examples best? It picks that one and moves on.
It measures sorting quality with a score called information gain. A good question leaves groups where almost everyone has the same answer. The process stops when each group is clean. The result is a tree that anyone can read and follow.
Where it is applied
A regional lender wants a transparent screening rule for small-business loan applications. Its analysts take 2,000 past applications described by categorical attributes: industry sector, years in business (binned into three bands), existing debt level (low, medium, high) and collateral type, each labeled as repaid or defaulted.
Running ID3 places existing debt level at the root, because it gives the largest information gain, followed by years in business on the high-debt branch. The analysts limit depth to four and require at least 30 applications per leaf to control overfitting. The final tree has 11 leaves, each a readable rule such as “medium debt and more than five years in business: low risk”. Credit officers can explain every decision to applicants and regulators, which a black-box model would not allow.