ComeçarComece de graça

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.

Este exercício faz parte do curso

Machine Learning in the Tidyverse

Ver curso

Instruções do exercício

  • Add the validate_actual binary column for each cross-validation fold by converting all "Yes" values to TRUE.
  • Use model to predict the probabilities of attrition for each cross-validation fold of validate. Convert the predicted probabilities to a binary vector, treating all probabilities greater than 0.5 as TRUE. Name this column validate_predicted.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

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") > ___)
  )
Editar e executar o código