开始使用免费开始使用

评估您的集成模型

在上一个练习中,您构建了第一个投票分类器。现在我们来评估它,并与各个单模型进行比较。

各个模型(clf_knnclf_dtclf_lr)以及投票分类器(clf_vote)都已加载并完成训练。

请记得使用 f1_score() 来评估性能。此外,您还将使用 classification_report() 函数,在测试集(X_testy_test)上生成一个分类报告

您的投票分类器能超过决策树 58% 的 F1 分数吗?

本练习是课程的一部分

Python 中的集成方法

查看课程

练习说明

  • 使用投票分类器 clf_vote 对测试集 X_test 进行标签预测。
  • 计算该投票分类器的 F1 分数。
  • 调用 classification_report(),传入 y_testpred_vote,计算该投票分类器的分类报告。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# 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)
编辑并运行代码