Random Forest explained
Mohammad Arshad
CEO DecodingDataScience.com | ?? AI Community Builder (150K+)| Data Scientist | Strategy & Solutions | Generative AI | 20 Years+ Exp | Ex- MAF, Accenture, HP, Dell | Global Keynote Speaker & Mentor | LLM, AWS, Azure, GCP
A random forest merges a collection of independent decision trees to get a more accurate and stable prediction
Random forest is a type of ensemble method, ensemble method combine several machine learning models in order to decrease both bias and variance.
Multiple models are fit and each key in a different aspect of the data, and combining all these models ultimately generates better predictions together than any of the single models on their own.
In Training Data , this algorithm will take N sample from the training data with replace so one record can be present in multiple samples , then next step is to take sample of features to be used for each of the data samples.
So we have N subset of our overall data and those data contains both subset of rows and subset of column(features).
Then for each feature and data subset the algorithm will built a decision tree to try generate the most accurate results, these decision trees are developed independently. So that each decision tree key in different relationship in the data , this will ultimately result in best prediction.
To test the model, Now we will pass example A from the test data to all n trees built in training data, based on the features the model will give a prediction 'Survive'. Now the splits and features on the 2nd decision tree will be totally different, so it will be possible to get a different Prediction 'Did Not Survive' . So now you will have n predictions for example A , one from each tree , then the random forest algorithm will basically just aggregate all the predictions together and then based on voting, with majority rules will make a final predication - So in this case it will say that the person has 'Survived'
* Illustration from Titanic data and prediction is for each person whether he/she will survive or not survive
In the next article will write how to tune the Random forest model and interpret the results, Please like , share and comment if any questions.