#y = bst.predict(sub_trainning_data)
feature_score = bst.get_fscore()
feature_score = sorted(feature_score.items(), key=lambda x:x[1],reverse = True)
fs = []
for (key,value) in feature_score:
fs.append("{0},{1}\n".format(key,value))
with open('../sub/submission.csv','w') as f:
f.writelines("feature,fscore\n")
f.writelines(fs)
df = pd.DataFrame(feature_score , columns=['feature', 'fscore'])
df['fscore'] = df['fscore'] / df['fscore'].sum()
featp = df.plot(kind='barh', x='feature', y='fscore', legend=False, figsize=(6, 10))
plt.title('XGBoost Feature Importance')
plt.xlabel('relative importance')
XGBOOST查看特征分数
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 这是Regression-房价预测的第(2)篇笔记。介绍outline里的: Load data Data exp...
- 我是用 jupyter notebook写的,各个功能模块清楚分明,顺便推荐给大家。 以图片分类为例: 主要依赖于...
- Is He Mr Right? : Everything you need to know before ...