Random forest

A random forest is a machine learning method that trains many decision trees on random samples of the data and features, then combines their votes or averages them for a more accurate prediction.

A single decision tree asks a series of yes-or-no questions about the data and is easy to follow, but it tends to memorise its training examples and do worse on new ones. A random forest grows many trees, typically a few hundred to several thousand, and makes each one different in two ways. Each tree is trained on a bootstrap sample, a random draw of the training examples with replacement. And at each split, a tree may only choose from a random subset of the features. For a category, the forest takes the majority vote of its trees; for a number, it averages them.

The randomness is the point. Because each tree sees different data and features, their mistakes are only partly related, and averaging lets many of them cancel out. The scikit-learn documentation describes this as reducing the variance of the model, sometimes at the cost of a slight increase in bias, usually with a better model overall. Picture a bank predicting loan defaults from income, existing debt and repayment history: one tree might latch on to a quirk in its sample, but hundreds of trees trained on different samples smooth that out.

Tin Kam Ho created the first random decision forest algorithm in 1995. Leo Breiman, working with Adele Cutler, extended it in 2001 by combining bagging, short for bootstrap aggregating, with random feature selection. Breiman's paper also used the out-of-bag error, which tests each example only on the trees that did not see it in training, giving an accuracy estimate without a separate test set, and a way to rank how important each feature is. Random Forests was registered as a trademark in 2006.

Random forests work on tabular data, the rows and columns of spreadsheets and databases, for both classification and regression. Their main competitor there is gradient boosting, which builds shallow trees one after another, each correcting the last; the scikit-learn documentation recommends trying both. Random forests are not deep learning and use no neural networks.

The trade-off is explainability. A single tree can be read like a flowchart; a forest of hundreds cannot. Feature importance scores help, but the most common kind, built into scikit-learn and R by default, tends to favour features with many distinct values, so it should not be read as a precise account of why the model decided as it did.

Common questions

What is a random forest in simple terms?

It is a crowd of decision trees. Each tree is trained on a slightly different random sample of the data and features, and the forest combines all their answers, which is usually more accurate and less prone to overfitting than any single tree.

What is the difference between a random forest and a decision tree?

A decision tree is one model that splits the data with a series of questions. A random forest trains many such trees on random variations of the data and combines them. The forest is usually more accurate but much harder to interpret.

What is the difference between random forest and gradient boosting?

Both combine many decision trees. A random forest grows deep trees independently and averages them, while gradient boosting grows shallow trees in sequence, each one correcting the errors of those before. Which works better depends on the dataset, so practitioners often try both.

Is a random forest deep learning?

No. A random forest is a classic machine learning method built from decision trees and uses no neural networks. It runs on ordinary computers and works directly on tabular data such as spreadsheets.

Finding more

Search for "random forest", "bagging" or "random forest vs gradient boosting" for explanations and comparisons. Reliable sources include the scikit-learn user guide, Breiman's 2001 paper and statistics textbooks on ensemble methods. Treat feature importance charts from random forests with caution, and look for permutation importance or similar checks before drawing conclusions from them.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.