xgboost 保存模型和特征重要度

来源:互联网 发布:软件测试毕业总结 编辑:程序博客网 时间:2024/06/04 17:49

1. 保存模型:

(1)保存:

bst.save_model('0001.model')
(2)加载模型:

bst_new = xgb.Booster({'nthread':4}) #init modelbst_new.load_model("0001.model") # load data

source from:

http://blog.csdn.net/zc02051126/article/details/46771793


2.xgb 打印特征重要度:


使用f1 score来打分

import pandas as pdimport matplotlib.pylab as pltfeat_imp = pd.Series(clf.booster().get_fscore()).sort_values(ascending=False)feat_imp.plot(kind='bar', title='Feature Importances')plt.ylabel('Feature Importance Score')plt.show()
来自,余音大神的blog:

http://blog.csdn.net/q383700092/article/details/53763328



原创粉丝点击