What is Random forests

Understanding Random Forests


  • Random Forestis an ensemble learning method for classification, regression and other tasks
  • It operates by constructing multitude of decision trees at training time and outputting the class that is the mode of the classes (classification) of the individual trees
  • In case of regression, it outputs the average prediction of the individual trees.
  • Random forest corrects the tendency of decision tree to overfit on their training set.

Components of Random Forest:

A typical random forest consists of the following components:

  • Random Sampling: Random Samples are taken from the dataset to build the decision trees.
  • Bootstrapping: The random samples are created using bootstrapping, which is a method of creating multiple datasets from a single dataset by resampling with replacement.
  • Decision Trees: A set of unpruned decision trees is generated in random forest.
  • Random features: At each decision-node, a random sample of features are taken from the total features available.
  • Aggregating: The final output of random forest is obtained by aggregating the outputs of individual decision trees.

Advantages of Random Forests:

  • Reduces variance: Random Forest can reduce variance and over-fitting which are the major drawbacks of decision trees.
  • Handles large datasets: Random Forestcan handle large datasets with high dimensionality.
  • Supports Mixed dataset: Random Forestcan work with mixed feature sets (continuous and categorical).
  • Improved Accuracy: Random Forest generally has a higher accuracy compared to decision trees.
  • High interpretability: Random forests are easier to interpret and explain when compared to other algorithms.
  • Robust to outliers: Outliers have a minor effect on the Random Forest algorithm due to the use of numerous decision trees.

Disadvantages of Random Forests:

  • Random forests can be computationally intensive and slow:
  • Training takes relatively longer times due to the high number of decision trees.
  • Accuracy can be affected by noisy datasets:
  • Random forests are not well-suited for data with a lot of missing values.

Random Forest Applications:

  • Classification: Random Forest can be used for classification tasks, such as predicting whether or not a customer is likely to churn, or detecting spam emails
  • Regressions: Random Forest can be used for regression tasks, such as predicting the price of a car based on its characteristics.
  • Feature Importance: Random Forest can be used to determine feature importance in a dataset.
  • Anomaly Detection: Random forest can be used to identify anomalies in a dataset.


Random forest is a powerful and versatile algorithm that can be used for both classification and regression tasks, can handle large datasets, and is robust to outliers. However, it can be computationally intensive and accuracy can be hampered by noisy datasets. Despite these drawbacks, it is still one of the most popular machine learning algorithms used today.