MulaiMulai sekarang secara 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.

Latihan ini adalah bagian dari kursus

Supervised Learning with scikit-learn

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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()
Edit dan Jalankan Kode