A node holds 16 samples, 8 positive and 8 negative. Split sends 6 samples (5 positive, 1 negative) left and 10 samples (3 positive, 7 negative) right. Split sends 8 samples (6 positive, 2 negative) left and 8 samples (2 positive, 6 negative) right. What is the information gain (using base-2 entropy) of each split, and which split is chosen?
Supervised learning, Decision trees
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can compute binary entropy and information gain by hand and weight each child by its sample fraction.
Key idea
Entropy measures how mixed a node is: where is the positive fraction ( for a pure node, bit for an even mix). A split's information gain is , where is the number of samples in child and the number in the parent.
Steps
- Parent: , so bit, the maximum for two classes.
- Split child entropies: left has , giving bits; right has , giving bits.
- Split information gain: weight each child by its share of the 16 samples: bits. Gain bits.
- Split information gain: by symmetry both children have bits, so the weighted child entropy is bits and the gain is bits.
- Conclude: split is chosen because . Its left child is almost pure, which outweighs its more mixed right child (Gini impurity uses the same weighted-average rule without logarithms).
Common mistakes
- Averaging the child entropies without weighting them by .
- Mixing and . Either base works if you use it throughout.
- Assuming a split with one very pure child always loses to two balanced splits; weighting by can favour creating a nearly pure child.
How long your answer should be
A small table of numbers; 3–4 minutes.
Read this
Previous in Supervised learning: A spam filter uses two yes/no features: = “contains the word offer” and = “contains a link”. The training set has 10 emails: 4 spam and 6 ham (not spam). Among spam, in 3 emails and in 3. Among ham, in 1 email and in 2. Using Bernoulli naive Bayes, how is a new email with classified (a) with maximum-likelihood estimates and (b) with Laplace (add-one) smoothing, and what is the posterior in each case?
Next in Supervised learning: Write the hinge loss and the logistic loss as functions of the margin , where is the label and the classifier's score, and evaluate both at . What does the difference in their shapes mean for the classifiers they produce?