What is a Random Forest and how does it make a prediction?

Last updated 5 November 2026

A Random Forest is an ensemble of decision trees. Each tree is trained on a bootstrap sample and considers random feature subsets at each split. It predicts by combining the trees: majority vote (or averaged probabilities) for classification, and the mean for regression.

  • Training: two sources of randomness:

    1. Row sampling: each tree is fit on a bootstrap sample (n rows drawn with replacement).

    2. Feature sampling: each split only searches a random subset of max_features features.

    3. Trees are usually grown deep (low bias, high variance) and are not pruned.

  • Prediction:

    • Each tree routes the sample to a leaf and outputs that leaf's class distribution or mean value.

    • Classification uses a majority vote. scikit-learn instead averages predict_proba across trees and takes the argmax.

    • Regression averages the trees' numeric predictions.

  • Why it works:

    • Averaging many diverse, weakly correlated trees cancels out their individual errors.

    • The result has much lower variance than a single tree, at roughly the same bias.

  • Practical perks:

    • Little tuning is needed.

    • Out-of-bag error gives a free validation estimate.

    • Feature importances come built in.

    • Trees are independent, so training parallelizes easily.

  • https://analyticsarora.com/8-unique-machine-learning-interview-questions-about-random-forests/
  • https://pub.towardsai.net/crack-ml-interviews-with-confidence-random-forest-20-q-a-476f0a37c645
  • https://www.reddit.com/r/datascience/comments/1ghc7xh/how_does_a_random_forest_make_predictions_on/
All Random Forests interview questions