为什么 xgboost 显示最后一棵树中未显示的具有重要特征的特征?

Why xgboost show features of feature importance which doen't shown in last tree?

我的数据集有 7 个特征。 我是 运行 xgboost 并绘制了最后一棵树:

plot_tree(model, num_trees = model.n_estimators-1)

我正在绘制特征重要性:

plot_importance(model)

xgboost 使用所有树进行预测。 (每个树叶都会为最终预测添加一些值)因此你看到了 7 个特征。

我建议您观看有关 xgboost 工作原理的视频教程: XGBoost Part 2 (of 4): Classification