Skip to content

Commit be0bb7d

Browse files
authored
Remove unnecessary warning when 'gblinear' is selected (dmlc#3888)
1 parent e38d5a6 commit be0bb7d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/learner.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,14 @@ class LearnerImpl : public Learner {
187187
#endif
188188
}
189189

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

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

279-
ConfigureUpdaters();
280-
281286
if (cfg_.count("objective") == 0) {
282287
cfg_["objective"] = "reg:linear";
283288
}
284289
if (cfg_.count("booster") == 0) {
285290
cfg_["booster"] = "gbtree";
286291
}
287292

293+
ConfigureUpdaters();
294+
288295
if (!this->ModelInitialized()) {
289296
mparam_.InitAllowUnknown(args);
290297
name_obj_ = cfg_["objective"];

0 commit comments

Comments
 (0)