2.3.2 · D5Tree-Based & Instance Methods

Question bank — Entropy and information gain

1,493 words7 min readBack to topic

Every item below targets a specific misconception or boundary case. The four sections are True/False, Spot the error, Why questions, and Edge cases.


True or false — justify

Higher entropy always means a worse feature to split on.
False. Entropy of the parent is fixed; what matters is the weighted child entropy and the resulting information gain. A messy single child can still belong to a high-gain split.
If a child node has higher entropy than its parent, the split was invalid.
False. One child can exceed the parent, but the weighted average of all children never does — that is why gain is by concavity.
Information gain can be negative for a badly chosen feature.
False. By concavity of , the weighted child entropy never beats the parent, so the worst case is , never negative.
Switching from to changes which feature the tree picks.
False. Changing base multiplies every entropy by the same constant , so it rescales all gains equally and the ranking of splits is unchanged. Only the numbers differ.
Entropy of means the node has exactly one example.
False. It means the node is pure — every example shares one class. It could hold a thousand examples, all "Yes".
A node with 4 Yes and 4 No has the same entropy as one with 40 Yes and 40 No.
True. Entropy depends only on the proportions , not the raw counts, so both are 50/50 giving bit.
Maximum binary entropy is always regardless of log base.
False. It is only with . With the max is ; the max is base-dependent even though the location is not.
Gini impurity and entropy always select the same split.
False. They usually agree because both are concave impurity measures, but on some distributions they disagree — they are different functions, only similarly shaped.
Information gain is unbiased across features with different numbers of values.
False. It is biased toward high-cardinality features, since splitting into many tiny pure groups inflates gain artificially.

Spot the error

", and since a pure node has for one class and for the rest, its entropy is undefined because is undefined."
The terms use the convention (its limit as ), so they vanish. The term gives . Entropy is a clean , not undefined.
"Gain = parent entropy − sum of child entropies."
Missing the weights. It must be parent entropy minus the weighted sum ; without weights you could get a negative or meaningless number.
"An ID column gives huge information gain, so it's the best feature to split on."
An ID splits into singletons, each perfectly pure, so gain is near-maximal but useless — it memorises rows and generalises to nothing. Use Gain Ratio to penalise this.
"Entropy uses a logarithm because logarithms happen to grow slowly."
The real reason is that is the only continuous function turning independent multiplication into addition: . Slow growth is incidental, not the motivation.
"A split with the lowest weighted child entropy is not necessarily the highest-gain split."
This is actually correct — the parent entropy is the same constant for all candidate features, so lowest weighted child entropy is equivalent to highest gain. The claim as written is the error.
"Gini impurity ranges from 0 to 1, so it's on the same scale as binary entropy."
For two classes Gini maxes at (at : ), not . Only entropy hits bit at 50/50; the scales differ.
"Since gain can be zero, a zero-gain split means the feature is random noise."
Not necessarily. Gain is when every child has the same class proportions as the parent — the feature simply carries no information about the label here, which can be a property of this data, not proof of noise.

Why questions

Why do we weight child entropies by instead of averaging them equally?
Because a random example lands in child with probability ; the weighted sum is the expected leftover uncertainty. Big children influence the outcome more.
Why is information gain guaranteed to be non-negative?
Entropy is a concave function, so the weighted average of child entropies (evaluated at the child distributions) never exceeds the parent's entropy (evaluated at the mixed distribution) — Jensen's inequality forces .
Why does Gini impurity exist if entropy already measures messiness?
Gini avoids the logarithm, making it cheaper to compute at scale. CART uses it; entropy and Gini usually agree on the split, so the speed is often free.
Why does the minus sign appear in the entropy formula?
Because probabilities satisfy , so . The minus flips each term positive so entropy (a measure of positive uncertainty) comes out .
Why does binary entropy peak exactly at ?
At 50/50 you are maximally uncertain — every draw is a fair coin flip. Any imbalance makes one class predictable, lowering surprise, so entropy dips toward the pure ends.
Why is Gain Ratio preferred over raw gain in C4.5?
It divides gain by SplitInfo, , which grows with the number of children, penalising high-cardinality features that inflate raw gain.
Why can cross-entropy loss in neural nets look like decision-tree entropy?
Both share the shape — Cross-Entropy Loss measures surprise of predicted probabilities under true labels , the same "average surprise" idea entropy formalises. See KL Divergence for the general comparison.

Edge cases

A node has 100 examples, all "Yes". What is its entropy and what does a further split gain?
Entropy is (pure). Any split leaves pure children, so gain is exactly — there is no uncertainty left to remove.
A binary node is exactly 50/50. What is its entropy, and can any split reduce it?
Entropy is bit (maximum). A split can reduce it — a perfect split into two pure children yields gain ; that is the dream case.
What happens to the term for a class with probability exactly ?
It contributes by the limiting convention ; absent classes never break or inflate the sum.
A feature has one value that every example shares (all in one child). What is its gain?
Gain is . The single child is identical to the parent, so weighted child entropy equals parent entropy — no information is gained.
A three-class node is a perfect uniform . Is its entropy bit?
No. Maximum entropy for classes is , so here it is bits. The "1 bit max" rule is only for two classes.
An ID feature splits 50 examples into 50 singletons. What is its raw gain vs. its Gain Ratio?
Raw gain equals the full parent entropy (every child pure) — deceptively maximal. Gain Ratio is small because SplitInfo is large, correctly deflating the fake gain.
If two candidate features tie on information gain, what breaks the tie?
Gain alone cannot; algorithms fall back on Gain Ratio, Gini, or arbitrary/first-listed order. This is a genuine ambiguity, not a computed winner — see ID3 and C4.5 Algorithms.
Splitting always to pure leaves gives gain at every step — is that ideal?
No. Driving to pure leaves overfits, memorising noise. Pruning trades a little training purity for generalisation, per Overfitting and Pruning.

Connections

  • Decision Trees — the traps above all bite during node splitting.
  • Gini Impurity — the scale and agreement subtleties.
  • ID3 and C4.5 Algorithms — cardinality bias and Gain Ratio.
  • Cross-Entropy Loss — the shared shape.
  • KL Divergence — comparing distributions, entropy generalised.
  • Overfitting and Pruning — why pure leaves are not the goal.