ComenzarEmpieza gratis

Predictions of a single model

To calculate the performance of a classification model you need to compare the actual values of Attrition to those predicted by the model. When calculating metrics for binary classification tasks (such as precision and recall), the actual and predicted vectors must be converted to binary values.

In this exercise, you will learn how to prepare these vectors using the model and validate data frames from the first cross-validation fold as an example.

Este ejercicio forma parte del curso

Machine Learning in the Tidyverse

Ver curso

Instrucciones del ejercicio

  • Extract the model and the validate data frame from the first fold of the cross-validation.
  • Extract the Attrition column from the validate data frame and convert the values to binary (TRUE/FALSE).
  • Use model to predict the probabilities of attrition for the validate data frame.
  • Convert the predicted probabilities to a binary vector, assume all probabilities greater than 0.5 are TRUE.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Extract the first model and validate 
model <- cv_models_lr$___[[___]]
validate <- cv_models_lr$___[[___]]

# Prepare binary vector of actual Attrition values in validate
validate_actual <- ___ == "Yes"

# Predict the probabilities for the observations in validate
validate_prob <- predict(___, ___, type = "response")

# Prepare binary vector of predicted Attrition values for validate
validate_predicted <- ___
Editar y ejecutar código