应用评分的堆叠预测
一旦构建好堆叠估计器,您就可以将其拟合到训练集上。然后,便可以进行步骤 5:使用堆叠集成进行预测。
堆叠分类器已作为 clf_stack 提供给您。
让我们获取最终预测,并看看通过堆叠是否带来了性能提升。
本练习是课程的一部分
Python 中的集成方法
练习说明
- 在训练集上拟合堆叠分类器。
- 在测试集上使用堆叠估计器计算最终预测。
- 使用准确率在测试集上评估模型性能。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Fit the stacking classifier to the training set
____
# Obtain the final predictions from the stacking classifier
pred_stack = ____
# Evaluate the new performance on the test set
print('Accuracy: {:0.4f}'.format(____))