# Random forest

> Canonical: https://skillalmanac.com/glossary/random-forest | Last verified: 2026-11-25 | Index status: index-eligible

A random forest combines predictions from many randomized decision trees. Bootstrap sampling and feature subsampling are common sources of diversity, but their use depends on the implementation and settings; classification and regression combine tree outputs differently.

Also called: random forests, random forest algorithm, random forest classifier, random forest regression, RF.

## In plain language

A random forest is a crowd of decision trees that vote. A common configuration varies the sampled training examples and the features considered at splits, which can diversify the trees' errors. Other settings can use every training row or consider all features. For a question like whether a customer will cancel, the forest takes the majority answer, and the errors of single trees tend to cancel out. The scikit-learn guide says combining diverse trees reduces variance, which often gives a better model than one tree. The costs are that it is harder to read than a single tree, it needs more computing and memory, and it can still be wrong on data unlike what it was trained on. Someone still has to test it on examples it has not seen.

## Technical definition

In scikit-learn's default classifier configuration, trees use bootstrap samples drawn with replacement and consider a random subset of features at each split. Setting bootstrap=False uses all training rows; feature subsampling depends on max_features. The guide says the purpose of these two sources of randomness is to decrease the variance of the forest estimator, and that the prediction is the average of the individual trees, which in scikit-learn means averaging probabilistic predictions rather than a single vote per tree. IBM describes the same pieces as bagging and feature randomness, with a majority vote for classification and averaging for regression. IBM says averaging uncorrelated trees lowers variance and prediction error, and lists feature importance among its uses, and time, resources and complexity as challenges.

## How it shows up when you use agents

Ask Claude Code, Codex or Cursor to predict something from a spreadsheet and a random forest is one method it may pick for a table of rows and columns. In [scikit-learn](/glossary/scikit-learn) it is `RandomForestClassifier` or `RandomForestRegressor`, and the agent may print a feature importance list with the result.

What breaks when this is misunderstood: people read the list as proof of cause, when it only shows which columns the trees split on. A forest can also reach a high score because of a leak in the data, not because it learned something real. That is a form of [overfitting](/glossary/overfitting) that the test score hides. Runs also differ from one another unless a random seed is fixed, so two runs of the same code can give slightly different numbers.

The safer habit is to ask the agent for the number of trees and depth settings, the seed, and the training and held-out scores together, with the splits checked for leaks. The catalogue has no skills for training models, so the skills on this page are data checks. A forest is a [supervised learning](/glossary/supervised-learning) method built from [decision trees](/glossary/decision-tree).

## Common confusions

- **Random forest versus decision tree.** One tree is easy to read but can overfit and can change a lot with small changes in the data. A forest averages many trees to reduce that variance, at the price of being harder to read.
- **Random forest versus other ensembles.** A forest is one kind of tree ensemble. The scikit-learn ensemble page also covers bagging, voting, stacking and gradient boosting, which combine models in other ways.
- **Reduced risk versus no risk.** IBM says averaging uncorrelated trees lowers variance and prediction error, not that overfitting disappears.
- **Feature importance versus causation.** Importance describes how the model used a column. It does not show that changing that column would change the outcome.

## Worked examples in this catalogue

### [split-leakage-check](https://skillalmanac.com/skills/skill-almanac/split-leakage-check)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A JSON report on train, validation and test files that flags duplicates, shared groups, time leakage and label leakage between the splits.

Why it exercises the concept: The catalogue has no training skills, so this is a data check. A forest can fit its training rows very closely, and a score on a test set that shares rows with them says little. This skill checks the splits.

### [data-analysis-eda](https://skillalmanac.com/skills/skill-almanac/data-analysis-eda)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A fixed exploratory-analysis procedure and CSV profiler that keeps findings descriptive, evidenced and caveated.

Why it exercises the concept: Not a training skill. Profiling a table first shows its columns, missing values and class balance, which is what a forest will be trained on.

### [mock-record-generator](https://skillalmanac.com/skills/skill-almanac/mock-record-generator)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Seeded mock records as CSV or JSON from a JSON field list or a simple TypeScript interface.

Why it exercises the concept: Not a training skill. Seeded fake records give a small repeatable table for a first try at a forest. Random forests are themselves random, so fixing a seed is how a run is repeated.

## Related terms

- [Decision tree](https://skillalmanac.com/glossary/decision-tree.md)
- [Supervised learning](https://skillalmanac.com/glossary/supervised-learning.md)
- [Overfitting](https://skillalmanac.com/glossary/overfitting.md)
- [Machine learning algorithm](https://skillalmanac.com/glossary/machine-learning-algorithm.md)
- [scikit-learn](https://skillalmanac.com/glossary/scikit-learn.md)
- [Machine learning (ML)](https://skillalmanac.com/glossary/machine-learning.md)

## Sources

- [What is random forest?](https://www.ibm.com/think/topics/random-forest), IBM (accessed 2026-11-24)
- [Ensembles: Gradient boosting, random forests, bagging, voting, stacking](https://scikit-learn.org/stable/modules/ensemble.html), scikit-learn user guide (accessed 2026-11-24)
- [RandomForestClassifier: bootstrap and max_features parameters](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html), scikit-learn (accessed 2026-11-25)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
