Log inStart free
LESSON 4.20 · 5 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Decision tree splits

Score 16 split lines on 12 points, and watch a tree keep the best one.


Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.20 · SPLIT BAYROOT 8 A · 4 B · H = 0.918
01
Stage 1 of 5 · Mixed node
An impurity score says how mixed a decision tree node is. The root's entropy is 0.918 bits.
Explain it simply

The root of the tree holds all 12 points: 8 of class A and 4 of class B. The red curve scores how mixed a node is. Entropy counts the bits you need to name the class of a random point. A pure node needs 0 bits, and an even mix needs 1.

Twelve points sit on a 9 by 9 grid: 8 of class A and 4 of class B. The root's entropy is 0.918 bits.

points, class countssplit line, thresholdimpuritygain, prediction
12 points · 2 featuresH curve · entropy112233445566778899x₁ →x₂ ↑root · 12 points8 A · 4 BH = 0.91800.5100.51share of class A in the noderoot12 points · 2 featuresH curve · entropy112233445566778899x₁ →x₂ ↑root · 12 points8 A · 4 BH = 0.91800.5100.51share of class A in the noderoot
Toy: 12 points · 8 A, 4 B · 2 features · 8 thresholds each
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
H=−∑kpklog⁡2pkG=1−∑kpk2E=1−max⁡kpk\sy{H}{grad}{H} = -\sum_k \sy{p}{data}{p_k} \log_2 \sy{p}{data}{p_k} \qquad \sy{G}{grad}{G} = 1 - \sum_k \sy{p}{data}{p_k}^2 \qquad \sy{E}{grad}{E} = 1 - \max_k \sy{p}{data}{p_k}
H=−(812log⁡2812+412log⁡2412)=0.918(pA=812)H = -(\tfrac{8}{12}\log_2 \tfrac{8}{12} + \tfrac{4}{12}\log_2 \tfrac{4}{12}) = 0.918\quad (p_A = \tfrac{8}{12})

Each score is 0 for a pure node and largest for an even mix.

Common mix-ups

MYTHA good split makes both children purer than the root.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If the criterion is Gini instead of entropy, does the best split change?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.