A node has 12 samples, 6 of each class. Attribute takes 12 distinct values (one per sample). Attribute splits the samples into two groups of 6: (5 positive, 1 negative) and (1 positive, 5 negative). Compute the information gain and the gain ratio of both attributes. Which one does ID3 pick and which does C4.5 pick, and why?
Supervised learning, Decision trees: gain ratio
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you see why information gain favours many-valued attributes and how the gain ratio corrects it.
Key idea
Gain ratio , where is the entropy of the split sizes. It penalises attributes that cut the data into many small pieces.
Steps
- Parent entropy: bit, because the classes are 6 and 6.
- Attribute : each child has one sample, so is pure and has entropy 0. Gain . SplitInfo . Gain ratio .
- Attribute : each child has proportion and . Entropy . Gain .
- SplitInfo of . Gain ratio .
- ID3 uses the gain, so it picks (1.0 against 0.35). This is useless: a tree on an ID column memorises the training set and cannot generalise.
- C4.5 uses the gain ratio, so it picks (0.350 against 0.279). Real C4.5 also keeps only attributes whose gain is at least the average, to stop a tiny SplitInfo inflating the ratio. Here the average gain is , which would wrongly keep only , so this toy example uses the plain gain-ratio rule to show the idea.
Common mistakes
- Computing SplitInfo from the class labels instead of from the sizes of the children.
- Forgetting that the ratio can be unstable when SplitInfo is close to 0.
- Thinking gain ratio removes the bias completely. It reduces it but can then favour very unbalanced splits.
How long your answer should be
Half a page; 4 minutes.
Last checked on 4 December 2026.
Read this
Previous in Supervised learning: A node has 10 samples, 6 positive and 4 negative. A split sends 5 samples left (4 positive, 1 negative) and 5 right (2 positive, 3 negative). What is the Gini impurity of the parent and of the two children, and what is the Gini gain of the split?
Next in Supervised learning: Take the Gaussian (RBF) kernel on the 1-D points . Write the Gram matrix. What happens to the Gram matrix when the width is made very small and when it is made very large, and what does that mean for an SVM?