全部,
我想绘制以下内容:
我有一个二进制分类问题,我在下面使用 xgboost 作为我的“模型”:
y_pred = model.predict_proba(x_test)[:, 1]
probabilities = pd.DataFrame({
'prediction': y_pred,
'output': y_true
})
colors = ['g', 'r']
for output in [0, 1]:
probabilities[probabilities['output'] == output]['prediction'] \
.plot(kind='kde', ax=ax2, legend=True, color=colors[output])
ax2.set_xlim(prob_xlims)
ax2.set_xlabel('Predicted probability')
ax2.set_title('Predicted probabilities and true labels (color)')
# Legend
handles, labels = ax2.get_legend_handles_labels()
ax2.legend(handles, ['Class 0', 'Class 1'])
使用上面我怎样才能得到一个类似于上面的情节?如果错了也请纠正我,但predict_proba会返回其中数据样本是单行数据..?
