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?
Supervised learning, Decision trees: Gini
Level L2 Elementary. Length Short. Nature Mat Mathematical.
What's being asked
Whether you can compute Gini impurity for a node and the weighted decrease from a split, as CART does.
Key idea
Gini . The gain of a split is parent impurity minus the sample-weighted average of the children's impurities.
Steps
- Parent: , so Gini .
- Left child: , so Gini .
- Right child: , so Gini .
- Weight the children by their sizes: .
- Gini gain . CART tries every split and picks the one with the largest gain.
Common mistakes
- Averaging the two child impurities without weighting by the child sizes.
- Forgetting the '1 ' and reporting (which is a purity, not an impurity).
- Concluding that a gain of 0.08 means the split is bad. Only the comparison across candidate splits matters.
How long your answer should be
4–5 lines of arithmetic.
Last checked on 4 December 2026.
Read this
Previous in Supervised learning: What is the difference between multiclass and multilabel classification, and how do the output activation, the loss and the prediction rule differ for a neural or linear model with outputs? What are three ways to reduce multilabel to simpler problems?
Next in Supervised learning: 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?