28 std::string get_default_string_map(
const std::map <std::string, std::string> &
m,
29 const std::string&
key,
const std::string & defval=
"")
31 std::map<std::string, std::string>::const_iterator
it =
m.find(
key);
32 if (
it ==
m.end()) {
return defval; }
36 std::map<std::string, std::string> parseOptions(
const std::string& raw_options)
38 std::stringstream
ss(raw_options);
39 std::map<std::string, std::string>
options;
41 while (std::getline(
ss,
item,
';')) {
42 auto pos =
item.find_first_of(
'=');
43 const auto right =
item.substr(
pos+1);
44 const auto left =
item.substr(0,
pos);
45 if (!
options.insert(std::make_pair(left, right)).second)
47 throw std::runtime_error(std::string(
"option ") + left +
48 " duplicated in title of TTree used as input");
63 throw std::runtime_error(
"nullptr to a TTree passed ");
65 tree->SetCacheSize(0);
66 std::map<std::string, std::string>
options = parseOptions(
tree->GetTitle());
67 std::string creator = get_default_string_map(
options, std::string(
"creator"));
68 if (creator ==
"lgbm")
70 std::string node_type = get_default_string_map (
options, std::string(
"node_type"));
71 if (node_type ==
"lgbm") {
73 }
else if (node_type ==
"lgbm_simple") {
74 m_forest = std::make_unique<ForestLGBMSimple>(
77 throw std::runtime_error(
78 "the title of the input tree is misformatted: cannot understand which "
79 "BDT implementation to use");
81 }
else if (creator ==
"xgboost") {