การคำนวณค่าความแม่นยำ: Recall
Recall score เป็นอีกหนึ่งค่าเมตริกสำคัญที่ใช้วัดความแม่นยำของอัลกอริทึมการจำแนกประเภท คำนวณจากสัดส่วนของ True Positives หารด้วยผลรวมของ True Positives และ False Negatives หรือ $$\frac{\text{# of True Positives}}{\text{# of True Positives} + \text{# of False Negatives}}.$$
หากไม่มี False Negatives เลย ค่า recall score จะเท่ากับ 1 หากไม่มี True Positives เลย ค่า recall score จะเท่ากับ 0
ในแบบฝึกหัดนี้ จะคำนวณ recall score (โดยใช้ฟังก์ชัน recall_score จาก sklearn) สำหรับโมเดลการจำแนกประเภทเริ่มต้น
ตัวแปร features_test และ target_test พร้อมใช้งานในพื้นที่ทำงานแล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
HR Analytics: การพยากรณ์การลาออกของพนักงานด้วย Python
คำแนะนำการฝึกหัด
- Import ฟังก์ชันสำหรับคำนวณ recall score
- ใช้โมเดลเริ่มต้นเพื่อพยากรณ์การลาออก (จากฟีเจอร์ของชุดทดสอบ)
- คำนวณ recall score โดยเปรียบเทียบ
target_testกับผลการพยากรณ์
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Import the function to calculate recall score
from sklearn.____ import ____
# Use the initial model to predict churn
prediction = model.____(features_test)
# Calculate recall score by comparing target_test with the prediction
____(target_test, ____)