Basic Prerequisites: 02 · Decision Trees and 05 · Bias–Variance & Validation.
1. Intuition & Practical Objective
A deep tree is a low-bias, high-variance estimator: it can represent almost any function, but resample the data and it draws a different staircase. Bagging asks: if the variance comes from the estimator’s sensitivity to the sample, what if we fit many trees on many bootstrap resamples and average them? Each tree keeps its low bias; the independent parts of their errors cancel in the average, and the variance drops. A random forest adds one more trick - at each split, each tree may only consider a random subset of features - precisely so that the trees are less correlated with one another, because correlated trees average away less.
The objective of this page is to show, with numbers, that (a) averaging tames tree variance, (b) the de-correlation trick of the RF helps further when features are correlated, and (c) the forest hands you a free held-out error estimate - the out-of-bag (OOB) error - which matters enormously when every fold refit is a chance to overfit in low-SNR finance.
2. Mathematical Ground Truth & Derivations
Bagging (ESL 8.51–8.52). Draw bootstrap samples, fit a tree on each, and average:
At the population level, averaging never increases MSE (ESL 8.52): for the average of identically-distributed but possibly dependent fits. Bagging does not reduce bias - it only attacks variance.
Why the bootstrap breaks correlation. Bootstrap draws lose roughly of the rows, so each tree is fit on a perturbed sample. The variance of the average of identically-distributed trees with pairwise correlation is (ESL 15.1):
Two consequences: increasing kills the second term but the first () never dies; to reduce it you must reduce . Since falls as the trees are forced to differ, random forests reduce by restricting each split to a random feature subset of size :
- classification default , node size 1;
- regression default , terminal node size 5 (ESL 15.1).
Lower ⇒ lower ⇒ more variance killed, at the cost of slightly stronger (higher-bias) individual trees.
OOB error (ESL 15.3.1). For each observation, roughly of the trees did not see it in their bootstrap sample. Predicting it from only those trees gives an unbiased-ish held-out error that is, in practice, “almost identical to -fold CV” - obtained in a single fit. In time-series finance this must be paired with purging/embargoing (Purged CV); plain OOB assumes exchangeable samples.
3. Computational Implementation - single tree vs bagging vs random forest
A synthetic low-SNR panel with 8 factors, three of them real and two of those ~0.9 correlated (e.g. 20-day and 30-day momentum). We fit one deep tree, then a bagged forest and a random forest, and measure test MSE, the average pairwise tree correlation , and the OOB error.
Read the numbers against the formula . One deep tree scores MSE ; averaging 100 of them drops it to , a 30% cut - pure variance reduction. Restricting each split to 3 of the 8 features cuts the average tree correlation from to and improves the OOB estimate ( vs ): exactly the mechanism of ESL eq 15.1 - less correlation between the averaged trees means less residual variance. (The test MSE is essentially a tie here because the informative features are few; the decorrelation benefit grows with the number of correlated predictors.) Finally, note the OOB error is available for free - it tracks the test MSE closely without a single extra fit.
4. Failure Modes & First-Principles Breakdowns
- Bagging is not a cure for a bad base learner. It removes variance, never bias. Bag a linear model and nothing happens; bag a tree and its instability is addressed. If the model is biased (too shallow), more trees do not help.
- Correlated trees limit the gain. The floor in eq 15.1 is set by tree correlation; if every tree is fit on the same dominant features, the forest’s benefit saturates. Feature subsampling is the lever - too large and the forest is bagging.
- OOB assumes exchangeable samples. A naive OOB is invalid on overlapping, serially-correlated financial labels; it must be purged/embargoed. Do not read the OOB number above as a finance-grade backtest.
- Interpretability is lost. A 100-tree forest is not a tree; you need 06 · Feature Importance to recover any attribution - and that attribution is itself biased (see 05).
- More trees never overfit in B, but the limit can. Averaging infinitely many trees converges to a fixed (bagged) estimator; if the individual trees are too deep, that limit itself overfits. is not a regularizer for depth.
5. References
- Hastie, Tibshirani & Friedman, The Elements of Statistical Learning
- López de Prado, Advances in Financial Machine Learning
- Hastie, Tibshirani & Friedman, ESL
6. Connected Graph Bridges
- Back: 02 · Decision Trees · Index Hub
- Continue: 04 · Gradient Boosting
- Hygiene: Purged CV & Embargoing · Financial ML Pitfalls & Low SNR