29 std::string ToString()
const;
38 const std::unordered_map<std::string, std::string>& params,
39 const std::string& name, std::string* out);
49 const std::unordered_map<std::string, std::string>& params,
50 const std::string& name,
int* out);
60 const std::unordered_map<std::string, std::string>& params,
61 const std::string& name,
double* out);
71 const std::unordered_map<std::string, std::string>& params,
72 const std::string& name,
bool* out);
74 static void KV2Map(std::unordered_map<std::string, std::string>& params,
const char* kv);
75 static std::unordered_map<std::string, std::string> Str2Map(
const char* parameters);
77 #pragma region Parameters
79 #pragma region Core Parameters
85 std::string config =
"";
126 std::string objective =
"regression";
136 std::string boosting =
"gbdt";
141 std::string data =
"";
148 std::vector<std::string> valid;
154 int num_iterations = 100;
160 double learning_rate = 0.1;
166 int num_leaves = kDefaultNumLeaves;
177 std::string tree_learner =
"serial";
196 std::string device_type =
"cpu";
208 #pragma region Learning Control Parameters
217 int min_data_in_leaf = 20;
222 double min_sum_hessian_in_leaf = 1e-3;
231 double bagging_fraction = 1.0;
237 int bagging_freq = 0;
241 int bagging_seed = 3;
249 double feature_fraction = 1.0;
252 int feature_fraction_seed = 2;
257 int early_stopping_round = 0;
263 double max_delta_step = 0.0;
268 double lambda_l1 = 0.0;
273 double lambda_l2 = 0.0;
278 double min_gain_to_split = 0.0;
285 double drop_rate = 0.1;
296 double skip_drop = 0.5;
300 bool xgboost_dart_mode =
false;
304 bool uniform_drop =
false;
314 double top_rate = 0.2;
320 double other_rate = 0.1;
324 int min_data_per_group = 100;
329 int max_cat_threshold = 32;
334 double cat_l2 = 10.0;
339 double cat_smooth = 10.0;
343 int max_cat_to_onehot = 4;
357 std::vector<int8_t> monotone_constraints;
364 std::vector<double> feature_contri;
372 std::string forcedsplits_filename =
"";
378 double refit_decay_rate = 0.9;
382 #pragma region IO Parameters
398 int min_data_in_bin = 3;
405 int bin_construct_sample_cnt = 200000;
410 double histogram_pool_size = -1.0;
414 int data_random_seed = 1;
419 std::string output_model =
"LightGBM_model.txt";
425 int snapshot_freq = -1;
432 std::string input_model =
"";
437 std::string output_result =
"LightGBM_predict_result.txt";
443 std::string initscore_filename =
"";
451 std::vector<std::string> valid_data_initscores;
456 bool pre_partition =
false;
461 bool enable_bundle =
true;
468 double max_conflict_rate = 0.0;
472 bool is_enable_sparse =
true;
477 double sparse_threshold = 0.8;
480 bool use_missing =
true;
484 bool zero_as_missing =
false;
489 bool two_round =
false;
493 bool save_binary =
false;
498 bool enable_load_from_binary_file =
true;
509 std::string label_column =
"";
517 std::string weight_column =
"";
526 std::string group_column =
"";
536 std::string ignore_column =
"";
548 std::string categorical_feature =
"";
554 bool predict_raw_score =
false;
559 bool predict_leaf_index =
false;
566 bool predict_contrib =
false;
571 int num_iteration_predict = -1;
575 bool pred_early_stop =
false;
579 int pred_early_stop_freq = 10;
583 double pred_early_stop_margin = 10.0;
589 std::string convert_model_language =
"";
595 std::string convert_model =
"gbdt_prediction.cpp";
599 #pragma region Objective Parameters
610 bool is_unbalance =
false;
616 double scale_pos_weight = 1.0;
621 double sigmoid = 1.0;
625 bool boost_from_average =
true;
630 bool reg_sqrt =
false;
645 double poisson_max_delta_step = 0.7;
653 double tweedie_variance_power = 1.5;
658 int max_position = 20;
665 std::vector<double> label_gain;
669 #pragma region Metric Parameters
700 std::vector<std::string> metric;
710 bool is_provide_training_metric =
false;
717 std::vector<int> eval_at;
721 #pragma region Network Parameters
727 int num_machines = 1;
733 int local_listen_port = 12400;
742 std::string machine_list_filename =
"";
746 std::string machines =
"";
750 #pragma region GPU Parameters
755 int gpu_platform_id = -1;
760 int gpu_device_id = -1;
763 bool gpu_use_dp =
false;
769 bool is_parallel =
false;
770 bool is_parallel_find_bin =
false;
771 LIGHTGBM_EXPORT
void Set(
const std::unordered_map<std::string, std::string>& params);
772 static std::unordered_map<std::string, std::string> alias_table;
773 static std::unordered_set<std::string> parameter_set;
776 void CheckParamConflict();
777 void GetMembersFromString(
const std::unordered_map<std::string, std::string>& params);
778 std::string SaveMembersToString()
const;
818 const std::unordered_map<std::string, std::string>& params,
819 const std::string& name,
bool* out) {
820 if (params.count(name) > 0) {
821 std::string value = params.at(name);
822 std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
823 if (value == std::string(
"false") || value == std::string(
"-")) {
825 }
else if (value == std::string(
"true") || value == std::string(
"+")) {
828 Log::Fatal(
"Parameter %s should be \"true\"/\"+\" or \"false\"/\"-\", got \"%s\"",
829 name.c_str(), params.at(name).c_str());
837 static void KeyAliasTransform(std::unordered_map<std::string, std::string>* params) {
838 std::unordered_map<std::string, std::string> tmp_map;
839 for (
const auto& pair : *params) {
840 auto alias = Config::alias_table.find(pair.first);
841 if (alias != Config::alias_table.end()) {
842 auto alias_set = tmp_map.find(alias->second);
843 if (alias_set != tmp_map.end()) {
845 if (alias_set->second.size() < pair.first.size() ||
846 (alias_set->second.size() == pair.first.size() && alias_set->second < pair.first)) {
847 Log::Warning(
"%s is set with %s=%s, %s=%s will be ignored. Current value: %s=%s",
848 alias->second.c_str(), alias_set->second.c_str(), params->at(alias_set->second).c_str(),
849 pair.first.c_str(), pair.second.c_str(), alias->second.c_str(), params->at(alias_set->second).c_str());
851 Log::Warning(
"%s is set with %s=%s, will be overridden by %s=%s. Current value: %s=%s",
852 alias->second.c_str(), alias_set->second.c_str(), params->at(alias_set->second).c_str(),
853 pair.first.c_str(), pair.second.c_str(), alias->second.c_str(), pair.second.c_str());
854 tmp_map[alias->second] = pair.first;
857 tmp_map.emplace(alias->second, pair.first);
859 }
else if (Config::parameter_set.find(pair.first) == Config::parameter_set.end()) {
860 Log::Warning(
"Unknown parameter: %s", pair.first.c_str());
863 for (
const auto& pair : tmp_map) {
864 auto alias = params->find(pair.first);
865 if (alias == params->end()) {
866 params->emplace(pair.first, params->at(pair.second));
867 params->erase(pair.second);
869 Log::Warning(
"%s is set=%s, %s=%s will be ignored. Current value: %s=%s",
870 pair.first.c_str(), alias->second.c_str(), pair.second.c_str(), params->at(pair.second).c_str(),
871 pair.first.c_str(), alias->second.c_str());