Decision Tree Learning (Likelihood Splits, Pruning, CV)
Context: FIT2086_MOC · how a decision tree is grown and sized · the split score is the Bernoulli NLL from Maximum Likelihood Estimation · sizing reuses Model Selection and Information Criteria (AIC, BIC) and Cross-Validation with as the complexity Parent Framework: Decision Trees and Regression Trees
Quick Revision
- 🎯 Objective: score a split by the minimised NLL of its leaves ➔ purer leaves = smaller NLL ➔ grow greedily, then size by IC or CV.
- 📦 Core Components: split score ➔ Bernoulli NLL per leaf | forward search ➔ greedy, stop when no split lowers the score | prune ➔ grow big, cut back to the best .
- ⚠️ Key Constraint: splitting can never increase the minimised NLL ⟹ NLL alone always grows the tree to (perfect fit, overfit) ⟹ the tree must be penalised (IC) or cross-validated.
📝 How It Works
1. Why Not Just Maximise the Likelihood
- Perfect fit ➔ if predictor values distinguish every observation, a large enough fits the training data perfectly ➔ overfits.
- Model selection instead ➔ score every tree by AIC, BIC, … or a CV error ➔ choose the smallest score ➔ trades goodness-of-fit against tree complexity.
- Search is approximate ➔ the number of possible trees is enormous even for moderate ⟹ greedy search, never exhaustive.
2. What Makes a Good Split
- Setup ➔ binary targets in one leaf; ones, zeros.
- Leaf score ➔ minimised Bernoulli NLL (with ).
- Purity reading ➔ largest at (least pure) · zero at or (pure) · symmetric in ➔ : peaks at when .
- Split score ➔ sum the leaf NLLs; the best split has the smallest total.
- Numeric predictor ➔ search thresholds : leaves and ➔ keep the giving the smallest total NLL.
- Never worse ➔ the unsplit fit is the special case of the split model ⟹ the split’s minimum NLL the parent’s ⟹ likelihood guides which split, not whether to stop.
3. Forward Search
- Start with one leaf (the root).
- Try splitting on every predictor (every threshold) and compute the criterion score of each resulting tree.
- If no split improves (lowers) the score ➔ stop.
- Otherwise take the split giving the smallest score.
- Go back to step 2.
- Greedy ➔ each step is locally best; an early bad split is never undone.
4. Pruning and K-fold CV for Trees
- Pruning ➔ grow a large, overfitted tree (forward search, splitting on whatever cuts NLL most) ➔ prune back subtrees (replace a subtree by one leaf) ➔ how far is set by an information criterion ➔ still approximate, but often better than forward search.
- CV sizing ➔ complexity parameter ; input ; for : split into disjoint folds; for : grow a tree with leaves on all folds except ➔ prune to ➔ predict fold with all pruned trees ➔ accumulate errors; average over the runs.
- Choose ➔ ➔ grow the final tree with leaves on all the data.
- Cost per run ➔ big trees grown, pruned trees scored.
🧮 Proof Blueprint
- Theorem ➔ for a leaf with ones among , .
- Strategy ➔ write the iid Bernoulli likelihood, plug in the MLE (Maximum Likelihood Estimation), take .
- Derivation Steps:
- Q.E.D. ➔ the leaf score is the entropy of the leaf’s class proportions — the “purity” measure falls out of maximum likelihood.
📊 Exam Execution Trace & Applied Exercises
Manual Execution Trace
Toy data, , binary predictors :
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | |
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | |
| 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 |
| Step | Tree | Leaf values | per leaf | Leaf NLLs | Total NLL |
|---|---|---|---|---|---|
| 0 | root | all 10 | |||
| 1 | split | : · : | · | ||
| 2 | split | : · : | · |
- Verdict ➔ gives much purer leaves (, vs , ) ⟹ split on .
Greedy growth on 185 patients (leaf label ; score = the lecture’s information criterion, lower is better):
| Step | Action | Leaves | Score | Kept? |
|---|---|---|---|---|
| 0 | root | — | ||
| 1 | split on Sex | M · F | ✓ improves | |
| 2 | split Female on Age | M · F · F | ✓ improves | |
| 3 | also split Male on Age | M · M · · | ✗ worse ➔ stop |
Applied Exercise
Problem: a leaf holds with , . Find and the leaf NLL; is it purer than a leaf? Then compare split A (leaves and ) with split B ( and ).
Final Extracted Output: , NLL ⟹ purer than ; split B wins ().
⚠️ Common Mistakes
- 💡 Selecting the tree by training NLL ➔ it only ever falls as grows; select by IC or CV error.
- 💡 Averaging leaf NLLs ➔ the split score is the sum over leaves (each already carries its own ).
- 💡 Keeping a CV fold’s tree as the answer ➔ CV picks ; the final tree is regrown on all the data.
🧠 Active Recall
Why can likelihood choose which split to make but not when to stop?
Answer
- Short answer: Every split weakly lowers the minimised NLL, so NLL alone would keep splitting to a perfect, overfitted tree; stopping needs a complexity penalty (IC) or held-out error (CV).
- Why: Nested models ➔ the parent leaf is the split model with , so the split can only match or beat it on the training data.
Trees A, B, C have , training errors , CV errors . Which do you choose for prediction, and why?
Answer
- Short answer: B — smallest CV error (); C’s tiny training error is overfitting.
- Why: CV estimates future error ➔ training error always favours the largest ; CV error is U-shaped in and bottoms out at .
, : how many pruned models are scored in one full -fold run?
Answer
- Short answer: pruned trees (from large trees, one per fold).
- Why: Per fold ➔ grow one big tree on the other folds, prune to , predict the held-out fold with each ⟹ models per fold folds.
Why is pruning a grown tree often better than stopping forward search early?
Answer
- Short answer: Forward search stops at the first split that fails to improve the score, but a weak split can enable strong splits below it; growing big then pruning lets those deeper splits be seen before deciding.
- Why: Greedy myopia ➔ forward search judges one split at a time; pruning judges whole subtrees — both remain approximate searches.