अपने एन्सेम्बल का मूल्यांकन
पिछले अभ्यास में, आपने अपना पहला voting classifier बनाया था. अब इसे evaluate करते हैं और अलग-अलग मॉडलों के प्रदर्शन से तुलना करते हैं.
इंडिविजुअल मॉडल्स (clf_knn, clf_dt, और clf_lr) और voting classifier (clf_vote) पहले से लोड और ट्रेन किए जा चुके हैं.
परफॉर्मेंस के लिए f1_score() का उपयोग करना याद रखें. इसके अलावा, आप टेस्ट सेट (X_test, y_test) पर classification_report() फंक्शन का उपयोग करके एक classification report बनाएँगे.
क्या आपका voting classifier, decision tree के 58% F1-score को हरा पाएगा?
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Ensemble Methods
अभ्यास निर्देश
- Voting classifier
clf_voteका उपयोग करके टेस्ट सेटX_testके लेबल्स को predict करें. - Voting classifier का F1-Score निकालें.
y_testऔरpred_voteपास करकेclassification_report()की मदद से voting classifier का 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)