In this topic we would implement Random Forest classifier, using R. We would try to understand practical application of Random Forest and codes used for classifier. As we have understood in our previous topic a random forest classifier is a group of decision tree classifier. We will also see as we increase the number of trees, the predictive power of the Random Forest classifier increases.
Let us look into codes step by step.
Step: 1 First setup the working library for the R-Studio or whichever interface you are using. We set a working library as it becomes easier to import the stored data set or even while saving final codes.
Step: 2 Import the Data set:
Dataset consist of Account Number of the customer, Gender, Age, Salary and Default Status.
Step: 3 We would use “randomForest” package to while working with Random Forest. First try to install the package using the following code.
Step:4 In this analysis we would use just last three columns. So we would select last three columns using the following command
Step5: Change the Response variable to Factors
Step 6: Define the Classifier
Step 7: Predicting the Test Results
Step 8: Checking the accuracy with confusion matrix.