首页 > 解决方案 > 如何在 Jupyter 中放大 XGBClassifier plot_importance 大小?

问题描述

在我的 Jupyter 笔记本中,我有:

from xgbost import plot_importance

plot_importance(model)
pyplot.show()

由于模型有很多特征,所以输出的图表是不可读的。如何使图表变大?

标签: pythonmatplotlibxgboost

解决方案


您可能希望创建图形以绘制到 xgboost 绘图函数的外部。这将允许您将大小设置为您喜欢的任何内容。

fig, ax = plt.subplots(figsize=(10,8))
plot_importance(model, ax=ax)

或者,您可以让绘图功能按照您的方式创建图形,然后更改其大小。

ax = plot_importance(model)
ax.figure.set_size_inches(10,8)

推荐阅读