Skip to content
Snippets Groups Projects
Commit 7058afbf authored by Nikolai.Hartmann's avatar Nikolai.Hartmann
Browse files

Allow reoder=True in auc if values are not increasing (due to neg event weights)

parent 4429feb9
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,11 @@ def overlay_ROC(filename, *projects, **kwargs):
for p, color in zip(projects, colors):
fpr, tpr, threshold = roc_curve(p.y_test, p.scores_test, sample_weight = p.w_test)
fpr = 1.0 - fpr
roc_auc = auc(tpr, fpr)
try:
roc_auc = auc(tpr, fpr)
except ValueError:
logger.warning("Got a value error from auc - trying to rerun with reorder=True")
roc_auc = auc(tpr, fpr, reorder=True)
ax.grid(color='gray', linestyle='--', linewidth=1)
ax.plot(tpr, fpr, label=str(p.name+" (AUC = {:.3f})".format(roc_auc)), color=color)
......
......@@ -911,9 +911,12 @@ class ClassificationProject(object):
logger.info("Plot ROC curve")
fpr, tpr, threshold = roc_curve(self.y_test, self.scores_test, sample_weight = self.w_test)
fpr = 1.0 - fpr
roc_auc = auc(tpr, fpr)
try:
roc_auc = auc(tpr, fpr, reorder=True)
except ValueError:
logger.warning("Got a value error from auc - trying to rerun with reorder=True")
roc_auc = auc(tpr, fpr, reorder=True)
plt.grid(color='gray', linestyle='--', linewidth=1)
plt.plot(tpr, fpr, label=str(self.name + " (AUC = {})".format(roc_auc)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment