如何在 Jupyter 中放大 XGBClassifier plot_importance 大小?

use*_*836 1 python matplotlib xgboost

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

from xgbost import plot_importance

plot_importance(model)
pyplot.show()
Run Code Online (Sandbox Code Playgroud)

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

Imp*_*est 7

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

fig, ax = plt.subplots(figsize=(10,8))
plot_importance(model, ax=ax)
Run Code Online (Sandbox Code Playgroud)

或者,您可以让绘图函数创建您拥有的图形,然后更改其大小。

ax = plot_importance(model)
ax.figure.set_size_inches(10,8)
Run Code Online (Sandbox Code Playgroud)