"include/git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "3d9ada76574e3e246155f4410f285c334f148dec"
Commit 441bafa1 authored by Zach Kurtz's avatar Zach Kurtz Committed by Guolin Ke
Browse files

Enable boost_from_average as default for binary objective (#1361)

* implement boost_from_average by default for binary objective

* include sigmoid_ parameter in binary regression boost_from_average
parent c1fc76b0
......@@ -114,6 +114,29 @@ public:
}
}
}
// implement custom average to boost from (if enabled among options)
double BoostFromScore() const override {
double suml = 0.0f;
double sumw = 0.0f;
if (weights_ != nullptr) {
#pragma omp parallel for schedule(static) reduction(+:suml,sumw)
for (data_size_t i = 0; i < num_data_; ++i) {
suml += label_[i] * weights_[i];
sumw += weights_[i];
}
} else {
sumw = static_cast<double>(num_data_);
#pragma omp parallel for schedule(static) reduction(+:suml)
for (data_size_t i = 0; i < num_data_; ++i) {
suml += label_[i];
}
}
double pavg = suml / sumw;
double initscore = std::log(pavg / (1.0f - pavg)) / sigmoid_;
Log::Info("[%s:%s]: pavg=%f -> initscore=%f", GetName(), __func__, pavg, initscore);
return initscore;
}
const char* GetName() const override {
return "binary";
......
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