def plot_roc_curve(y_true, y_score, ax=None):
'''
Plot the Receiving Operator Characteristic curved, including the
Area under the Curve (AUC) score.
Parameters
----------
y_true : array
y_score : array
ax : matplotlib.axes, defaults to new axes
Returns
-------
ax : matplotlib.axes
'''
ax = ax or plt.axes()
auc = metrics.roc_auc_score(y_true, y_score)
fpr, tpr, _ = metrics.roc_curve(y_true, y_score)
ax.plot(fpr, tpr)
ax.annotate('AUC: {:.2f}'.format(auc), (.8, .2))
ax.plot([0, 1], [0, 1], linestyle='--', color='k')
return ax
评论列表
文章目录