Aan de slagGa gratis aan de slag

Create a confusion matrix

As you saw in the video, a confusion matrix can be used to determine how well your model is performing. However, before creating the confusion matrix, you need to classify the predicted probabilities as 1 or 0, by using a cut-off.

Note: 1 means Inactive while 0 is Active.

prediction_test, which contains the predicted probabilities of turnover for all cases in test_set is available in your workspace.

Deze oefening maakt deel uit van de cursus

HR Analytics: Predicting Employee Churn in R

Cursus bekijken

Oefeninstructies

  • Turn the numeric predictions in prediction_test into a vector of categorical predictions using a cut-off of 0.5.
  • Create the confusion matrix using prediction_categories and actual values in the test set (test_set$turnover).

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Classify predictions using a cut-off of 0.5
prediction_categories <- ___(prediction_test > 0.5, 1, 0)

# Construct a confusion matrix
conf_matrix <- ___(prediction_categories, test_set$turnover)
conf_matrix
Code bewerken en uitvoeren