Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tweedie handling of base_score #3295

Merged
merged 2 commits into from Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Expand Up @@ -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)
5 changes: 5 additions & 0 deletions src/objective/regression_obj.cc
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions tests/cpp/objective/test_regression_obj.cc
Expand Up @@ -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};
Expand Down