What do Gini impurity and entropy measure in a two-class decision-tree node, and what are their values when the positive-class proportion is p=0.5 (evenly mixed) and p=1 (pure)?

Supervised learning, Impurity measures
Level L1 Beginner. Length Short. Nature Th+Mat Both.

What's being asked

Whether you know what node impurity means and can evaluate Gini impurity and entropy for the two extreme cases: evenly mixed and completely pure.

Key idea

Impurity measures how mixed the class labels are in a node: it is 0 for a pure node and largest when the classes are split 50–50. With p as the fraction of positive samples, Gini=2p(1−p) and entropy=−plog⁡2p−(1−p)log⁡2(1−p).

Steps

  1. Explain impurity with an example: think of a basket of fruit. A basket holding only apples is pure (impurity 0), whereas a basket that is half apples and half oranges is maximally mixed; a tree split tries to make its child nodes purer.
  2. At p=0.5 (most mixed): Gini=2(0.5)(0.5)=0.5. Because log⁡20.5=−1, entropy=−0.5(−1)−0.5(−1)=1 bit.
  3. At p=1 (pure): Gini=2(1)(0)=0 and entropy=−1log⁡21−0log⁡20=0 bits (using the convention 0log⁡20=0). Since the node is pure, we stop splitting.
  4. Compare briefly: both curves rise smoothly from 0 at a pure node to their peak at p=0.5, so they usually choose very similar splits. Computing them on intermediate proportions to score candidate splits comes next.

Common mistakes

How long your answer should be

4–5 sentences with the two quick calculations.

Read this

Previous in Supervised learning: How does Adaline (trained with the delta or LMS rule) differ from the perceptron, in the quantity used for the update and in the loss being minimised?
Next in Supervised learning: How many binary classifiers do one-vs-rest (OvR) and one-vs-one (OvO) need for K=10 classes? For K=4 classes A,B,C,D, suppose the OvO classifiers say A beats B, A beats C, D beats A, B beats C, D beats B and D beats C. What does OvO predict, and why can OvR be ambiguous?