ROC Curve
เมื่อสร้างโมเดล logistic regression สำหรับพยากรณ์สถานะโรคเบาหวานแล้ว ลองพล็อต ROC curve เพื่อดูว่า true positive rate และ false positive rate เปลี่ยนแปลงอย่างไรเมื่อปรับ decision threshold
ป้าย y_test และความน่าจะเป็นที่โมเดลพยากรณ์ว่าข้อมูลทดสอบอยู่ในคลาสบวก y_pred_probs ได้ถูกโหลดไว้ให้แล้ว พร้อมกับ matplotlib.pyplot ในชื่อ plt
จากนั้นให้สร้าง ROC curve และแปลผลที่ได้
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Supervised Learning ด้วย 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()