From 2003e11882e08cce129a11ee3a39796bd2091d79 Mon Sep 17 00:00:00 2001 From: William de Vazelhes Date: Tue, 26 Mar 2019 16:47:16 +0100 Subject: [PATCH 1/2] first commit --- sklearn/metrics/ranking.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sklearn/metrics/ranking.py b/sklearn/metrics/ranking.py index 5848f913c8a66..ef27449bba286 100644 --- a/sklearn/metrics/ranking.py +++ b/sklearn/metrics/ranking.py @@ -634,12 +634,11 @@ def roc_curve(y_true, y_score, pos_label=None, sample_weight=None, tps = tps[optimal_idxs] thresholds = thresholds[optimal_idxs] - if tps.size == 0 or fps[0] != 0 or tps[0] != 0: - # Add an extra threshold position if necessary - # to make sure that the curve starts at (0, 0) - tps = np.r_[0, tps] - fps = np.r_[0, fps] - thresholds = np.r_[thresholds[0] + 1, thresholds] + # Add an extra threshold position if necessary + # to make sure that the curve starts at (0, 0) + tps = np.r_[0, tps] + fps = np.r_[0, fps] + thresholds = np.r_[thresholds[0] + 1, thresholds] if fps[-1] <= 0: warnings.warn("No negative samples in y_true, " From 7142e31e4b48218d7c46105e77de5360ba00fae3 Mon Sep 17 00:00:00 2001 From: William de Vazelhes <31916524+wdevazelhes@users.noreply.github.com> Date: Thu, 28 Mar 2019 09:33:06 +0100 Subject: [PATCH 2/2] remove "if necessary" --- sklearn/metrics/ranking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/metrics/ranking.py b/sklearn/metrics/ranking.py index ef27449bba286..52404e856135f 100644 --- a/sklearn/metrics/ranking.py +++ b/sklearn/metrics/ranking.py @@ -634,7 +634,7 @@ def roc_curve(y_true, y_score, pos_label=None, sample_weight=None, tps = tps[optimal_idxs] thresholds = thresholds[optimal_idxs] - # Add an extra threshold position if necessary + # Add an extra threshold position # to make sure that the curve starts at (0, 0) tps = np.r_[0, tps] fps = np.r_[0, fps]