How to use this calculator
- Enter or choose items in each class.
- The gini impurity updates as you type. Use Copy result or Share to keep it.
Method
G = 1 − Σ p_i²; G_max = 1 − 1 ÷ k
- p_i
- share of items in class i
- k
- number of classes
Worked example
- Shares: 9 ÷ 14 and 5 ÷ 14.
- G = 1 − (81 + 25) ÷ 196 = 90 ÷ 196 = 0.459184.
A node with 9 and 5 items has Gini impurity 0.459, close to the two-class maximum of 0.5.
What the result means
Decision trees (CART) choose the split that most reduces weighted Gini impurity. It is not the Gini coefficient of inequality used in economics.
Assumptions and limits
- Class shares are estimated from the counts in the node.
- To score a whole split, use the information gain calculator with the Gini criterion.
Questions
Gini or entropy?
They rank splits almost identically in practice. Gini is slightly cheaper to compute; entropy penalises very impure nodes a little more.
Is this the same as the Gini coefficient?
No. The Gini coefficient measures inequality of a distribution, such as income; Gini impurity measures class mixing in a node.