xgboost情节重要性数字大小

Geo*_*ler 4 python matplotlib scikit-learn xgboost

如何更改xgboost的绘图重要性函数的数字大小?

尝试传递figsize =(10,20)失败,但未知属性除外.

AJ *_*ete 17

您可以在ax参数中传递轴plot_importance().例如,使用此包装器:

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)
Run Code Online (Sandbox Code Playgroud)

然后使用my_plot_importance()而不是plot_importance()


Rom*_*rac 11

您还可以使用以下命令设置图形大小:

from xgboost import plot_importance
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = (14, 7)
plot_importance(booster=booster)
Run Code Online (Sandbox Code Playgroud)