One question creates two groups
A threshold such as x ≤ 2 sends smaller values left and larger values right. A leaf can predict the majority class among the training examples routed to it.
Measuring a split
For class proportions p₁ and p₂, Gini impurity is 1 − p₁² − p₂². A pure node has impurity zero. A split’s weighted impurity averages its child impurities, weighted by their sample counts. The dashed line separates the training points into leaves. Each leaf predicts its own majority class, with ties assigned to A.
INTERACTIVE EXPLORATION
Try a split
Four training points have x = 1, 2, 3, 4 and classes A, A, B, B. Move the threshold and compare leaf predictions and weighted impurity.
When a tree is too specific
A deep tree can create small leaves that fit training quirks. Depth constraints, minimum leaf sizes and validation are common ways to control complexity. Ensembles combine multiple trees rather than relying on one.
Check your understanding
What is Gini impurity in a node containing only class A?
Zero: 1 − 1² − 0² = 0.