ML0063 Random Forest

How does the random forest algorithm operate? Please outline its key steps.

Answer

Random Forest builds an ensemble of decision trees, each trained on a bootstrapped sample of the data with a random feature subset considered at each split. This combination reduces variance, combats overfitting, and improves predictive accuracy; the final output aggregates all trees’ predictions: majority vote for classification, averaging for regression.

(1) Bootstrap Sampling: Create multiple subsets of the training data by sampling with replacement (bootstrap samples).
(2) Grow Decision Trees: Train an unpruned decision tree on each bootstrap sample.
(3) Random Feature Selection: At every split in every tree, consider only a random subset of features; this increases diversity between trees.
(4) Aggregate: Classification: each tree votes for a class and the majority wins; regression: the tree outputs are averaged.

Three individual tree decision boundaries with different jagged artifacts and the smoother random forest ensemble boundary

Figure 1: Three trees, three different jagged boundaries: each overfits its own bootstrap sample in its own way. The ensemble’s boundary (bottom right) averages the votes and lands smoother and closer to the true structure: the trees’ individual errors cancel.

Mathematical Formulation:
\hat{y} = \mathrm{mode}\big\{ T_b(x) \big\},\quad b = 1, \ldots, B
\hat{y} = \frac{1}{B} \sum_{b=1}^{B} T_b(x)

Where:

  • T_b(x) is the prediction of the b-th tree for input x.
  • B is the total number of trees in the forest.
  • First line: classification by majority vote (mode); second line: regression by averaging.
Flowchart from training data through bootstrap samples into three trees and a majority vote box producing the final prediction

Figure 2: The full pipeline: B bootstrap replicas of the training set feed B independently grown trees (each with random feature subsets at its splits), and a majority-vote / averaging box fuses their outputs into one robust prediction.


Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *