Skip to content

Commit

Permalink
COSMIT: Use searchsorted in weighted_percentile
Browse files Browse the repository at this point in the history
  • Loading branch information
MechCoder authored and amueller committed Nov 5, 2014
1 parent d21d6dd commit e01f225
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions sklearn/utils/stats.py
Expand Up @@ -52,8 +52,6 @@ def _weighted_percentile(array, sample_weight, percentile=50):

# Find index of median prediction for each sample
weight_cdf = sample_weight[sorted_idx].cumsum()
percentile_or_above = weight_cdf >= (percentile / 100.0) * weight_cdf[-1]
percentile_idx = percentile_or_above.argmax()

percentile_idx = np.searchsorted(
weight_cdf, (percentile / 100.) * weight_cdf[-1])
return array[sorted_idx[percentile_idx]]

0 comments on commit e01f225

Please sign in to comment.