Commit 0f224c05 authored by Guolin Ke's avatar Guolin Ke
Browse files

fix a bug in WeightedPercentile function.

parent 2204e45f
...@@ -48,8 +48,8 @@ namespace LightGBM { ...@@ -48,8 +48,8 @@ namespace LightGBM {
}\ }\
double threshold = weighted_cdf[cnt_data - 1] * alpha;\ double threshold = weighted_cdf[cnt_data - 1] * alpha;\
size_t pos = std::upper_bound(weighted_cdf.begin(), weighted_cdf.end(), threshold) - weighted_cdf.begin();\ size_t pos = std::upper_bound(weighted_cdf.begin(), weighted_cdf.end(), threshold) - weighted_cdf.begin();\
if (pos == 0) {\ if (pos == 0 || pos == cnt_data - 1) {\
return data_reader(sorted_idx[0]);\ return data_reader(sorted_idx[pos]);\
}\ }\
CHECK(threshold >= weighted_cdf[pos - 1]);\ CHECK(threshold >= weighted_cdf[pos - 1]);\
CHECK(threshold < weighted_cdf[pos]);\ CHECK(threshold < weighted_cdf[pos]);\
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment