diff --git a/sklearn/metrics/ranking.py b/sklearn/metrics/ranking.py index 5848f913c8a66..52404e856135f 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 + # 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, "