Fix tweedie handling of base_score (#3295)
* fix tweedie margin calculations * add entry to contributors
This commit is contained in:
parent
64b8cffde3
commit
12e34f32e2
@ -75,3 +75,4 @@ List of Contributors
|
|||||||
* [Andrew Hannigan](https://github.com/andrewhannigan)
|
* [Andrew Hannigan](https://github.com/andrewhannigan)
|
||||||
* [Andy Adinets](https://github.com/canonizer)
|
* [Andy Adinets](https://github.com/canonizer)
|
||||||
* [Henry Gouk](https://github.com/henrygouk)
|
* [Henry Gouk](https://github.com/henrygouk)
|
||||||
|
* [Pierre de Sahb](https://github.com/pdesahb)
|
||||||
|
|||||||
@ -394,6 +394,11 @@ class TweedieRegression : public ObjFunction {
|
|||||||
preds[j] = std::exp(preds[j]);
|
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 {
|
const char* DefaultEvalMetric() const override {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "tweedie-nloglik@" << param_.tweedie_variance_power;
|
os << "tweedie-nloglik@" << param_.tweedie_variance_power;
|
||||||
|
|||||||
@ -163,9 +163,9 @@ TEST(Objective, TweedieRegressionBasic) {
|
|||||||
<< "Expected error when label < 0 for TweedieRegression";
|
<< "Expected error when label < 0 for TweedieRegression";
|
||||||
|
|
||||||
// test ProbToMargin
|
// test ProbToMargin
|
||||||
EXPECT_NEAR(obj->ProbToMargin(0.1f), 0.10f, 0.01f);
|
EXPECT_NEAR(obj->ProbToMargin(0.1f), -2.30f, 0.01f);
|
||||||
EXPECT_NEAR(obj->ProbToMargin(0.5f), 0.5f, 0.01f);
|
EXPECT_NEAR(obj->ProbToMargin(0.5f), -0.69f, 0.01f);
|
||||||
EXPECT_NEAR(obj->ProbToMargin(0.9f), 0.89f, 0.01f);
|
EXPECT_NEAR(obj->ProbToMargin(0.9f), -0.10f, 0.01f);
|
||||||
|
|
||||||
// test PredTransform
|
// test PredTransform
|
||||||
xgboost::HostDeviceVector<xgboost::bst_float> io_preds = {0, 0.1f, 0.5f, 0.9f, 1};
|
xgboost::HostDeviceVector<xgboost::bst_float> io_preds = {0, 0.1f, 0.5f, 0.9f, 1};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user