Prepare for cross-validated performance
Now that you know how to calculate the performance metrics for a single model, you are now ready to expand this for all the folds in the cross-validation data frame.
This exercise is part of the course
Machine Learning in the Tidyverse
Exercise instructions
- Add the
validate_actual
binary column for each cross-validation fold by converting all"Yes"
values toTRUE
. - Use
model
to predict the probabilities of attrition for each cross-validation fold ofvalidate
. Convert the predicted probabilities to a binary vector, treating all probabilities greater than 0.5 as TRUE. Name this columnvalidate_predicted
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
cv_prep_lr <- cv_models_lr %>%
mutate(
# Prepare binary vector of actual Attrition values in validate
validate_actual = map(validate, ~.x$___ == "___"),
# Prepare binary vector of predicted Attrition values for validate
validate_predicted = map2(.x = ___, .y = ___, ~predict(.x, .y, type = "response") > ___)
)