2.3.5 · D3Tree-Based & Instance Methods

Worked examples — Overfitting in decision trees

3,279 words15 min readBack to topic

This is the drill-ground child of Overfitting in decision trees. The parent gave you the ideas: cost-complexity pruning, the effective- formula, the U-shaped validation curve. Here we hit every case class those ideas can throw at you, one worked example per cell, so no exam question can surprise you.

Everything below reuses a few objects from the parent. To keep the contract — never a symbol before its meaning — here they are in plain words:


The scenario matrix

Every question this topic can ask falls into one of these cells. Each row is answered by at least one worked example below.

# Case class What makes it special Example
A Reading a train/val curve pick the depth at the U-curve bottom Ex 1
B Degenerate: negligible gap train ≈ val, tree is not overfitting Ex 2
C Plain effective- subtree with several leaves Ex 3
D Limiting input: 2-leaf stump denominator Ex 4
E Zero input: perfect subtree makes pure gain Ex 5
F Weakest-link ordering two nodes, which prunes first Ex 6
G sweep → tree size monotone shrink as Ex 7
H Pre- vs post-pruning trap (XOR) myopic gain Ex 8
I Real-world word problem translate business cost into a knob Ex 9
J Exam twist: forest vs single tree variance arithmetic Ex 10

We will also cover the degenerate limits explicitly: , , a subtree with zero training error, and a single split (stump) where the formula's denominator is smallest.


Worked examples


Recall Quick self-test on the matrix

A subtree has , , . Effective ? ::: . Train , val — overfitting? ::: No; -pt gap is noise-level (cell B). At the pruned tree becomes… ::: A single root leaf (predict the majority class). Between and , which node prunes first? ::: The one — smaller effective is the weaker link. Nine independent trees cut variance to… ::: (divide by ).


Connections