绘制 XGBoost 模型特征重要性的增益、覆盖、权重
Plot gain, cover, weight for feature importance of XGBoost model
我有一个 XGBoost 模型 xgboost_model
。绘制此 XGBoost 模型的特征重要性;
plot_importance(xgboost_model)
pyplot.show()
该图显示了 F 分数。然而,F 分数背后有一些重要指标,如增益、覆盖率、权重。
如何单独绘制重要性指标增益、覆盖率、权重?
我正在使用 python 3.7
您可以将不同的重要性类型传递给 plot_importance
:
fig, ax = plt.subplots(3,1,figsize=(14,30))
nfeats = 15
importance_types = ['weight', 'cover', 'gain']
for i, imp_i in enumerate(importance_types):
plot_importance(xgboost_model, ax=ax[i], max_num_features=nfeats
, importance_type=imp_i
, xlabel=imp_i)
在上面的示例中,您可以构建一个 subplot
,其中包含 3 个地块,每个地块对应 plot_importance
支持的三种类型。
我在 jupyter
中对此进行了测试。否则,你会打电话给 plt.show()
.
我有一个 XGBoost 模型 xgboost_model
。绘制此 XGBoost 模型的特征重要性;
plot_importance(xgboost_model)
pyplot.show()
该图显示了 F 分数。然而,F 分数背后有一些重要指标,如增益、覆盖率、权重。
如何单独绘制重要性指标增益、覆盖率、权重?
我正在使用 python 3.7
您可以将不同的重要性类型传递给 plot_importance
:
fig, ax = plt.subplots(3,1,figsize=(14,30))
nfeats = 15
importance_types = ['weight', 'cover', 'gain']
for i, imp_i in enumerate(importance_types):
plot_importance(xgboost_model, ax=ax[i], max_num_features=nfeats
, importance_type=imp_i
, xlabel=imp_i)
在上面的示例中,您可以构建一个 subplot
,其中包含 3 个地块,每个地块对应 plot_importance
支持的三种类型。
我在 jupyter
中对此进行了测试。否则,你会打电话给 plt.show()
.