IniziaInizia gratis

The ROC curve

Now you have built a logistic regression model for predicting diabetes status, you can plot the ROC curve to visualize how the true positive rate and false positive rate vary as the decision threshold changes.

The test labels, y_test, and the predicted probabilities of the test features belonging to the positive class, y_pred_probs, have been preloaded for you, along with matplotlib.pyplot as plt.

You will create a ROC curve and then interpret the results.

Questo esercizio fa parte del corso

Supervised Learning with scikit-learn

Visualizza il corso

Esercizio pratico interattivo

Prova questo esercizio completando il codice di esempio.

# Import roc_curve
____

# Generate ROC curve values: fpr, tpr, thresholds
fpr, tpr, thresholds = ____(____, ____)

plt.plot([0, 1], [0, 1], 'k--')

# Plot tpr against fpr
plt.plot(____, ____)
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('ROC Curve for Diabetes Prediction')
plt.show()
Modifica ed esegui il codice