当前位置: 首页>>代码示例>>Python>>正文


Python DecisionTreeClassifier.booster方法代码示例

本文整理汇总了Python中sklearn.tree.DecisionTreeClassifier.booster方法的典型用法代码示例。如果您正苦于以下问题:Python DecisionTreeClassifier.booster方法的具体用法?Python DecisionTreeClassifier.booster怎么用?Python DecisionTreeClassifier.booster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.tree.DecisionTreeClassifier的用法示例。


在下文中一共展示了DecisionTreeClassifier.booster方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: normalize

# 需要导入模块: from sklearn.tree import DecisionTreeClassifier [as 别名]
# 或者: from sklearn.tree.DecisionTreeClassifier import booster [as 别名]
# test['logvar38'] = test['var38'].map(np.log1p)
# # Encode var36 as category
# test['var36'] = test['var36'].astype('category')
# test = pd.get_dummies(test)
test_normalized = normalize(test, axis=0)
test_pca = pca.fit_transform(test_normalized)
test['PCA1'] = test_pca[:,0]
test['PCA2'] = test_pca[:,1]
sel_test = test[features]
sel_test = fs.transform(sel_test)
probs = clf.predict_proba(sel_test, ntree_limit=clf.best_iteration)

submission = pd.DataFrame({"ID":test.index, "TARGET":probs[:,1]})
submission.to_csv("submission.csv", index=False)


# plot feature importance
print 'plot feature importance ...'
#mapFeat = dict(zip(["f"+str(i) for i in range(len(features))],features))
mapFeat = dict(zip(features,features))

ts = pd.Series(clf.booster().get_fscore())
#ts.index = ts.reset_index()['index'].map(mapFeat)
ts.sort_values()[-15:].plot(kind="barh", title=("features importance"))

featp = ts.sort_values()[-15:].plot(kind='barh', x='feature', y='fscore', legend=False, figsize=(6, 10))
plt.title('XGBoost Feature Importance')
fig_featp = featp.get_figure()
fig_featp.savefig('feature_importance_xgb.png', bbox_inches='tight', pad_inches=1)

开发者ID:clover9gu,项目名称:simplemining,代码行数:31,代码来源:classifier.py


注:本文中的sklearn.tree.DecisionTreeClassifier.booster方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。