| 832 | } |
| 833 | |
| 834 | void ConfigureObjective(LearnerTrainParam const& old, Args* p_args) { |
| 835 | // Once binary IO is gone, NONE of these config is useful. |
| 836 | if (cfg_.find("num_class") != cfg_.cend() && cfg_.at("num_class") != "0" && |
| 837 | tparam_.objective != "multi:softprob") { |
| 838 | cfg_["num_output_group"] = cfg_["num_class"]; |
| 839 | if (atoi(cfg_["num_class"].c_str()) > 1 && cfg_.count("objective") == 0) { |
| 840 | tparam_.objective = "multi:softmax"; |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | if (cfg_.find("max_delta_step") == cfg_.cend() && cfg_.find("objective") != cfg_.cend() && |
| 845 | tparam_.objective == "count:poisson") { |
| 846 | // max_delta_step is a duplicated parameter in Poisson regression and tree param. |
| 847 | // Rename one of them once binary IO is gone. |
| 848 | cfg_["max_delta_step"] = kMaxDeltaStepDefaultValue; |
| 849 | } |
| 850 | if (obj_ == nullptr || tparam_.objective != old.objective) { |
| 851 | obj_.reset(ObjFunction::Create(tparam_.objective, &ctx_)); |
| 852 | } |
| 853 | |
| 854 | bool has_nc{cfg_.find("num_class") != cfg_.cend()}; |
| 855 | // Inject num_class into configuration. |
| 856 | // FIXME(jiamingy): Remove the duplicated parameter in softmax |
| 857 | cfg_["num_class"] = std::to_string(mparam_.num_class); |
| 858 | auto& args = *p_args; |
| 859 | args = {cfg_.cbegin(), cfg_.cend()}; // renew |
| 860 | obj_->Configure(args); |
| 861 | if (!has_nc) { |
| 862 | cfg_.erase("num_class"); |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | void ConfigureMetrics(Args const& args) { |
| 867 | for (auto const& name : metric_names_) { |