Random forests explained in plain terms means understanding the model that asks hundreds of simple decision trees the same question, and takes the majority answer. The central question is how a crowd of weak, unreliable models can be more accurate than any one of them alone, and the answer is that their mistakes cancel out, while their shared signal survives.
A random forest is an ensemble machine learning method, which means it combines many models into one. It grows a large number of decision trees, each trained on a different random sample of the data, and each allowed to see only a random subset of the inputs at every split, and then it averages their predictions, or takes a vote, to produce its answer.
The idea is simple: many noisy guesses beat one careful guess. A single decision tree is easy to read but unstable, since a small change in the data can produce a very different tree, while a forest of trees, each slightly different, is steady and accurate, because no single tree’s quirks can dominate the result. This article explains what random forests are, how they work, and where they are used.
Key takeaways
- A random forest is many decision trees trained on random samples, voting together.
- Each tree sees only a random subset of inputs at each split.
- Averaging the trees removes the instability of a single tree.
- It handles numbers, categories, and missing values with little preparation.
- It suits problems where accuracy matters more than reading the model.
What random forests are
A random forest is built on bagging, short for bootstrap aggregating. Each tree is trained on a bootstrap sample, which is a sample of the training data drawn with replacement, so that each tree sees roughly two-thirds of the examples, with some repeated and some left out. The examples left out of a tree’s sample are called out-of-bag, and they give a free, honest estimate of how well that tree predicts new data.
The second source of randomness is the feature subset. At each split, a tree is allowed to consider only a small random selection of the inputs, often the square root of the total number. This stops the strongest input from dominating every tree, forces the trees to use different information, and makes them genuinely different from each other, which is what makes the vote work.
For classification, each tree casts a vote for a class, and the forest predicts the class with the most votes. For regression, each tree predicts a number, and the forest predicts the average. The forest itself has no single structure to read, which is the price of its accuracy: you can inspect any one tree, but the model as a whole is a crowd, not a flowchart. Our guide to decision trees explains the single-tree model a forest is built from, and our guide to linear regression explains the simpler model a forest is usually compared against.
How random forests work
Training starts with the full dataset, and the algorithm grows each tree independently, which means the work can be spread across many processors at once. A tree is grown deep, with little or no pruning, because the averaging will control the overfitting that a deep tree would suffer alone, and a forest commonly holds a few hundred trees.
At each node, the tree tries the random subset of inputs it is allowed to see, and picks the split that best separates the answers, measured by Gini impurity for classification or variance for regression. Because each tree sees different data and different inputs, the trees disagree with each other often, and those disagreements are the point: the errors are uncorrelated, so they average away.
Prediction is a walk through every tree. A new example is passed down each of the hundreds of trees, each one votes or predicts a number, and the forest combines them. A classification that wins 380 votes to 120 is a confident one, while a 210 to 190 split is a warning that the example sits near a boundary the model finds genuinely hard.
The out-of-bag examples give a built-in performance check. Each example is out-of-bag for about a third of the trees, so it can be predicted by the trees that never saw it, and the error across all such predictions is an unbiased estimate of how the forest will do on new data, with no separate test set needed.
Feature importance is the forest’s way of explaining itself. By measuring how much each input improves the splits across all the trees, or how much accuracy is lost when an input’s values are shuffled, the forest ranks the inputs by their contribution. The ranking is useful, but it is not a story: it says which inputs matter, not how they combine.

Comparing random forests with other models
Random forests are one of several predictive models, and each suits a different problem. A single decision tree is readable but unstable, linear regression is simple and clear, and gradient boosting is accurate but slower to train, but each has its own trade-offs.
The table below sets out the main contrasts between the leading approaches.
| Aspect | Random forests | Decision trees | Gradient boosting |
|---|---|---|---|
| Predicts | Categories or numbers | Categories or numbers | Categories or numbers |
| Interpretability | Poor, many trees at once | Very clear, a flowchart | Poor, sequential trees |
| Accuracy | High, averages many trees | Moderate, one tree | Very high, tuned carefully |
| Overfitting | Resistant, by averaging | Prone, needs pruning | Prone, needs tuning |
| Best for | Accuracy without tuning | Explainable rules | Maximum accuracy, with effort |
The practical result is that random forests are the right choice when accuracy matters and tuning time is short, a single tree wins when the decision must be explained, and gradient boosting is the choice when every last point of accuracy is worth the extra work.
Where random forests are used
Credit scoring and fraud detection are major uses. A bank’s forest scores transactions from amount, location, and history, and its resistance to overfitting suits data that is noisy and uneven, while the vote share gives a natural measure of how suspicious a transaction looks, which guides which cases a human reviews first.
Medicine uses random forests to predict outcomes from patient data. A forest might estimate the risk of readmission from age, diagnoses, and lab results, and the feature importance ranking tells clinicians which factors the model leans on, even though no single tree can be read as the reasoning behind a prediction.
Remote sensing uses random forests to classify land from satellite images. Each pixel carries measurements in many spectral bands, the forest learns which combinations mean forest, water, or farmland, and the model scales to millions of pixels without needing the careful tuning that other methods demand.
Marketing uses random forests to score customers. A retailer predicts who will buy, who will leave, and who will respond to an offer, from behaviour and demographics, and the forest’s tolerance for mixed inputs, numbers and categories together, makes it easy to feed with whatever data the business already holds.
Ecology and environmental science use random forests to model where species live. Researchers predict the presence of a species from climate, soil, and terrain, and the model handles the interactions between those factors naturally, which is why it has become a standard tool in species distribution modelling.
Strengths and limits
The greatest strength of random forests is their accuracy with almost no tuning. Grow a few hundred trees, accept the defaults, and the result is usually close to the best available, which is why forests are the first model many practitioners reach for on a new dataset, and the baseline that fancier methods must beat.
It is also a strength that random forests are robust. They need no scaling of inputs, they accept categories and numbers together, they handle missing values, and they are resistant to overfitting, which means they can be used on messy, real-world data without the careful preparation other models demand.
The limits are real, though. A forest cannot be drawn and read like a single tree, so it is a poor choice where a decision must be explained to a regulator or a customer, and it is slower to predict than a simple model, since every new example must be walked down hundreds of trees. It also struggles with very sparse data, such as text, where other methods do better.
Random forest checklist
- Start with a few hundred trees, and add more only if accuracy improves.
- Let the trees grow deep, and let the averaging control overfitting.
- Use the out-of-bag error as a first check, before a separate test set.
- Check feature importance, and drop inputs that contribute nothing.
- Do not expect the model to extrapolate beyond the training data.
- Handle class imbalance, since a forest will favour the majority class.
- Compare against a single tree, to see what accuracy costs in readability.
- Watch prediction speed, since hundreds of trees take time to walk.
- Retrain when the data drifts, because a forest cannot adapt on its own.
Frequently asked questions
What is a random forest in simple terms?
A random forest is a crowd of decision trees that vote together. Each tree is trained on a different random sample and sees different inputs, and the forest takes the majority vote, or the average, which is more accurate than any single tree.
What is bagging?
Bagging is short for bootstrap aggregating. Each model is trained on a random sample of the data drawn with replacement, and the predictions are averaged or voted on, which removes the variance that makes single models unstable.
What are out-of-bag examples?
They are the examples a particular tree did not see during training, because each tree is trained on a random sample. They let the forest estimate its own accuracy honestly, without needing a separate test set.
What is feature importance?
It is a ranking of how much each input contributes to the forest’s predictions, measured across all the trees. It says which inputs matter most, though it does not explain how they combine to produce an answer.
How many trees should a random forest have?
A few hundred is the usual starting point. More trees rarely hurt, since averaging only helps, but the gains level off, and prediction gets slower, so the right number is where accuracy stops improving.
When should I use a random forest?
When accuracy matters more than explanation, when the data mixes numbers and categories, and when you want a strong result without careful tuning. For a model that must be read and defended, a single tree is better.
The bottom line
Random forests explained in one line is this: hundreds of decision trees, each trained on a different random sample, voting together so that their mistakes cancel and their shared signal wins.
They are the workhorse of applied machine learning, accurate with almost no tuning, robust on messy data, and the standard first choice whenever a decision does not need to be drawn as a flowchart.
This article is general information about how random forests work, not advice about building models for a particular problem.







