梯度提升正负类在python中的重要性

我正在使用梯度提升来预测分类问题的特征重要性,其中一类是成功的而另一类是失败的。但是,我的模型只是预测特征对于肯定类别的重要性。有人可以协助预测正面和负面类的特征重要性。 Sample data

# code that I used for above feature importance                         
 x.columns = \[x.lower() for x in x.columns\] gb=
GradientBoostingClassifier(learning_rate= 0.1,max_depth=
 4,n_estimators=500,max_features = 0.9,min_samples_leaf = 2)
 x.columns = [x.lower() for x in x.columns]

feature_importance = gb.feature_importances_
# make importances relative to max importance
#feature_importance = 100.0 * (feature_importance / feature_importance.max())
sorted_idx = np.argsort(feature_importance)
pos = np.arange(sorted_idx.shape[0]) + .5
# plt.subplot(1,2,2)
#colors=['o','b','g','y','k','#66b3ff','#99ff99','#ff9999']
plt.figure(figsize=(8,8))
plt.barh(pos,feature_importance[sorted_idx],align='center',color=colors)
plt.yticks(pos,x.keys()[sorted_idx])
plt.xlabel('Relative Importance')
plt.title('Variable Importance for Gradient Boost')
plt.show()

should output figure like this one

enter image description here

iCMS 回答:梯度提升正负类在python中的重要性

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2036031.html

大家都在问