Exercise

Create full random forest model

Random forest models naturally perform feature selection as they build many subtrees from random subsets of the features. One way to understand feature importances is to build a model and then extract the feature importances. So, in this exercise, you will use the Healthcare Job Attrition data to train a rand_forest() classification model from which you can extract feature importances. To make feature importances available, be sure to create the model with importance = "impurity". The train and test sets are available to you.

The tidyverse, tidymodels, and vip packages have been loaded for you.

Instructions

100 XP
  • Define a random forest classification model with 200 trees that you can use to extract feature importances.
  • Fit the random forest model with all predictors.
  • Bind the predictions to the test set.
  • Calculate the F1 metric.