| 156 | } |
| 157 | |
| 158 | void Config::Set(const std::unordered_map<std::string, std::string>& params) { |
| 159 | // generate seeds by seed. |
| 160 | if (GetInt(params, "seed", &seed)) { |
| 161 | Random rand(seed); |
| 162 | int int_max = std::numeric_limits<int16_t>::max(); |
| 163 | data_random_seed = static_cast<int>(rand.NextShort(0, int_max)); |
| 164 | bagging_seed = static_cast<int>(rand.NextShort(0, int_max)); |
| 165 | drop_seed = static_cast<int>(rand.NextShort(0, int_max)); |
| 166 | feature_fraction_seed = static_cast<int>(rand.NextShort(0, int_max)); |
| 167 | } |
| 168 | |
| 169 | GetTaskType(params, &task); |
| 170 | GetBoostingType(params, &boosting); |
| 171 | GetMetricType(params, &metric); |
| 172 | GetObjectiveType(params, &objective); |
| 173 | GetDeviceType(params, &device_type); |
| 174 | GetTreeLearnerType(params, &tree_learner); |
| 175 | |
| 176 | GetMembersFromString(params); |
| 177 | |
| 178 | // sort eval_at |
| 179 | std::sort(eval_at.begin(), eval_at.end()); |
| 180 | |
| 181 | if (valid_data_initscores.size() == 0 && valid.size() > 0) { |
| 182 | valid_data_initscores = std::vector<std::string>(valid.size(), ""); |
| 183 | } |
| 184 | CHECK(valid.size() == valid_data_initscores.size()); |
| 185 | |
| 186 | if (valid_data_initscores.empty()) { |
| 187 | std::vector<std::string> new_valid; |
| 188 | for (size_t i = 0; i < valid.size(); ++i) { |
| 189 | if (valid[i] != data) { |
| 190 | // Only push the non-training data |
| 191 | new_valid.push_back(valid[i]); |
| 192 | } else { |
| 193 | is_provide_training_metric = true; |
| 194 | } |
| 195 | } |
| 196 | valid = new_valid; |
| 197 | } |
| 198 | |
| 199 | // check for conflicts |
| 200 | CheckParamConflict(); |
| 201 | |
| 202 | if (verbosity == 1) { |
| 203 | LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Info); |
| 204 | } else if (verbosity == 0) { |
| 205 | LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Warning); |
| 206 | } else if (verbosity >= 2) { |
| 207 | LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Debug); |
| 208 | } else { |
| 209 | LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Fatal); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | bool CheckMultiClassObjective(const std::string& objective) { |
| 214 | return (objective == std::string("multiclass") || objective == std::string("multiclassova")); |
no test coverage detected