【发布时间】:2017-02-26 04:07:17
【问题描述】:
如何更改xgboost的绘图重要性函数的图形大小?
尝试传递 figsize=(10,20) 失败,但出现未知属性。
【问题讨论】:
标签: python matplotlib scikit-learn xgboost
如何更改xgboost的绘图重要性函数的图形大小?
尝试传递 figsize=(10,20) 失败,但出现未知属性。
【问题讨论】:
标签: python matplotlib scikit-learn xgboost
您可以在plot_importance() 的ax 参数中传递一个轴。例如,使用这个包装器:
def my_plot_importance(booster, figsize, **kwargs):
from matplotlib import pyplot as plt
from xgboost import plot_importance
fig, ax = plt.subplots(1,1,figsize=figsize)
return plot_importance(booster=booster, ax=ax, **kwargs)
然后用my_plot_importance()代替plot_importance()
【讨论】:
您还可以使用以下方法设置图形大小:
from xgboost import plot_importance
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (14, 7)
plot_importance(booster=booster)
【讨论】:
仅将plt.rcParams["figure.figsize"] = (20,50) 添加到您的代码中
例如:
from xgboost import plot_importance
plt.figure(figsize=(40,20))
plot_importance(model,max_num_features=100)
plt.rcParams["figure.figsize"] = (20,100)
plt.show()
调整 (20,100) 以放大或缩小图像尺寸
【讨论】: