|
ATLAS Offline Software
|
Go to the documentation of this file.
19 std::vector<int> *vars =
nullptr;
20 std::vector<float> *
values =
nullptr;
22 std::vector<NodeLGBMSimple> nodes;
24 tree->SetBranchAddress(
"vars", &vars);
27 int numEntries =
tree->GetEntries();
33 throw std::runtime_error(
34 "vars pointer is null in ForestLGBMSimple constructor");
37 throw std::runtime_error(
38 "values pointers is null in ForestLGBMSimple constructor");
40 if (vars->size() !=
values->size()) {
41 throw std::runtime_error(
"inconsistent size for vars and values in "
42 "ForestLGBMSimple constructor");
49 for (
size_t i = 0;
i < vars->size(); ++
i) {
50 nodes.emplace_back(vars->at(
i),
values->at(
i), right[
i]);
62 TTree *
tree =
new TTree(
name.Data(),
"creator=lgbm;node_type=lgbm_simple");
64 std::vector<int> vars;
67 tree->Branch(
"vars", &vars);
70 for (
size_t itree = 0; itree <
GetNTrees(); ++itree) {
74 vars.push_back(
node.GetVar());
84 std::cout <<
"***BDT LGBMSimple: Printing entire forest***" << std::endl;
95 std::vector<int> *vars =
nullptr;
96 std::vector<float> *
values =
nullptr;
97 std::vector<bool> *default_left =
nullptr;
99 std::vector<NodeLGBM> nodes;
101 tree->SetBranchAddress(
"vars", &vars);
103 tree->SetBranchAddress(
"default_left", &default_left);
104 int numEntries =
tree->GetEntries();
109 throw std::runtime_error(
110 "vars pointer is null in ForestLGBM constructor");
113 throw std::runtime_error(
114 "values pointers is null in ForestLGBM constructor");
117 throw std::runtime_error(
118 "default_left pointers is null in ForestLGBM constructor");
120 if (vars->size() !=
values->size()) {
121 throw std::runtime_error(
122 "inconsistent size for vars and values in ForestLGBM constructor");
124 if (default_left->size() !=
values->size()) {
125 throw std::runtime_error(
"inconsistent size for default_left and "
126 "values in ForestLGBM constructor");
133 for (
size_t i = 0;
i < vars->size(); ++
i) {
135 vars->at(
i),
values->at(
i), right[
i], default_left->at(
i));
150 TTree *
tree =
new TTree(
name.Data(),
"creator=lgbm;node_type=lgbm");
152 std::vector<int> vars;
153 std::vector<float>
values;
154 std::vector<bool> default_left;
156 tree->Branch(
"vars", &vars);
158 tree->Branch(
"default_left", &default_left);
160 for (
size_t itree = 0; itree <
GetNTrees(); ++itree) {
163 default_left.clear();
165 vars.push_back(
node.GetVar());
167 default_left.push_back(
node.GetDefaultLeft());
176 std::cout <<
"***BDT LGBM: Printing entire forest***" << std::endl;
ForestLGBMSimple()=default
std::vector< NodeLGBMSimple > GetTree(unsigned int itree) const
Return the vector of nodes for the tree itree.
std::vector< index_t > computeRight(const std::vector< int > &vars)
Compute the offsets between the nodes to their right children from a serialized representation of the...
virtual unsigned int GetNTrees() const override final
void newTree(const std::vector< NodeLGBMSimple > &nodes)
append a new tree (defined by a vector of nodes serialized in preorder) to the forest
Node for LGBM without nan implementation.
virtual TTree * WriteTree(TString name) const override
Return a TTree representing the BDT.
virtual TTree * WriteTree(TString name) const override
Return a TTree representing the BDT.
virtual void PrintForest() const override
virtual void PrintForest() const override
virtual void PrintForest() const override
Node for LGBM with nan implementation.