Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Making ID3 practical
Real data have temperatures, not just “hot/mild/cool”. They have sensor readings that are sometimes missing, and identifier-like columns that fool ID3. C4.5 keeps ID3’s recipe (pick the most informative question, recurse) and adds four upgrades:
- it normalises the gain so many-valued attributes lose their unfair advantage;
- it tries thresholds such as “temperature ≤ 58°” for continuous readings;
- it lets examples with missing values flow down every branch in proportion;
- it prunes the finished tree.
C4.5 produced readable, accurate rule sets from messy engineering data for decades, and C5.0 is still used in industry. Its handling of thresholds and missing values is the template every tree library follows, and knowing its assumptions explains when trees mishandle sensor dropouts.
- 1. C4.5 handles a continuous attribute by…
- 2. Gain ratio divides gain by…
- 3. A case with a missing split value in C4.5…
Level 1: Beginner
★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.The extensions by hand
Gain ratio. Split information is the entropy of the branch sizes. For outlook (5, 4, 5 of 14):
SI = −2·(5/14)·log₂(5/14) − (4/14)·log₂(4/14) = 1.061 + 0.516 = 1.577 bits.
Gain ratio = 0.247/1.577 = 0.156. A day-ID has SI = log₂ 14 = 3.807 and gain ratio 0.940/3.807 = 0.247. That is still higher, which is why C4.5 adds two rules:
- consider only attributes whose gain is at least the average gain;
- accept only splits where at least two branches hold at least 2 cases. The ID split fails this.
A continuous threshold. On the five sunny days the humidities are 70 (yes), 70 (yes), 85 (no), 90 (no) and 95 (no).
- Candidate cuts are the midpoints 77.5, 87.5 and 92.5.
- The cut at 77.5 separates yes from no perfectly. Its gain is the full entropy of the sunny subset, 0.971.
- Only midpoints between neighbouring distinct values need checking, because gain changes only when a case crosses the cut.
Missing values. Suppose 2 of 14 humidities are missing.
- C4.5 computes the gain on the 12 known cases and multiplies by F = 12/14.
- When splitting, each case with a missing value goes down both branches, with weights equal to the branches’ shares of known cases (for example 0.6 and 0.4).
- At prediction time the class distributions from all branches are blended with the same weights.
The steps in plain English:
- For each attribute, compute gain on the known cases (thresholds for continuous ones), scaled by F.
- Keep the valid splits with at least average gain, and choose the one with the highest gain ratio.
- Split, sending cases with missing values down every branch with fractional weights, and recurse.
- Prune bottom-up wherever replacing a subtree by a leaf does not raise the pessimistic error estimate.
- 1. Split information of two equal branches?
- 2. Candidate thresholds for values 2, 5, 9?
- 3. With 3 of 20 values missing, gain is multiplied by…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.C4.5 in full
Split selection. For each attribute A, compute Gain(A) = F·(H(known) − Σ size-weighted child entropy). Among valid splits with Gain(A) at least the average over attributes, choose the largest GainRatio(A) = Gain(A)/SplitInfo(A). In SplitInfo the missing cases form an extra “branch”.
Continuous attributes. Sort the values and evaluate each midpoint (C4.5 reports the largest training value not exceeding it). This costs O(n log n) per attribute per node with cumulative class counts. Later versions add an MDL-style correction, log₂(number of candidate cuts)/n, to the gain, because continuous attributes get many chances to look good (Quinlan, 1996).
Missing values.
- Training: fractional cases, with weights multiplied down the tree.
- Prediction: blend the leaf distributions reachable along every branch for the unknown attribute.
Pruning (error-based). At a node with N cases and E errors, estimate the error rate by the upper limit of a binomial confidence interval (confidence factor CF = 25%). Replace a subtree by a leaf, or by its most-used branch, if that does not increase the estimated errors. This is pessimistic pruning on the training data itself, with no validation set.
C5.0 additions. Boosting (trials), misclassification costs, winnowing of attributes, rule sets, and large speed and memory gains.
| ID3 | C4.5 | CART | |
|---|---|---|---|
| Criterion | gain | gain ratio | Gini or variance |
| Splits | multiway | multiway (categorical), binary (continuous) | binary |
| Missing values | no | fractional cases | surrogate splits |
| Pruning | χ² pre-pruning | error-based (CF) | cost-complexity + CV |
- 1. C4.5 considers gain ratio only for attributes with…
- 2. C4.5's pruning uses…
- 3. CART handles missing values with…
Level 3: Advanced
★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.Theory
Why gain ratio needs guards. SplitInfo can be tiny when one branch holds almost every case, which makes the ratio huge for a nearly useless split. Requiring at least average gain removes such splits, and the minimum branch size removes ID-like splits. Gain ratio still prefers unbalanced splits in some cases. Kononenko (1995) and White and Liu (1994) analysed these biases, and later work favoured binary splits with statistical corrections (conditional inference trees, Hothorn et al., 2006).
Missing-data mechanisms (Rubin, 1976).
- MCAR: missingness is unrelated to anything. Most strategies work, with some loss of efficiency.
- MAR: missingness depends on observed variables.
- MNAR: missingness depends on the missing value itself.
C4.5’s fractional cases implicitly assume that a case with a missing value behaves like the known cases at that node, a MAR-type assumption. Under MNAR that is wrong, and the fact of being missing is itself information. Exercise 2: with a sensor that drops out when it reads high, treating “missing” as a value beat C4.5’s fractional cases by 9 points.
Pessimistic pruning critique. The CF bound is a heuristic and has no rigorous statistical meaning (the data are not independent of the tree they built). It works reasonably in practice, but cross-validated cost-complexity pruning is better founded.
Interview questions.
- When is “missing” informative? When the mechanism depends on the value or the situation: saturated sensors, skipped tests, safe-mode telemetry gaps. Encode a missing indicator or let the tree route missing values.
- Why do modern libraries (XGBoost, LightGBM) learn a default direction for missing values? It lets the data decide where missing cases go, which captures MNAR effects cheaply.
- 1. If a sensor drops out mostly when its value is high, the data are…
- 2. C4.5's fractional cases assume missing cases behave like…
- 3. XGBoost handles missing values by…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Missing sensor data: at random versus informative
History.
- Quinlan’s C4.5: Programs for Machine Learning (1993) followed ID3 and its intermediate versions.
- “Improved use of continuous attributes in C4.5” (1996) added the MDL correction for thresholds.
- C5.0 (RuleQuest, 1997; open-sourced 2011) added boosting and costs.
- C4.5 topped the 2008 IEEE ICDM survey of the top 10 data-mining algorithms.
- The Weka implementation, J48, made it a default teaching and research tool.
Exercise 1.
- Outlook has gain 0.2467 and gain ratio 0.1564.
- A day-ID gets gain ratio 0.2470, but its split is invalid (no branch holds 2 cases).
- On sunny days, humidity ≤ 77.5 gives gain 0.9710.
- With 2 of 14 humidities missing, the gain on the 12 known cases is scaled by 12/14 to 0.3486. A case with unknown humidity gets the blended P(yes) = 0.534.
Exercise 2. Setup: a rule on 5 telemetry features with 5% label noise, and 30% of the key feature missing in training and test data. A depth-6 C4.5-style tree throughout, with accuracy against the noise-free rule over 10 repetitions.
| Strategy | MCAR | MNAR (missing when high) |
|---|---|---|
| C4.5 fractional cases | 0.906 | 0.834 |
| mean imputation | 0.914 | 0.909 |
| drop incomplete training rows | 0.912 | 0.842 |
| missing as a value (sentinel) | 0.910 | 0.925 |
- Under MCAR the strategy hardly matters. All four were within 1 point.
- Under MNAR, “missing” is itself a strong signal that x₀ is high. Strategies that let the tree isolate missing cases won: the sentinel, and also mean imputation, since every missing case gets the same value and the tree can carve it out with two thresholds.
- Fractional cases and row deletion lost 8–9 points. Both treat missing cases as if they resembled the observed ones.
- Lesson: before choosing a missing-value strategy, ask why the data are missing. Add explicit missing indicators when in doubt.
C4.5 in AI, robotics and aerospace
- Diagnostic rule sets from maintenance and anomaly databases (C5.0 rule output).
- Telemetry with dropouts: choose missing-value handling by mechanism (saturation, safe mode, link loss).
- Feature thresholds that engineers can verify (“bus voltage ≤ 27.4 V”).
- J48 in Weka remains a standard baseline in applied ML papers.
References
- J. R. Quinlan (1993). C4.5: Programs for Machine Learning. Morgan Kaufmann.
- J. R. Quinlan (1996). “Improved use of continuous attributes in C4.5.” Journal of Artificial Intelligence Research 4.
- D. B. Rubin (1976). “Inference and missing data.” Biometrika 63(3).
- I. Kononenko (1995). “On biases in estimating multi-valued attributes.” IJCAI.
- X. Wu et al. (2008). “Top 10 algorithms in data mining.” Knowledge and Information Systems 14.