Visual explainer
Random Forests
Bootstrap hundreds of de-correlated decision trees with random feature subspaces and combine their votes, collapsing single-tree variance from 0.33 to 0.08 without overfitting.
A single unpruned decision tree possesses low bias but notoriously high variance (). Because greedy splitting algorithms recursively partition feature space until terminal leaf nodes achieve near-zero impurity, the resulting decision boundary draws narrow axis-aligned stair-steps around noisy outliers. While training error drops to zero, held-out test error surges to as new query points fall into isolated overfitted islands.
Trees That Disagree
To tame single-tree variance, Breiman's bagging procedure draws bootstrap samples of size from the original training dataset with replacement. Mathematically, the probability that any individual observation is excluded from a single bootstrap draw approaches . Approximately of unique rows appear in-bag (with duplicate copies), while the remaining form an Out-Of-Bag (OOB) partition that serves as an internal validation benchmark without requiring a held-out test split.
Votes Fix Errors
When classifying a new query vector , the ensemble collects individual predictions across all trees and takes the plurality vote:
If Tree 3 memorized a noisy training artifact and casts a rogue vote for Class 0, independent peer trees evaluating the same instance vote for Class 1. By a 3-to-2 majority tally, the ensemble suppresses the localized error and preserves correct global classification.
Hide Some Features
Bootstrap aggregation alone fails when one dominant predictor exists: every tree greedily places that dominant feature at its root split, producing strongly correlated trees (). Random Forests overcome this correlation bottleneck by forcing each split candidate to consider only a random feature subspace of size (e.g., out of ). Masking the dominant feature forces alternative trees to split on secondary attributes (), decorrelating the ensemble down to .
Error Falls Together
The variance of an average of identically distributed random estimators with pairwise correlation and individual variance obeys:
As , the sample variance term vanishes, driving overall variance down to the irreducible correlation floor . Averaging 200 decorrelated trees replaces jagged axis-aligned steps with a smooth continuous probability contour, cutting test classification error from to (a variance reduction).
Grow Enough Trees
Tracking Out-Of-Bag (OOB) generalization error against ensemble size demonstrates steep initial returns: error drops precipitously from at down to at and reaches an elbow near with an OOB error floor of . Unlike gradient boosting or deep neural networks, Random Forests do not overfit as ; the error curve plateaus asymptotically. Growing beyond trees burns CPU cycles with negligible statistical dividend ().
Where It Breaks
The Random Forest architecture encounters two fundamental theoretical limitations:
- Feature Redundancy and Correlation Collapse: If predictors are heavily confounded or multi-collinear, trees cannot decorrelate (). When every tree constructs identical flawed partitions, they vote unanimously for the wrong label (), completely defeating the variance-reduction benefits of voting.
- Inability to Extrapolate: Because decision trees assign constant leaf values, an ensemble cannot forecast trends outside the bounding box of observed training data (). Queries in outer domains receive flat, clipped constant predictions rather than tracking genuine physical trends.
The Quick Version
- Single tree dilemma: Deep trees achieve zero training error but suffer high variance ( test error) through outlier memorization.
- Bootstrap sampling: Drawing with replacement reserves roughly of data as out-of-bag validation rows while ensuring training diversity.
- Majority voting: Combining individual votes suppresses rogue errors whenever the majority of independent trees holds the correct consensus.
- Random feature subspaces: Selecting features per split prevents strong variables from creating identical, correlated trees.
- Variance formula: Averaging trees eliminates the term, cutting error to the correlation floor ().
- Sizing : Out-of-bag error plateaus near ; adding further trees costs compute without risking overfitting.
- Failure boundaries: High feature correlation () destroys voting diversity, and step-constant leaves cannot extrapolate beyond training extremes.