Random Forests Explained: 3 Reasons They Just Work

⚑ TL;DR: A random forest trains many decision trees on random subsets of the rows and columns, then averages their predictions. The randomness makes the trees disagree β€” and averaging disagreeing trees cancels out their individual mistakes.

A single decision tree is easy to understand and unfortunately unstable: change a few rows and you get a noticeably different tree. A random forest turns that instability into an advantage.

How a random forest works

Random forest diagram showing five different decision trees each casting a vote, combined into a majority prediction
Each tree sees different data and different features, so each makes different mistakes. The vote keeps what they agree on.

Two sources of randomness, and both are essential:

Random rows (bagging). Each tree trains on a sample drawn with replacement from the training data β€” same size, but some rows appear twice and roughly a third are left out entirely.

Random features. At every split, each tree may only consider a random subset of the columns. This is the part that makes random forests work rather than merely being an ensemble.

πŸ§ͺ Why restricting features matters so much

Suppose one feature is strongly predictive. Every tree, given free choice, would split on it first β€” and you would get 500 nearly identical trees. Averaging identical trees achieves nothing.

By hiding that feature from most splits, other trees are forced to find different patterns. The trees become genuinely diverse, their errors become uncorrelated, and that is what averaging can cancel out.

Diversity is the mechanism. Without it a forest is just an expensive tree.

Why averaging helps

Each tree overfits its own sample in its own direction β€” one is fooled by a quirk in rows it saw, another by a different quirk. Those errors are largely independent, so they partly cancel when averaged. What survives is the signal all the trees found, because that was in the data rather than in any one sample.

In the language of the bias–variance tradeoff: individual deep trees are low bias and very high variance. Averaging keeps the low bias and cuts the variance sharply.

Out-of-bag scoring: free validation

Roughly a third of rows are left out of each tree’s training sample. Those rows are “out of bag” for that tree β€” genuinely unseen β€” so you can score each tree on its own leftovers and average.

Set oob_score=True and you get a validation estimate without holding anything out or running cross-validation. It is a genuinely useful property that most algorithms do not have.

Settings that matter

SettingEffectSensible value
n_estimatorsNumber of trees. More never overfits β€” it just costs time200–500
max_featuresColumns considered per split β€” controls diversityThe one worth tuning
max_depthTree depth limitOften fine unlimited
min_samples_leafMinimum rows per leaf1–5
βœ… Unlike almost everything else, more trees cannot overfit. Adding trees only refines the average. If results get worse with more trees, something else is wrong. This makes random forests unusually forgiving β€” the defaults are genuinely good.

Why it is the best default for table data

No scaling needed. Handles mixed types. Copes with irrelevant features. Robust to outliers. Trains in parallel. Rarely overfits badly, and works well without tuning.

For a spreadsheet-shaped problem, a random forest with default settings is a strong baseline that many more sophisticated approaches fail to beat.

The limitations

⚠️ Where random forests fall down

  • Interpretability is gone. One tree you can read; 500 you cannot. You get feature importances, not an explanation.
  • Feature importance is biased toward high-cardinality columns. Use permutation importance instead.
  • Cannot extrapolate. Predictions are averages of training values, so a forest will never predict beyond the range it saw. For a trend that continues upward, use a linear model.
  • Large and slow to serve. 500 deep trees is a big model to load and query.
  • Weak on images, audio and text β€” that is neural network territory.

The extrapolation limit surprises people, so it is worth stating plainly: if your training prices top out at Β£500k, no random forest will ever predict Β£600k.

πŸ”‘ Key Takeaways

  • A random forest averages many trees trained on random rows and random features.
  • Restricting features per split is what makes the trees diverse β€” and diversity is the whole mechanism.
  • More trees never overfits; max_features is the setting worth tuning.
  • Out-of-bag scoring gives free validation without a holdout set.
  • It cannot extrapolate beyond the range of its training data.

Further reading

scikit-learn’s forest documentation covers bagging, out-of-bag scoring and the tuning parameters, and its permutation importance example shows why the built-in importances mislead.

Where to go next

Scroll to Top