98 Node* lr =
const_cast<Node*
>(local_root);
107 left_new_child->
setParent(new_local_root);
109 right_new_child->setParent(new_local_root);
110 new_local_root->setLeftDaughter(left_new_child);
111 new_local_root->setRightDaughter(right_new_child);
121 return new_local_root;
127 tn.push_back(local_root);
175 double totalSquaredError = 0;
178 totalSquaredError += (*it)->getTotalError();
187 double bestNodeErrorReduction = -1;
188 Node* nodeToSplit =
nullptr;
197 if ((*it)->getErrorReduction() > bestNodeErrorReduction) {
198 bestNodeErrorReduction = (*it)->getErrorReduction();
206 if (nodeToSplit ==
nullptr)
265 if (left ==
nullptr || right ==
nullptr)
292 if (nextNode ==
nullptr)
309 if (left ==
nullptr || right ==
nullptr)
344 if (left ==
nullptr || right ==
nullptr)
351 std::cout <<
"ERROR: negative split variable for nonterminal node." << std::endl;
352 std::cout <<
"rankVarRecursive Split Variable = " <<
sv << std::endl;
370 template <
typename T>
373 std::stringstream
ss;
392 TXMLEngine* xml =
new TXMLEngine();
402 XMLDocPointer_t
xmldoc = xml->NewDoc();
419 if (
l ==
nullptr || r ==
nullptr)
423 XMLNodePointer_t left = xml->NewChild(
np,
nullptr,
"left");
424 XMLNodePointer_t right = xml->NewChild(
np,
nullptr,
"right");
439 TXMLEngine* xml =
new TXMLEngine;
449 XMLNodePointer_t mainnode = xml->DocGetRootElement(
xmldoc);
454 if (
std::string(
"BinaryTree") == xml->GetNodeName(mainnode)) {
455 XMLAttrPointer_t attr = xml->GetFirstAttr(mainnode);
456 while (
std::string(
"boostWeight") != xml->GetAttrName(attr)) {
457 attr = xml->GetNextAttr(attr);
459 boostWeight = (attr ? strtod(xml->GetAttrValue(attr),
nullptr) : 0);
461 mainnode = xml->GetChild(mainnode);
479 XMLAttrPointer_t attr = xml->GetFirstAttr(xnode);
480 std::vector<std::string> splitInfo(3);
482 for (
unsigned int i = 0;
i < 10;
i++) {
483 if (
std::string(
"IVar") == xml->GetAttrName(attr)) {
484 splitInfo[0] = xml->GetAttrValue(attr);
486 if (
std::string(
"Cut") == xml->GetAttrName(attr)) {
487 splitInfo[1] = xml->GetAttrValue(attr);
489 if (
std::string(
"res") == xml->GetAttrName(attr)) {
490 splitInfo[2] = xml->GetAttrValue(attr);
492 attr = xml->GetNextAttr(attr);
495 for (
unsigned int i = 0;
i < 3;
i++) {
496 splitInfo[
i] = xml->GetAttrValue(attr);
497 attr = xml->GetNextAttr(attr);
528 XMLNodePointer_t xleft = xml->GetChild(xnode);
529 XMLNodePointer_t xright = xml->GetNext(xleft);
532 if (xleft ==
nullptr || xright ==
nullptr)
void setFitValue(double sFitValue)
Node * getRightDaughter()
Node * filterEventRecursive(Node *node, Event *e)
std::list< Node * > terminalNodes
void buildTree(int nodeLimit)
void getSplitValues(std::vector< std::vector< double >> &v)
void loadFromXMLRecursive(TXMLEngine *xml, XMLNodePointer_t node, Node *tnode)
int getNumTerminalNodes()
void addXMLAttributes(TXMLEngine *xml, Node *node, XMLNodePointer_t np)
void loadFromCondPayloadRecursive(const L1TMuonEndCapForest::DTree &tree, const L1TMuonEndCapForest::DTreeNode &node, Node *tnode)
void filterEvents(std::vector< Event *> &tEvents)
Tree & operator=(const Tree &tree)
void setEvents(std::vector< std::vector< Event *> > &sEvents)
void setTerminalNodes(std::list< Node *> &sTNodes)
void findLeafs(Node *local_root, std::list< Node *> &tn)
void loadFromCondPayload(const L1TMuonEndCapForest::DTree &tree)
Node * filterEventToDaughter(Event *e)
void rankVariables(std::vector< double > &v)
void rankVariablesRecursive(Node *node, std::vector< double > &v)
std::vector< std::vector< Event * > > & getEvents()
void saveToXMLRecursive(TXMLEngine *xml, Node *node, XMLNodePointer_t np)
std::vector< DTreeNode > DTree
std::list< Node * > & getTerminalNodes()
Node * copyFrom(const Node *local_root)
void setParent(Node *sParent)
void filterEventsRecursive(Node *node)
void setSplitVariable(int sSplitVar)
Node * filterEvent(Event *e)
void loadFromXML(const char *filename)
void saveToXML(const char *filename)
double getErrorReduction()
void filterEventsToDaughters()
std::string numToStr(T num)
void setRootNode(Node *sRootNode)
void getSplitValuesRecursive(Node *node, std::vector< std::vector< double >> &v)
void setSplitValue(double sSplitValue)
void theMiracleOfChildBirth()