ประเมินผล Ensemble ของคุณ
ในแบบฝึกหัดก่อนหน้า คุณได้สร้าง voting classifier ตัวแรกแล้ว มาประเมินผลและเปรียบเทียบกับโมเดลแต่ละตัวกัน
โมเดลแต่ละตัว (clf_knn, clf_dt และ clf_lr) รวมถึง voting classifier (clf_vote) ถูกโหลดและฝึกเรียบร้อยแล้ว
อย่าลืมใช้ f1_score() ในการวัดประสิทธิภาพ นอกจากนี้ยังจะสร้าง classification report บนชุดทดสอบ (X_test, y_test) โดยใช้ฟังก์ชัน classification_report()
voting classifier จะทำคะแนน F1-Score เกิน 58% ของ decision tree ได้หรือไม่?
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Ensemble Methods ใน Python
คำแนะนำการฝึกหัด
- ใช้ voting classifier
clf_voteเพื่อทำนายป้ายกำกับของชุดทดสอบX_test - คำนวณ F1-Score ของ voting classifier
- คำนวณ classification report ของ voting classifier โดยส่ง
y_testและpred_voteให้กับclassification_report()
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Calculate the predictions using the voting classifier
pred_vote = ____
# Calculate the F1-Score of the voting classifier
score_vote = ____
print('F1-Score: {:.3f}'.format(score_vote))
# Calculate the classification report
report = ____
print(report)