So now let us see how to create a random forest model in our.
Again, to create random forest model, we need to use the package.
Random forest.
This is the same package we use to do bagging and Jawdat.
This package is installed and it is active.
So since this package started for me, I'll just run this Libatique a one to make sure that it is active
for me.
Next step is to use the land random forest function to create the model random for is the name of my
variable, which will contain the information from this random forest function.
The first barometer is the formula.
This is the same collection as my dependent variable, all of that on my independent ready world data
is brain data.
And three is the barometer, which specifies the maximum number of threes that this model should create.
If you remember in bagging, we used a barometer called M3 and we specified that Emtriva value should
be equal to all the other independent variables.
So we equated it to 17.
In this scenario, since Random Forest considers less number of rebuild, that is a subset of the total
predicted space.
Therefore, either we specify Emtriva less than 17.
So maybe we can say M3 is equal to five or embrace equal to six, something like that, or we do not
specify anything.
And are will use a default value.
So by default, since this is a regression model, I will use PMA three.
Since we have 17.
Predictor variables.
B by three will come out to be five point six six.
Which is nearly six.
So probably ordering take em crazy equal to six.
If you want to use other value, you can just write a comma and the best way M3 is equal to some of
that value which you want to use.
So I love this model.
And random forward variable has the information of the random forest model.
Now, using the predicate function I predicted devalues and using this formula for MASC.
I calculated the MSE for Random Forest.
Now you can see that a messy for random forest is coming out to be 41 million, nearly four bagging,
it was 54, 55 million.
So you can clearly see an improvement in the model.
There is nearly a 20 percent improvement in terms of masc of the predicted values.
So just by changing the value of M3 in this whole process, that is instead of using Embry's equal to
17.
We are using embryos equal to nearly six.
I am getting a huge improvement in prediction, accuracy of my model.
And by the way, I hope since I'm doing bagging and rainforest's only for recreation, I hope that you're
doing it for classification on your own.
You know how to run that classification model.
Only thing you need to add is another parameter here, which is method.
So that works for bagging and random forest as well.
So my suggestion is that you should go ahead and do this for classification also.
And see the improvement in classification prediction accuracy.
So do this work classification, make their confusion metrics and see the improvement in prediction,
accuracy, using, bagging and random forest.