def plot_auc(self, estimator, estimator_name, neg, pos):
try:
classifier_probas = estimator.decision_function(self.X_test)
except AttributeError:
classifier_probas = estimator.predict_proba(self.X_test)[:, 1]
false_positive_r, true_positive_r, thresholds = metrics.roc_curve(self.y_test, classifier_probas)
roc_auc = metrics.auc(false_positive_r, true_positive_r)
label = '{:.1f}% neg:{} pos:{} {}'.format(roc_auc * 100, neg, pos, estimator_name)
plt.plot(false_positive_r, true_positive_r, label=label)
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([-0.05, 1.0])
plt.ylim([0.0, 1.05])
plt.title('ROC score(s)')
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.legend(loc='lower right', prop={'size': 10})
plt.savefig("ROC.png", dpi=300, bbox_inches='tight')
plt.grid()
评论列表
文章目录