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

Method Set

src/io/config.cpp:158–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void 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
213bool CheckMultiClassObjective(const std::string& objective) {
214 return (objective == std::string("multiclass") || objective == std::string("multiclassova"));

Callers 15

BoosterMethod · 0.45
ResetConfigMethod · 0.45
LGBM_DatasetGetSubsetFunction · 0.45

Calls 13

sortFunction · 0.85
push_backMethod · 0.80
GetTaskTypeFunction · 0.70
GetBoostingTypeFunction · 0.70
GetMetricTypeFunction · 0.70
GetObjectiveTypeFunction · 0.70
GetDeviceTypeFunction · 0.70
GetTreeLearnerTypeFunction · 0.70
NextShortMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected