A node holds 16 samples, 8 positive and 8 negative. Split A sends 6 samples (5 positive, 1 negative) left and 10 samples (3 positive, 7 negative) right. Split B 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: H(p)=−plog⁡2p−(1−p)log⁡2(1−p) where p is the positive fraction (0 for a pure node, 1 bit for an even mix). A split's information gain is H(parent)−∑knknH(childk), where nk is the number of samples in child k and n the number in the parent.

Steps

  1. Parent: p=8/16=0.5, so H(0.5)=−0.5log⁡20.5−0.5log⁡20.5=1 bit, the maximum for two classes.
  2. Split A child entropies: left has p=5/6, giving H(5/6)=−56log⁡256−16log⁡216≈0.650 bits; right has p=3/10, giving H(3/10)≈0.881 bits.
  3. Split A information gain: weight each child by its share of the 16 samples: 616(0.650)+1016(0.881)≈0.795 bits. Gain ≈1−0.795=0.205 bits.
  4. Split B information gain: by symmetry both children have H(6/8)=H(0.75)≈0.811 bits, so the weighted child entropy is 0.811 bits and the gain is ≈1−0.811=0.189 bits.
  5. Conclude: split A is chosen because 0.205>0.189. 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

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: O = “contains the word offer” and L = “contains a link”. The training set has 10 emails: 4 spam and 6 ham (not spam). Among spam, O=1 in 3 emails and L=1 in 3. Among ham, O=1 in 1 email and L=1 in 2. Using Bernoulli naive Bayes, how is a new email with O=1,L=0 classified (a) with maximum-likelihood estimates and (b) with Laplace (add-one) smoothing, and what is the posterior P(spam∣x) in each case?
Next in Supervised learning: Write the hinge loss and the logistic loss as functions of the margin m=t f(x), where t∈{−1,+1} is the label and f(x) the classifier's score, and evaluate both at m=−1,0,1,2. What does the difference in their shapes mean for the classifiers they produce?