Session Ready
Exercise

Build a random forest model

Here you will use the same cross-validation data to build (using train) and evaluate (using validate) random forests for each partition. Since you are using the same cross-validation partitions as your regression models, you are able to directly compare the performance of the two models.

Note: We will limit our random forests to contain 100 trees to ensure they finish fitting in a reasonable time. The default number of trees for ranger() is 500.

Instructions
100 XP
  • Use ranger() to build a random forest predicting life_expectancy using all features in train for each cross validation partition.
  • Add a new column validate_predicted predicting the life_expectancy for the observations in validate using the random forest models you just created.