Fix tweedie metric string. (#4543)

This commit is contained in:
Jiaming Yuan
2019-06-09 09:52:29 +08:00
committed by GitHub
parent 59ae42a179
commit da21ac0cc2
3 changed files with 7 additions and 6 deletions

View File

@@ -437,6 +437,9 @@ class TweedieRegression : public ObjFunction {
// declare functions
void Configure(const std::vector<std::pair<std::string, std::string> >& args) override {
param_.InitAllowUnknown(args);
std::ostringstream os;
os << "tweedie-nloglik@" << param_.tweedie_variance_power;
metric_ = os.str();
}
void GetGradient(const HostDeviceVector<bst_float>& preds,
@@ -499,13 +502,11 @@ class TweedieRegression : public ObjFunction {
}
const char* DefaultEvalMetric() const override {
std::ostringstream os;
os << "tweedie-nloglik@" << param_.tweedie_variance_power;
std::string metric = os.str();
return metric.c_str();
return metric_.c_str();
}
private:
std::string metric_;
TweedieRegressionParam param_;
HostDeviceVector<int> label_correct_;
};