ตรวจสอบความแม่นยำของการทำนาย
ถึงเวลาตรวจสอบแล้วว่าโมเดลที่เทรนไว้สามารถทำนายได้แม่นยำแค่ไหน ลองใช้ชุดข้อมูลทดสอบเพื่อวัดความแม่นยำของ Decision Tree model ด้วยเมธอด score()
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
HR Analytics: การพยากรณ์การลาออกของพนักงานด้วย Python
คำแนะนำการฝึกหัด
- นำ Decision Tree
modelมาใช้ fitfeaturesกับtargetในชุดข้อมูล Training - ตรวจสอบคะแนนความแม่นยำ
score()ของการทำนายสำหรับชุดข้อมูล Training - ตรวจสอบคะแนนความแม่นยำ
score()ของการทำนายสำหรับชุดข้อมูล Test
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Apply a decision tree model to fit features to the target in the training set
model.fit(____,____)
# Check the accuracy score of the prediction for the training set
model.____(features_train,____)*100
# Check the accuracy score of the prediction for the test set
model.____(____,____)*100