Class mixture rather than economic inequality
Gini impurity describes how strongly classes are mixed in a nonempty node. For proportionspk summing to one, G=1−Σpk2. A pure node has G=0; uniform classes maximise it at1−1/K for fixed K. This Gini quantity is not the economic Gini coefficient used for income inequality.[1][2]
Impurity is dimensionless; counts are nonnegative integers.[1]
A decision tree may select splits by a count-weighted reduction of this impurity. Information gain here instead denotes the corresponding entropy reduction. Similar goals do not imply identical values or split choices.
A precise random interpretation
Draw two labels independently with replacement from the same empirical class distribution. Agreement probability isΣpk2; disagreement probability is therefore G. The same calculation describes an independent random prediction drawn from that exact label distribution. It is not automatically the error rate of a majority prediction or trained classifier.
This equivalent form avoids subtracting nearly equal numbers for almost-pure nodes.
The calculator accepts exactly three class counts; a zero count leaves one class absent. N=0 is rejected. G cannot uniquely recover the original counts. Fractional sample weights and full tree optimisation are outside this teaching model.
Calculate three classes and examine an error interpretation
Example1: A three-class node
- Given
- Counts(6,3,1), N=10.
- Find
- Find proportions and G.
Obtain proportions from counts.
Sum the squared proportions and subtract from one.
Result: G=0.54 lies betweenzero and the three-class maximum2/3.
Check: Count check:2(6×3+6×1+3×1)/102=54/100.
Example2: Gini is not majority-vote error
- Given
- A node contains6 A and2B cases. Random labels are drawn independently with replacement from these proportions.
- Find
- Compare G with the empirical error of always predicting A.
Calculate Gini as random-label disagreement.
Evaluate the majority rule separately.
Result: G=0.375 and majority error0.25 answer different questions.
Check: Of64 ordered draws with replacement,24 disagree. Without replacement, the denominator would be8×7, which defines a different random experiment.
Recall the method later with the formula’s flashcards.
10 flashcards · English materials
Already have an account? Sign in for flashcardsAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Binary mixture has a maximum
The maximum occurs at equal proportions
Free with a Quanta account. Your download stays ready after registration.
Five node-impurity exercises
Calculate · Foundation
A node contains4 A,4B and0C cases. Find G.
Show hint
Form proportions using N=8.
Learning goal: Calculate Gini from integer class counts.
Show solution and calculation
G=1−[(4/8)2+(4/8)2+02]=1/2.
This is maximal impurity for two represented classes.
Rearrange · Application
A binary node has G=0.32. Which class proportionsp are possible?
Show hint
Solve2p(1−p)=0.32.
Learning goal: Recognise ambiguity when inverting impurity.
Show solution and calculation
p2−p+0.16=0 givesp=(1±0.6)/2, so0.2 or0.8.
G alone does not identify which class has which label.
The count calculator therefore offers no unique inverse.
Interpret · Foundation
Compare(9,0,0) with(0,0,0). Do both have G=0?
Show hint
An empty node has no proportions.
Learning goal: Distinguish pure from empty nodes.
Show solution and calculation
For(9,0,0), N=9 and G=0:the node is pure.
For(0,0,0), N=0 and G is undefined.
An absent node is not the same as a pure node.
Error analysis · Foundation
Someone uses G=1−Σpk forp=(2/3,1/3). Check the result.
Show hint
The squares are part of the definition.
Learning goal: Detect a definition error through probability normalisation.
Show solution and calculation
SinceΣpk=1, the incorrect formula always giveszero.
Correctly, G=1−4/9−1/9=4/9.
The classes are mixed, so G must be positive.
Transfer · Application
Double(6,3,1) to(12,6,2). What changes and what stays the same?
Show hint
Relative proportions remain unchanged.
Learning goal: Separate scale-invariant mixture from confidence in the data.
Show solution and calculation
N rises from10 to20, butp=(0.6,0.3,0.1) stays the same.
Hence G remains0.54.
Impurity measures mixture, not sample size or estimation confidence.
Check your understanding with the formula’s reference test.
8 test questions · English materials
Already have an account? Sign in for the testAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Sources for this explanation
Quanta · Updated November 9, 2026
- scikit-learn,DecisionTrees,§1.10.7.1Classificationcriteria:Gini
- CornellCS4/5780,DecisionTrees:ImpurityFunctions,Giniimpurity
Editorial responsibility: Quanta Study editorial team
Review scope
This explanation, 2 worked examples and 5 exercises are available in German and English. Structure, source references and mathematical notation undergo automated checks. Calculations, model assumptions and both language versions receive a separate AI review.
An independent, named human subject review has not yet been documented. Our exercise numbers are worked examples, rather than measurements published by the cited sources.
Editorial responsibility, sources and methodsChange history
- Authored an original DE/EN article with worked calculations, exercises, model limits and native graphics.
Cite this reference page
Quanta. Gini impurity of a classification node. Updated November 9, 2026. https://quanta-study.de/en/formula-sheet/gini-impurity-klassifikation
When citing a specific scientific statement, also cite the specialist source linked to that statement.