Commit 86ec0ef2 authored by Sixiang Hu's avatar Sixiang Hu Committed by Guolin Ke
Browse files

truncation for TweedieMetric class (#1625)

parent 677716d3
...@@ -286,6 +286,10 @@ public: ...@@ -286,6 +286,10 @@ public:
inline static double LossOnPoint(label_t label, double score, const Config& config) { inline static double LossOnPoint(label_t label, double score, const Config& config) {
const double rho = config.tweedie_variance_power; const double rho = config.tweedie_variance_power;
const double eps = 1e-10f;
if (score < eps) {
score = eps;
}
const double a = label * std::exp((1 - rho) * std::log(score)) / (1 - rho); const double a = label * std::exp((1 - rho) * std::log(score)) / (1 - rho);
const double b = std::exp((2 - rho) * std::log(score)) / (2 - rho); const double b = std::exp((2 - rho) * std::log(score)) / (2 - rho);
return -a + b; return -a + b;
......
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