Skip to Main Content
Back to website
Read next article: Neural Networks
15 mins read

Random Forest

Random forest is a widely-used machine learning algorithm developed by Leo Breiman and Adele Cutler, known for its ability to combine the outputs of multiple decision trees to produce a single result. This algorithm is highly favored for its versatility and ease of use, handling both classification and regression tasks effectively. 

To understand random forests, it is helpful to start with the basics of decision trees. A decision tree begins with a root node, which poses a question (e.g., “Should I surf today?”). Subsequent questions, known as decision nodes, split the data based on specific criteria (e.g., “Is it a long period swell?”). These splits guide the path through the tree until a final decision is reached at a leaf node.  

Random forests enhance the predictive power of individual decision trees by employing ensemble learning, where multiple trees are generated and aggregated to produce a more accurate and robust model. The process involves two key components: Bagging (bootstrap aggregating) (Breiman, 1996) and the Classification and Regression Tree (CART) split (Breiman et al., 1984). 

Bagging, introduced by Breiman in 1996, is a technique that improves the stability and accuracy of machine learning algorithms. It involves generating multiple subsets of the original dataset through random sampling with replacement. Each subset is used to train a separate decision tree, resulting in a diverse collection of trees. The final prediction is made by averaging the predictions of all individual trees (for regression) or by majority voting (for classification). This method reduces variance and helps prevent overfitting, making the model more robust to noise and variations in the data (Breiman, 1996).

The CART algorithm, involves recursively splitting the data into subsets based on feature values that result in the most significant reduction in impurity. For classification tasks, measures like Gini impurity or information gain are used to determine the best split, while for regression tasks, mean squared error (MSE) is typically used. Each decision node in the tree represents a feature and a threshold value, guiding the data down different branches until a prediction is made at the leaf nodes. By combining multiple CART trees in a random forest, the model benefits from the strengths of each individual tree while mitigating their weaknesses (Breiman et al., 1984). 

When these two techniques are combined in a random forest, the result is a powerful ensemble model that leverages the advantages of both methods. Bagging ensures that each tree is trained on a unique subset of the data, promoting diversity among the trees. The CART algorithm optimally splits the data at each node, ensuring that each tree makes accurate and meaningful decisions. Together, they create a model that is more accurate, less prone to overfitting, and capable of handling a wide variety of data types and structures.

While single-decision trees are prone to bias and overfitting, random forests mitigate these issues by creating an ensemble of uncorrelated trees, leading to more accurate and reliable predictions. This methodology is particularly effective for large, high-dimensional datasets, making it a powerful tool for various applications.

“J. Howard (Kaggle) and M. Bowles (Biomatica) claim in Howard and Bowles (2012) that ensembles of decision trees—often known as “random forests”—have been the most successful general-purpose algorithm in modern times”
Read next article: Neural Networks