Skip to content

Commit

Permalink
Merge branch 'master' into int32
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS committed May 18, 2018
2 parents cd1127d + 441bafa commit 386e122
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/objective/binary_objective.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@ class BinaryLogloss: public ObjectiveFunction {
}
}
}

// 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";
Expand Down

0 comments on commit 386e122

Please sign in to comment.