diff --git a/sklearn/metrics/ranking.py b/sklearn/metrics/ranking.py index da75465597f69..17ffd53442143 100644 --- a/sklearn/metrics/ranking.py +++ b/sklearn/metrics/ranking.py @@ -15,6 +15,7 @@ # Lars Buitinck # Joel Nothman # Noel Dawe +# Maximilian Soelch # License: BSD 3 clause from __future__ import division @@ -328,8 +329,11 @@ def _binary_clf_curve(y_true, y_score, pos_label=None, sample_weight=None): # concatenate a value for the end of the curve. # We need to use isclose to avoid spurious repeated thresholds # stemming from floating point roundoff errors. + # Setting the tolerances to higher values than 0.0 will cause unexpected + # behavior for low variance y_score arrays. distinct_value_indices = np.where(np.logical_not(isclose( - np.diff(y_score), 0)))[0] + np.diff(y_score), 0, atol=0.0, rtol=0.0)))[0] + threshold_idxs = np.r_[distinct_value_indices, y_true.size - 1] # accumulate the true positives with decreasing threshold