Random Forest
Setting Up a Random Forest Classifier
Note: Make sure you have your training and test data already vectorized and ready to go before you begin trying to fit the machine learning model to unprepped data.
Load in required libraries
Initialize Random Forest object
Create a parameter grid for tuning the model
Define how you want the model to be evaluated
Define the type of cross-validation you want to perform
Fit the model to the data
Score the testing dataset using your fitted model for evaluation purposes
Evaluate the model
Note: When you use the CrossValidator
function to set up cross-validation of your models, the resulting model object will have all the runs included, but will only use the best model when you interact with the model object using other functions like evaluate
or transform
.
Last updated