การวัดประสิทธิภาพของโมเดล Logistic Regression
มีหลายตัวชี้วัดที่ใช้ประเมินประสิทธิภาพของโมเดล logistic regression ในแบบฝึกหัดสุดท้ายนี้ จะได้คำนวณ accuracy, sensitivity และ specificity ด้วยตนเอง โดยอ้างอิงจากนิยามต่อไปนี้:
Accuracy คือสัดส่วนของการพยากรณ์ที่ถูกต้องทั้งหมด $$ \text{accuracy} = \frac{TN + TP}{TN + FN + FP + TP} $$
Sensitivity คือสัดส่วนของข้อมูลที่มีค่า จริง ซึ่งโมเดลพยากรณ์ได้ถูกต้องว่าเป็น จริง $$ \text{sensitivity} = \frac{TP}{TP + FN} $$
Specificity คือสัดส่วนของข้อมูลที่มีค่า เท็จ ซึ่งโมเดลพยากรณ์ได้ถูกต้องว่าเป็น เท็จ $$ \text{specificity} = \frac{TN}{TN + FP} $$
churn, mdl_churn_vs_relationship และ conf_matrix พร้อมใช้งานแล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การถดถอยเบื้องต้นด้วย statsmodels ใน Python
คำแนะนำการฝึกหัด
- ดึงค่า true positives (
TP), true negatives (TN), false positives (FP) และ false negatives (FN) จากconf_matrix - คำนวณค่า
accuracyของโมเดล - คำนวณค่า
sensitivityของโมเดล - คำนวณค่า
specificityของโมเดล
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Extract TN, TP, FN and FP from conf_matrix
TN = ____
TP = ____
FN = ____
FP = ____
# Calculate and print the accuracy
accuracy = ____
print("accuracy: ", accuracy)
# Calculate and print the sensitivity
sensitivity = ____
print("sensitivity: ", sensitivity)
# Calculate and print the specificity
specificity = ____
print("specificity: ", specificity)