Skip to content
CoreSource checked

Random Forest

Builds an ensemble of decision trees trained on random samples and feature subsets.

Quick Facts

Compact metadata for implementation and discovery.

Category
Machine Learning
Difficulty
Intermediate
Family
Ensemble Learning
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
5
Code example
Not ready
Visualization
Ready

Overview

A random forest trains many decision trees on bootstrapped data and randomized feature choices. Predictions are aggregated by voting or averaging, reducing variance compared with a single tree.

Core Concepts

learned parametersmodel aggregationclass decision boundarytree structureensemble learningmodel fittraining examplesprediction rule

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(t n d log n)

Average

O(t n d log n)

Worst

O(t n^2 d)

Space

O(t n)

When to Use

  • Use when a strong nonparametric baseline is needed for tabular data.
  • Use when interpretability of individual splits is less important than ensemble accuracy.

When Not to Use

  • Avoid when model size or prediction latency must be very small.
  • Avoid when extrapolation beyond the training distribution is required.

What It Does

  • Samples training data for each tree
  • Randomizes feature choices during tree splits
  • Aggregates predictions across trees

Use Cases

  • Tabular classification and regression
  • Robust baselines for mixed feature sets
  • Estimating feature importance with caution

Inputs

  • Feature matrix
  • Target labels or values
  • Number of trees

Outputs

  • Ensemble model
  • Combined prediction

Key Formulas (1)

Forest vote

prediction = majorityvote(tree1(x), tree2(x), …, treen(x))
prediction = majority_vote(tree_1(x), tree_2(x), ..., tree_n(x))

Combines individual tree predictions into one ensemble prediction.

Pseudocode

  1. 1.For each tree in the ensemble
  2. 2.Sample training rows with replacement
  3. 3.Grow a decision tree using random feature subsets at splits
  4. 4.Store the trained tree
  5. 5.For prediction, aggregate tree votes or averages

Canonical Example

Input
training rows with features [age, income] and label approved/not approved
Output
many trees whose votes produce the final class
Explanation
Each tree sees a randomized view of the data, and the forest aggregates their predictions.

Implementation Notes

  • Keep preprocessing inside the train/validation split.
  • Tune tree count, depth, leaf size, and feature subsampling together.
  • Evaluate with out-of-bag or held-out metrics, not training accuracy.

Common Pitfalls

  • Leaking validation data through preprocessing gives inflated accuracy.
  • Too few trees can make results unstable.
  • Default feature-importance measures can be biased toward high-cardinality features.

Interactive Mechanism Walkthrough

Iterative Convergence & State Trajectory

Show several trees voting into one final prediction.

Random Forest mechanism walkthrough step 1 of 5x₀x₁x₂x*
Step 1 of 5: For each tree in the ensemble
forest-voting

Notes

Random forests are strong baselines, but validation design still controls whether the result is trustworthy.

Sources (1)

What each reference supports for this entry.

Breiman 2001

Paper

Original random forests paper for tree ensemble learning.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

A random forest is an ensemble of decision trees.

Alternative toGradient Boosting

Random forests average independently trained trees, while boosting trains trees sequentially.

Tags

Machine LearningEnsembleClassificationTree