Trees and Ensembles of Them
How a regression tree chooses its splits by exhaustive search, why the resulting fit is piecewise constant and unstable under resampling, and what averaging many trees changes about that instability, including the correlation floor that limits what more trees can achieve and the restriction random forests use to reduce it.
Definition
A regression tree partitions the predictor space into rectangular regions and predicts, within each, the mean of the training responses that fall in it. The fitted function is therefore piecewise constant.
Recursive binary splitting builds it. At each node, consider every predictor
where
Bagging fits
Only the second term falls with
A random forest is bagging plus one change: at each split, only a randomly chosen subset of the predictors is considered as candidates. The intent is to reduce
Assumptions and scope
The split criterion above is for a continuous response. Classification trees use an impurity measure such as the Gini index or cross-entropy instead, and the greedy structure and instability carry over unchanged.
The variance formula
assumes every tree has the same variance and every pair the same correlation. Real ensembles violate both mildly, so it describes the shape of the relationship rather than an exact value.Bagging is primarily a variance-reduction device for unstable learners. Averaging changes the fitted function, so it does not leave bias exactly unchanged in general; the bias of the average is close to that of a single tree when the trees are similar, which is the case the argument assumes. A region where a single tree is systematically wrong stays wrong under averaging, since every tree makes the same error there.
Averaging a piecewise-constant fit produces a smoother fit, which helps where the truth is smooth and can hurt near a genuine discontinuity, where averaging across trees that place the boundary differently blurs it.
Bootstrap resamples omit about 37% of the observations each time. Those out-of-bag observations give an error estimate without a separate held-out set, but the estimate is of a bagged predictor built from fewer trees than the final one.
Worked material
Example
Relationships a tree handles well, and badly
A tree's fitted function is piecewise constant. That single property decides which relationships it represents cheaply and which it represents only by spending many splits.
A step. Cheap. A response that is one value below a threshold and another above it is exactly what a single split expresses. One comparison, two leaves, and the fit is essentially exact. No form had to be guessed, and no transformation applied.
A straight line. Expensive. A tree approximates
An interaction. Cheap, and automatic. Suppose the effect of dose reverses above a certain age. A linear model represents this only if somebody writes down an age-by-dose product term. A tree splits on age and then chooses different dose splits in each branch, so the interaction is discovered rather than specified. This is the main reason trees are used on data whose structure is unknown.
A relationship depending on a sum of predictors. Expensive. If the response depends on
A smooth curve. Middling, and improved by averaging. A single tree gives a coarse staircase. Averaging many trees whose steps fall in different places produces a fit with many small steps rather than a few large ones, which is closer to smooth. This is a case where the ensemble changes the shape of the fit and not merely its stability.
---
Trees are cheap where the truth has boundaries aligned with individual predictors, and expensive where it is smooth or depends on predictors in combination. Neither is a defect: it is what choosing a partition instead of a formula gains and costs. The complementary observation is that a linear model's costs are the mirror image, which is why the two appear together in practice and why comparing them on held-out error is the routine move.
Contrast
Changes that look similar and do different work
More trees against less correlated trees.
| raise | lower | |
|---|---|---|
| affects | ||
| at | variance | — |
| at | variance | — |
| at | — | variance |
Going from a hundred trees to infinitely many recovers
Bagging against pruning.
Both address a deep tree's poor test error and they work in opposite directions. Pruning removes splits, lowering variance and raising bias, and leaves one readable tree. Bagging keeps every tree deep and averages, lowering variance while leaving bias alone, and leaves no single tree to read. Choose pruning when the explanation is the deliverable; choose bagging when the prediction is.
Out-of-bag error against cross-validated error.
| out-of-bag | ||
|---|---|---|
| extra fits required | none | |
| estimates the error of | an ensemble of about | an ensemble of |
| bias | mildly pessimistic | mildly pessimistic |
Both are honest held-out estimates and neither is free of bias; out-of-bag is far cheaper and estimates a slightly smaller ensemble than the one being shipped.
A tree's variance against a tree's bias.
A deep tree has low bias and high variance: it can represent almost any partition, and which partition it chooses depends heavily on the sample. A stump has the reverse. Bagging addresses only the first, so bagging stumps accomplishes very little. There is little disagreement to average away. Recognising which term dominates decides whether an ensemble is the right instrument at all.
A split's score against a split's stability.
The reported tree shows which candidate won. It does not show by how much. A split winning by
Common errors
Common misconception
That growing more trees in an ensemble drives its variance toward zero, so a forest of 5000 trees is meaningfully better than one of 500. The variance of an average of
Common misconception
That a regression tree's split point is chosen by eye from where the data appear to separate, or at a round value such as the median or the midpoint of the range. The split is selected by exhaustive search: every candidate boundary between adjacent observed values is scored by the total residual sum of squares of the two groups it creates, and the minimising candidate is taken. The chosen point often coincides with where a reader would have drawn it, which is what makes the misconception durable, but the coincidence is a consequence of the criterion rather than the method. Where several candidates score closely the choice is decided by small differences that a different sample would reverse, and that instability is the variance an ensemble exists to average away.
Related units
Requires
Connected
- Choosing a Regression Form (contrasts with)