LearnViz CompSci
Home / Learn / AI & Machine Learning / Random Forests

Intermediate Topic 23 of 51 AI & Machine Learning

Random Forests

Ensembles of decision trees voting together.

How it works

A random forest is an ensemble of many decision trees trained on different bootstrap samples of the data, with each split considering only a random subset of features. Predictions are averaged for regression or taken by majority vote for classification. The randomness decorrelates the trees, so averaging reduces variance without increasing bias much, and out-of-bag samples provide a built-in validation estimate. It also gives feature importance scores.

Step-by-step walkthrough

  1. Draw random samples of the data, bootstrapping.
  2. Train a decision tree on each with random feature subsets.
  3. Another tree gets a different sample.
  4. Trees predict independently and vote.
  5. Averaging many different trees reduces variance.

Where it is used

Tabular data problems in finance, healthcare, marketing and ecology, quick strong baselines and feature selection use random forests, which need little tuning.

Common pitfall

They are less interpretable than a single tree and large forests use memory and prediction time. Importance measures can be biased toward high-cardinality features. They cannot extrapolate beyond the training range and are often outperformed by gradient boosting. Tune the number of trees, maximum depth, minimum leaf size and features per split, and use permutation importance for more reliable rankings.

Where it fits in the course

Random Forests is topic 23 of 51 in AI & Machine Learning, rated Intermediate. It follows Support Vector Machines. The next topic is Gradient Boosting.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the AI & Machine Learning quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Random Forests?
Ensembles of decision trees voting together. It belongs to AI & Machine Learning and is an intermediate-level topic.
Where do people use Random Forests?
Tabular data problems in finance, healthcare, marketing and ecology, quick strong baselines and feature selection use random forests, which need little tuning.
What is the most common mistake with Random Forests?
They are less interpretable than a single tree and large forests use memory and prediction time.
What should I learn before this topic?
Start with Support Vector Machines, the topic just before it in AI & Machine Learning.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the AI & Machine Learning quiz.
Is Random Forests hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn Random Forests?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Random Forests?
Support Vector Machines, Gradient Boosting, Naive Bayes are closely connected. The full list is in the related topics section of this page.
What should I study after Random Forests?
Continue with Gradient Boosting, the next topic in AI & Machine Learning.

Related topics