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
- Draw random samples of the data, bootstrapping.
- Train a decision tree on each with random feature subsets.
- Another tree gets a different sample.
- Trees predict independently and vote.
- 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
- Open the interactive lesson, with a mini quiz.
- Take the AI & Machine Learning quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- 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?
Where do people use Random Forests?
What is the most common mistake with Random Forests?
What should I learn before this topic?
How can I practice it?
Is Random Forests hard to learn?
How long does it take to learn Random Forests?
Which topics are related to Random Forests?
What should I study after Random Forests?
Related topics
- Support Vector Machines (AI & Machine Learning)
- Gradient Boosting (AI & Machine Learning)
- Naive Bayes (AI & Machine Learning)
- Feature Engineering (AI & Machine Learning)
- Random Variables (Math for Computing)