Random Forest Algorithm in Python

Premium

The Random Forest algorithm can be described in the following conceptual steps:

  • Select k features randomly from the dataset and build a decision tree from those features where k < m (total number of features)
  • Repeat this n times in order to have n decision trees from different random combinations of k features. 
  • Take each of the n built Decision Trees and pass a random variable to predict the outcome and store this outcome to get a total of n outcomes from n decision trees.
  • If the target variable is a categorical variable, each tree in the forest would predict the category to which the new record belongs and the new record is assigned to the category that has the majority vote. 
  • If the target variable is a continuous variable, each tree in the forest predicts a value for the target variable and the final value is calculated by taking the average of all the values predicted by the trees that are part of the forest.

Unlock Premium Content

Upgrade your account to access the full article, downloads, and exercises.

You'll get access to:

  • Access complete tutorials and examples
  • Download source code and resources
  • Follow along with practical exercises
  • Get in-depth explanations