Draw the ROC curve
Visualizing model performance with a ROC curve allows you to gather the performance across all possible thresholds into a single plot. It shows the sensitivity and specificity for every threshold. The more "up and left" a ROC curve is, the better the model.
You are going to predict class probabilities of credit card customers having churned and plot the results as a ROC curve.
Pre-loaded is a model
, which is a decision tree that was trained on the credit card customers training set, and the test data, customers_test
.
This exercise is part of the course
Machine Learning with Tree-Based Models in R
Exercise instructions
- Use
model
to predict class probabilities on the test set. - Add the results to the test set using
bind_cols()
and save the result aspredictions
. - Calculate the ROC curve of the result.
- Plot the ROC curve using
autoplot()
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Predict probabilities on test set
predictions <- predict(___,
___,
type = "___") %>%
# Add test set
___(customers_test)
# Calculate the ROC curve for all thresholds
roc <- ___(___,
estimate = ___,
truth = ___)
# Plot the ROC curve
___