Entropy
Learn entropy as an alternative impurity measure for classification splits.
Gini is not the only way to measure mixing. Entropy comes from information theory and captures how uncertain we are about a node's class label.
Big idea
High entropy means high uncertainty—many classes are represented. Low entropy means we are fairly sure which class dominates.
A pure node has entropy =0. Like Gini, entropy helps decision trees find splits that create cleaner child groups. Scikit-learn lets you switch criteria with criterion="entropy".
Formula
For class proportions p0,p1,…:
H=−i∑pilog2(pi)For two classes, entropy ranges from 0 (pure) to 1 (50/50).
Information gain measures how much a split reduces uncertainty:
IG=H(parent)−Weighted H(children)A good split has high information gain—meaning child nodes are more certain than the parent.
Worked example
Parent node: 4 class 0 and 4 class 1 (50/50).
Hparent=−(21log221+21log221)=1.0After splitting Feature 0 at t=2.5:
- Left (3 class 0, 1 class 1): Hleft≈0.811
- Right (4 class 1): Hright=0
Common mistake
Treating entropy and Gini as different goals. Both reward purer children—they just use different math. In practice, trees trained with either criterion often perform similarly.
Key takeaway
Entropy measures uncertainty; information gain measures how much a split reduces it. Lower child entropy (higher information gain) means a better split.
Try computing entropy for a small class distribution in the practice notebook below.
Practice
Try It Yourself
Open the practice lab to complete the starter code in the notebook.
Knowledge Check
Quick Quiz
A perfectly pure node has entropy of:
Summary
Key Takeaways
- Entropy measures uncertainty in a node.
- Like Gini, lower entropy means a purer node.
- Decision trees can use entropy instead of Gini to guide splits.