Skip to content

Commit

Permalink
Remove unnecessary warning when 'gblinear' is selected (#3888)
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 authored Nov 9, 2018
1 parent e38d5a6 commit be0bb7d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/learner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,14 @@ class LearnerImpl : public Learner {
#endif
}


/*! \brief Map `tree_method` parameter to `updater` parameter */
void ConfigureUpdaters() {
/* Choose updaters according to tree_method parameters */
// This method is not applicable to non-tree learners
if (cfg_.count("booster") > 0 && cfg_.at("booster") != "gbtree") {
return;
}
// `updater` parameter was manually specified
if (cfg_.count("updater") > 0) {
LOG(CONSOLE) << "DANGER AHEAD: You have manually specified `updater` "
"parameter. The `tree_method` parameter will be ignored. "
Expand All @@ -198,6 +204,7 @@ class LearnerImpl : public Learner {
return;
}

/* Choose updaters according to tree_method parameters */
switch (tparam_.tree_method) {
case TreeMethod::kAuto:
// Use heuristic to choose between 'exact' and 'approx'
Expand Down Expand Up @@ -276,15 +283,15 @@ class LearnerImpl : public Learner {
cfg_["max_delta_step"] = kMaxDeltaStepDefaultValue;
}

ConfigureUpdaters();

if (cfg_.count("objective") == 0) {
cfg_["objective"] = "reg:linear";
}
if (cfg_.count("booster") == 0) {
cfg_["booster"] = "gbtree";
}

ConfigureUpdaters();

if (!this->ModelInitialized()) {
mparam_.InitAllowUnknown(args);
name_obj_ = cfg_["objective"];
Expand Down

0 comments on commit be0bb7d

Please sign in to comment.