2.3.5 · D1Tree-Based & Instance Methods

Foundations — Overfitting in decision trees

3,246 words15 min readBack to topic

Before you can understand why trees overfit or how cost-complexity pruning fixes it, you have to be fluent in the small alphabet of symbols the parent note throws around. We will earn each one: plain words → a picture → why the topic needs it. Nothing is assumed.


0. What is a decision tree, physically?

Figure — Overfitting in decision trees

Look at the figure: each cut (yellow line) splits one region into two. Stack enough cuts and you carve the plane into little rectangular cells. Each final cell is a leaf of the tree — a box that gives one prediction to everything inside it.


1. The prediction symbols: , , and


2. Error, and why we square it: and


3. Averaging over randomness:


4. The three pieces of error: Bias, Variance,

This is the heart of why the parent note calls overfitting a "variance problem." Recall from Section 1 the honest data model : the noisy label wraps a true value inside a random jiggle . Picture a dartboard: the bullseye is the true value , each dart is the prediction from a model trained on a different random dataset.

Figure — Overfitting in decision trees

5. Tree anatomy: internal nodes, leaves and the symbol

Figure — Overfitting in decision trees

6. The complexity penalty: and


7. The tools that pick : cross-validation & purity


The prerequisite map

The roadmap below (also written out in words underneath, in case the diagram does not render) shows how these foundations feed the topic. In words: the geometry — feature space → axis-aligned splits → counting leaves — gives you the notion of tree size. Impurity (Gini/entropy) is what drives the splits. Separately, the observed label vs the guess → residual → square it → total error , then averaging with → the Bias/Variance/noise split, which pins down that overfitting is a high-variance condition. The leaf-count and the error together feed the complexity penalty , which builds the penalized cost ; that plus the variance insight plus cross-validation is exactly cost-complexity pruning.

Feature space and dots

Axis-aligned splits

Leaves count = tree size

Observed label y vs guess f-hat

Residual then square it

Error R of T

Expectation = average over data

Bias Variance Noise split

Complexity penalty alpha

Penalized cost R-alpha

Overfitting = high Variance

Cost-complexity pruning

Cross-validation

Impurity Gini Entropy

Trace any path and you reach the parent topic: Overfitting in Decision Trees (and the Hinglish version). Ensembling many trees to kill variance is the road to Random Forests.


A tiny numeric sanity check


Equipment checklist

Cover the answers and test yourself — you're ready for the parent note when every line is instant.

What does the feature space represent?
The graph of all possible input positions; each training example is a dot with coordinates .
What is an axis-aligned split, geometrically?
A straight cut parallel to one axis (a yes/no test on a single feature), slicing a region into two rectangular pieces.
What is the difference between an internal node and a leaf?
An internal node asks a question and splits (a fork); a leaf asks nothing and just predicts (the destination box).
What is the data model relating , and ?
: the observed label is the true value plus a zero-mean noise nudge with .
What does the hat in mean?
"Estimated / predicted" — the tree's attempt to recover the true .
What is a residual and why do we square it?
; squaring removes the sign so opposite errors don't cancel and big misses count more.
Write out for classification.
The misclassification rate — the fraction of training points the tree gets wrong.
What does mean?
The long-run average over infinitely many random datasets.
State the formal definition of Bias.
— offset of the average prediction from the true value.
State the formal definition of Var.
— scatter of predictions around their own average.
What is and where does it come from?
, the noise in the data model — the irreducible floor no model beats.
What does count?
The number of leaves in tree — our measure of its complexity.
What are , , , ?
= an internal node; = subtree below it; = error keeping it; = error collapsing it to one leaf.
Where does come from?
Setting keep-cost equal to prune-cost and solving; the denominator is the net leaves removed.
What if the effective comes out negative?
Then ; since no penalty triggers the prune, so always keep the subtree (in practice growing guarantees ).
What does do in ?
Charges a penalty per leaf, trading fit against simplicity; bigger → smaller tree.
Why does overfitting count as a variance problem?
A deep tree has low bias but its predictions swing wildly with each new dataset — the Var term dominates the error.