Fix tweedie handling of base_score (#3295)

* fix tweedie margin calculations

* add entry to contributors
This commit is contained in:
pdesahb 2018-06-28 17:43:05 +02:00 committed by Philip Hyunsu Cho
parent 64b8cffde3
commit 12e34f32e2
3 changed files with 9 additions and 3 deletions

View File

@ -75,3 +75,4 @@ List of Contributors
* [Andrew Hannigan](https://github.com/andrewhannigan)
* [Andy Adinets](https://github.com/canonizer)
* [Henry Gouk](https://github.com/henrygouk)
* [Pierre de Sahb](https://github.com/pdesahb)

View File

@ -394,6 +394,11 @@ class TweedieRegression : public ObjFunction {
preds[j] = std::exp(preds[j]);
}
}
bst_float ProbToMargin(bst_float base_score) const override {
return std::log(base_score);
}
const char* DefaultEvalMetric() const override {
std::ostringstream os;
os << "tweedie-nloglik@" << param_.tweedie_variance_power;

View File

@ -163,9 +163,9 @@ TEST(Objective, TweedieRegressionBasic) {
<< "Expected error when label < 0 for TweedieRegression";
// test ProbToMargin
EXPECT_NEAR(obj->ProbToMargin(0.1f), 0.10f, 0.01f);
EXPECT_NEAR(obj->ProbToMargin(0.5f), 0.5f, 0.01f);
EXPECT_NEAR(obj->ProbToMargin(0.9f), 0.89f, 0.01f);
EXPECT_NEAR(obj->ProbToMargin(0.1f), -2.30f, 0.01f);
EXPECT_NEAR(obj->ProbToMargin(0.5f), -0.69f, 0.01f);
EXPECT_NEAR(obj->ProbToMargin(0.9f), -0.10f, 0.01f);
// test PredTransform
xgboost::HostDeviceVector<xgboost::bst_float> io_preds = {0, 0.1f, 0.5f, 0.9f, 1};