Describe the use of Gini impurity in classification trees.
Instruction: Define Gini impurity, give its range for a fixed number of classes, and explain how a tree uses it to choose splits.
Updated
Official answer
Classification trees commonly use Gini impurity, not the income-inequality Gini coefficient. For class proportions p₁,…,pK in a node, impurity is 1 − Σ p_k². It is zero for a pure node and reaches 1 − 1/K for an even class distribution: the binary maximum is 0.5, not 1.
Compare a parent’s impurity with the sample-weighted average impurity of its proposed children. For a parent with five examples from each of two classes, impurity is 0.5. A split into counts (4,1) and (1,4) gives 0.32 in each equally sized child, so the reduction is 0.18.
A greedy tree chooses an allowed split with a favorable reduction, subject to restrictions such as minimum leaf size. It does not find a globally optimal tree or guarantee generalization. Control complexity with suitable stopping/pruning and validate on held-out data.
Reference: scikit-learn classification criteria.