Skip to content

Commit

Permalink
fix overflow in WeightedPercentile
Browse files Browse the repository at this point in the history
  • Loading branch information
guolinke committed Apr 16, 2019
1 parent 5b5b982 commit 8ffd8d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/objective/regression_objective.hpp
Expand Up @@ -65,7 +65,7 @@ namespace LightGBM {
CHECK(threshold < weighted_cdf[pos]);\
T v1 = data_reader(sorted_idx[pos - 1]);\
T v2 = data_reader(sorted_idx[pos]);\
if (weighted_cdf[pos + 1] - weighted_cdf[pos] > kEpsilon) {\
if (weighted_cdf[pos + 1] - weighted_cdf[pos] >= 1.0f) {\
return static_cast<T>((threshold - weighted_cdf[pos]) / (weighted_cdf[pos + 1] - weighted_cdf[pos]) * (v2 - v1) + v1); \
} else {\
return static_cast<T>(v2);\
Expand Down

0 comments on commit 8ffd8d8

Please sign in to comment.