評估你的集成模型
在前一個練習中,你建立了第一個投票分類器。現在來評估它,並與各個單一模型做比較。
個別模型(clf_knn、clf_dt、clf_lr)以及投票分類器(clf_vote)都已載入並完成訓練。
請記得使用 f1_score() 來評估效能。此外,你也會使用 classification_report() 函式,針對測試集(X_test、y_test)產生一份分類報告(classification report)。
你的投票分類器能超越決策樹的 58% F1-score 嗎?
本練習屬於課程
Python 的 Ensemble 方法
練習說明
- 使用投票分類器
clf_vote預測測試集X_test的標籤。 - 計算該投票分類器的 F1-score。
- 將
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)