17 std::vector<int> *vars =
nullptr;
18 std::vector<float> *values =
nullptr;
21 std::vector<NodeTMVA> nodes;
23 tree->SetBranchAddress(
"vars", &vars);
24 tree->SetBranchAddress(
"values", &values);
25 tree->SetBranchAddress(
"offset", &offset);
27 int numEntries =
tree->GetEntries();
28 for (
int entry = 0; entry < numEntries; ++entry) {
30 tree->GetEntry(entry);
32 throw std::runtime_error(
33 "vars pointer is null in ForestTMVA constructor");
36 throw std::runtime_error(
37 "values pointers is null in ForestTMVA constructor");
39 if (vars->size() != values->size()) {
40 throw std::runtime_error(
41 "inconsistent size for vars and values in ForestTMVA constructor");
48 for (
size_t i = 0; i < vars->size(); ++i) {
49 nodes.emplace_back(vars->at(i), values->at(i), right[i]);
63 TTree *
tree =
new TTree(name.Data(),
"creator=TMVA");
65 std::vector<int> vars;
66 std::vector<float> values;
69 tree->Branch(
"offset", &offset);
70 tree->Branch(
"vars", &vars);
71 tree->Branch(
"values", &values);
73 for (
size_t itree = 0; itree <
GetNTrees(); ++itree) {
77 vars.push_back(
node.GetVar());
78 values.push_back(
node.GetVal());
88 std::cout <<
"***BDT TMVA: Printing entire forest***" << std::endl;
virtual TTree * WriteTree(TString name) const override
Return a TTree representing the BDT.
virtual void PrintForest() const override
float GetTreeWeight(unsigned int itree) const
void newTree(const std::vector< NodeTMVA > &nodes, float weight)
std::vector< NodeTMVA > GetTree(unsigned int itree) const
virtual void PrintForest() const override
virtual unsigned int GetNTrees() const override final
Node for TMVA implementation.
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...