Random Forest Classification-R

0
154

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.

RC_F1

Step: 2 Import the Data set:

RC_F2

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.

RC_F3

Step:4 In this analysis we would use just last three columns. So we would select last three columns using the following command

RC_F4

Step5: Change the Response variable to Factors

RC_F5

Step 6: Define the Classifier

RC_F6

Step 7: Predicting the Test Results

RC_F7

Step 8: Checking the accuracy with confusion matrix.

RC_F8

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here