ROC 曲線
你已經建立了一個用於預測糖尿病狀態的邏輯斯回歸模型,現在可以繪製 ROC 曲線,來視覺化當決策閾值改變時,真正率與假正率如何變化。
測試標籤 y_test,以及測試特徵屬於正類的預測機率 y_pred_probs 已為你預先載入,matplotlib.pyplot 也已以 plt 名稱載入。
你將建立一條 ROC 曲線,然後解讀結果。
本練習屬於課程
使用 scikit-learn 進行監督式學習
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# 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()