2.3.3 · D5Tree-Based & Instance Methods
Question bank — Gini impurity
Every symbol below is from the parent: = the proportion (share) of class in a node, = number of classes, = Gini impurity , = fraction of parent samples landing in child .
Two pictures anchor everything below — keep them in view:

The parabola above is for a two-class node, where is one class's share. It is at the pure ends ( and ) and peaks at dead center (). This single curve explains EC6, TF3 (mirror symmetry about ), and WHY5 (the curve bulges upward, i.e. it is concave — a chord between two points sits below it).

The right panel warns about SE5: two different "Gini" ideas. ML's Gini impurity is the parabola on the left; the economics Gini coefficient is an area ratio on a Lorenz curve. Same name, unrelated construction.
True or false — justify
TF1. "A node with is always a leaf where the tree stops."
False. means the node is pure so there's nothing left to gain, so the tree won't split it — but stopping can also happen earlier (depth limit, min-samples). Purity forces a stop; it isn't the only reason to stop.
TF2. "Adding a class that has proportion changes the Gini value."
False. A zero-proportion class contributes to the sum, so is unchanged. Only classes that actually appear affect impurity.
TF3. "For two classes, is symmetric: an 80/20 node and a 20/80 node have the same impurity."
True. depends only on the set of proportions, not which class is which — the parabola in figure s01 is mirror-symmetric about . Swapping labels leaves identical.
TF4. "Gini impurity can be greater than 1."
False. Its maximum is , which stays strictly below 1 for every finite and only approaches 1 as . Since , is always strictly below 1.
TF5. "If a split makes both children more impure than the parent, the tree will still take it because splitting is always progress."
False. If the weighted child impurity exceeds the parent's, Gini gain is negative and the greedy tree rejects that split. A split must reduce expected error to be chosen.
TF6. "Two different splits with the same are equally good to the tree."
True by the Gini criterion alone — the tree ranks purely on gain , so equal ties. (A tie-breaking rule, like feature order, then decides, but Gini itself is indifferent.)
TF7. "Gini impurity depends on how many samples are in the node."
False. uses only the proportions , not counts. A node of 3 samples and a node of 300 with the same class ratios have identical . Counts matter only in the weighted split score .
TF8. "The maximum Gini for 4 classes is larger than for 2 classes."
True. Max is : for it's , for it's . More classes means more ways to be wrong, so peak impurity rises.
Spot the error
SE1. "This split has children with Gini 0.1 and 0.6, so the split's impurity is ."
Error: children are averaged with weights (the formula above), never summed. Raw sums have no probabilistic meaning and would exceed 1 with enough branches.
SE2. "Node has 3 apples and 1 orange, so ."
Error: you must square proportions, not raw counts. Correct: , . A negative Gini is an impossible red flag.
SE3. "Gini gain , and we pick the split with the largest gain."
Error: the subtraction is backwards. Gain ; splitting lowers impurity, so parent minus child is the positive improvement.
SE4. "For a 50/50 two-class node, ."
Error: you squared the sum instead of summing the squares. Correct: — the maximum (the parabola's peak in s01), not zero.
SE5. "This is the ML Gini, so I'll draw the Lorenz curve to compute it."
Error: the Lorenz curve belongs to the economics Gini coefficient (right panel of s02, see Gini Coefficient (Economics)). ML's Gini impurity is just , a misclassification probability with no Lorenz curve involved.
SE6. "The parent has ; a child with only 1 sample is pure so , which alone proves this is the best split."
Error: a single-sample pure child gets tiny weight , so it barely lowers . Purity of a large child is what drags the weighted average down. Size matters.
SE7. "Entropy uses and Gini doesn't, so they produce completely different trees."
Error: both are 0 at purity and maxed at uniform, and agree on splits roughly 98% of the time. Gini skips mainly for speed, not to get different trees.
Why questions
WHY1. "Why do we square the proportions instead of just using ?"
Because always — it carries no information. Squaring rewards concentration: a dominant class contributes a large , shrinking , which is exactly the "how often do I win the guessing game" signal we want.
WHY2. "Why is a uniform distribution the worst (highest Gini), not the best?"
is minimized when probability is spread evenly, so is maximized there. Even spread means no class to reliably guess, so the random-guess mistake rate peaks.
WHY3. "Why weight children by rather than treating each child equally?"
Because we care about total expected misclassifications across all data. A big impure child produces many mistakes; a tiny pure one produces few. Equal weighting would let a small child overrule a large one.
WHY4. "Why doesn't the tree just keep splitting until every leaf has ?"
Driving training Gini to 0 usually means memorizing noise — overfitting (see Overfitting and Pruning). Purity is the split criterion, not the generalization goal; that's why we prune and cap depth.
WHY5. "Why can Gini gain never be negative for the chosen split? (What does 'concave' mean here?)"
'Concave' means the graph bulges upward, so any straight chord between two points lies below the curve — visible in the parabola s01. A split replaces the parent's point on the curve with a weighted average (a point on the chord) of the children's points; by concavity (Jensen's inequality) that chord value is the value at the averaged , which is the parent. So , and gain for the best split.
WHY6. "Why is Gini preferred over Entropy in Random Forests and CART by default?"
It avoids computing logarithms, so it's cheaper per split — and across thousands of trees that speed adds up while giving near-identical results (see Entropy and Information Gain).
WHY7. "Why does the per-class form read as 'expected error per class', and why does it equal ?"
Expand it: (using ) — so the two forms are algebraically identical. Reading each term: is the chance the item truly is class ; is the chance a random guess is not class ; their product is class 's mistake probability, summed into total .
Edge cases
EC1. "What is for a node with a single class (, )?"
. With only one possible label you can never guess wrong — perfectly pure, the degenerate lower bound.
EC2. "What happens to the maximum Gini as the number of classes ?"
It approaches 1 but never reaches it. Infinitely many equally-likely classes make a correct random guess vanishingly unlikely, so impurity nears its ceiling.
EC3. "A node has proportions — is it 'pure enough' to have ?"
Yes, , very close to 0. Near-total dominance by one class makes misclassification rare, so Gini is nearly zero without being exactly zero.
EC4. "A split sends all samples into one child and zero into the other. What is ?"
The empty child has weight and is ignored; equals the full child's Gini = the parent's Gini. Gain is 0 — a useless split the tree won't take.
EC5. "Empty node (): does its (which is , undefined) break the split score?"
No. Its weight zeroes out the term before the undefined matters. By convention an empty child contributes nothing to .
EC6. "For a fixed 2-class node, where exactly does peak as moves from 0 to 1?"
At , giving . The curve (figure s01) is a downward parabola symmetric about , zero at both ends (pure) and maxed dead center.
Connections
- Decision Trees — where these split scores are actually applied.
- Entropy and Information Gain — the log-based sibling contrasted in WHY6, SE7.
- Overfitting and Pruning — the trap behind WHY4.
- Random Forests — why cheap Gini matters at scale (WHY6).
- Classification vs Regression Trees — regression swaps Gini for variance/MSE.
- Gini Coefficient (Economics) — the name-collision trap in SE5.