MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / BoostFromAverage

Method BoostFromAverage

src/boosting/gbdt.cpp:354–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352}
353
354double GBDT::BoostFromAverage(int class_id, bool update_scorer) {
355 // boosting from average label; or customized "average" if implemented for the current objective
356 if (models_.empty() && !train_score_updater_->has_init_score() && objective_function_ != nullptr) {
357 if (config_->boost_from_average || (train_data_ != nullptr && train_data_->num_features() == 0)) {
358 double init_score = ObtainAutomaticInitialScore(objective_function_, class_id);
359 if (std::fabs(init_score) > kEpsilon) {
360 if (update_scorer) {
361 train_score_updater_->AddScore(init_score, class_id);
362 for (auto& score_updater : valid_score_updater_) {
363 score_updater->AddScore(init_score, class_id);
364 }
365 }
366 Log::Info("Start training from score %lf", init_score);
367 return init_score;
368 }
369 } else if (std::string(objective_function_->GetName()) == std::string("regression_l1")
370 || std::string(objective_function_->GetName()) == std::string("quantile")
371 || std::string(objective_function_->GetName()) == std::string("mape")) {
372 Log::Warning("Disabling boost_from_average in %s may cause the slow convergence", objective_function_->GetName());
373 }
374 }
375 return 0.0f;
376}
377
378bool GBDT::TrainOneIter(const score_t* gradients, const score_t* hessians) {
379 GBDT::TrainOneIter_old(gradients, hessians);

Callers

nothing calls this directly

Calls 6

emptyMethod · 0.45
has_init_scoreMethod · 0.45
num_featuresMethod · 0.45
AddScoreMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected