如果列名包含汉字,需要设置字体
import lightgbm as lgb
import xgboost as xgb
from matplotlib import pyplot as plt
####lgb,xgb训练完成后............
#设置字体
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 使显示图标自适应
plt.rcParams['figure.autolayout'] = True
plt.figure(figsize=(16,10))
#lgb权值图
lgb.plot_importance(model_lgb, max_num_features=30)
plt.title("Featurertances")
plt.show()
#xgb权值图
from xgboost import plot_importance
plot_importance(model_xgb)