如何在 Jupyter 中扩大 XGBClassifier plot_importance 的大小?

How to enlarge XGBClassifier plot_importance size in Jupyter?

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

from xgbost import plot_importance

plot_importance(model)
pyplot.show()

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

你为什么不做

import matplotlib.pyplot as plt
plt.figure(figsize=(X,Y))

在你的 plot_importance(model) 电话之前?

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

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

或者,您可以让绘图函数按您的要求创建图形,然后再更改其大小。

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