A decision tree is a classifier shaped like a questionnaire: at each node it asks a question about one feature of the case ("what is the outlook?"), follows the branch matching the answer and, on reaching a leaf, returns a class. The interesting part is not the questionnaire but that nobody writes it: the algorithm induces it from a table of labeled examples. It is the first Symbolic type in this Pokédex that learns from data.
How it works
The canonical example is the weather data that Witten et al. (2017) use throughout their book: fourteen days described by four attributes (outlook, temperature, humidity and windy) and a class, whether or not some unspecified game was played (2017, pp. 10–11). The example comes from Quinlan (1986), where the objects were "Saturday mornings" and the classes were called P and N (1986, pp. 85–86).
The algorithm is recursive: pick an attribute for the root, open one branch per value, and repeat the procedure on each branch using only the examples that reach it; stop when a node is pure, that is, when all its examples share the same class (Witten et al., 2017, pp. 105–106). The key question is which attribute to pick. ID3 uses Shannon entropy: the information, in bits, still needed to determine the class of a case that has reached that node. The root holds 9 "yes" and 5 "no," which amounts to 0.940 bits; splitting on outlook brings the expected information down to 0.693 bits. The difference, 0.247 bits, is the information gain of outlook, higher than that of humidity (0.152), windy (0.048) and temperature (0.029) (Witten et al., 2017, p. 107). So outlook is asked first; on the "sunny" branch humidity wins, and the result is the tree in the diagram (2017, p. 109).
Read with a logician's eye, the tree is a formula in disjunctive normal form: play if and only if (outlook = overcast) ∨ (outlook = sunny ∧ humidity = normal) ∨ (outlook = rainy ∧ windy = false). Each path from the root to a "yes" leaf is a conjunction; the learned concept is the disjunction of those paths. You can experiment with this in the decision-tree lab.
What changed
In expert systems, rules were obtained by interviewing specialists; here they are induced from data. ID3 was in fact born from a challenge posed by Donald Michie: to decide, from board features alone, whether a position in a chess endgame (king and rook against king and knight) was lost within a given number of moves (Quinlan, 1986, p. 84). At about the same time, four statisticians at Californian universities (Breiman, Friedman, Olshen and Stone) developed CART without knowing of Quinlan's work: a case of parallel invention in statistics and machine learning (Witten et al., 2017, p. 30).
C4.5, ID3's successor, added the gain ratio, numeric attributes, missing values, pruning and the conversion of trees into rules (Witten et al., 2017, pp. 113, 210). From the 2000s on, trees came back in herds: random forests let many randomized trees vote (2017, p. 485), and gradient boosting over trees is, according to Chollet (2021), perhaps the best algorithm available for non-perceptual data (2021, sec. 1.2.4).
Limits
- Overfitting. A tree grown until every leaf is pure fits the training set too closely. That is why almost all systems build the full tree and then prune it, replacing subtrees with leaves (Witten et al., 2017, pp. 210, 213–214).
- Many-valued attributes. An ID code for each day earns the highest possible gain (0.940 bits) and generalizes nothing; C4.5 corrects this bias with the gain ratio (Witten et al., 2017, pp. 110–111).
- Instability. A small change in the data can alter the attribute chosen at a node, and with it the whole subtree below (Witten et al., 2017, p. 481).
- Straight borders. With numeric attributes, a tree only draws decision boundaries parallel to the axes; a diagonal must be approximated by a staircase of rectangles (Witten et al., 2017, p. 251).
- Transparency that evaporates. A five-leaf tree can be read at a glance; one with thousands of nodes, or a forest of five hundred trees, cannot.