The best performing parameter
You've now built models where you've varied the random forest-specific hyperparameter mtry
in the hopes of improving your model further. Now you will measure the performance of each mtry
value across the 5 cross validation partitions to see if you can improve the model.
Remember that the validate MAE you calculated two exercises ago of 0.795
was for the default mtry
value of 2.
Este exercício faz parte do curso
Machine Learning in the Tidyverse
Instruções do exercício
- Generate predictions for each mtry/fold combination.
- Calculate the MAE for each mtry/fold combination.
- Calculate the mean MAE for each value of
mtry
.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Generate validate predictions for each model
cv_prep_tunerf <- cv_model_tunerf %>%
mutate(validate_predicted = map2(.x = ___, .y = ___, ~predict(.x, .y)$predictions))
# Calculate validate MAE for each fold and mtry combination
cv_eval_tunerf <- cv_prep_tunerf %>%
mutate(validate_mae = map2_dbl(.x = ___, .y = ___, ~mae(actual = .x, predicted = .y)))
# Calculate the mean validate_mae for each mtry used
cv_eval_tunerf %>%
group_by(___) %>%
summarise(mean_mae = mean(___))