ATLAS Offline Software
Loading...
Searching...
No Matches
MVAUtils::BDT Class Reference

Simplified Boosted Regression Tree, support TMVA, lgbm, and xgboost. More...

#include <BDT.h>

Collaboration diagram for MVAUtils::BDT:

Public Member Functions

 BDT (TTree *tree)
 Constructor.
 BDT (std::unique_ptr< IForest > forest)
 BDT ()=delete
 BDT (const BDT &)=delete
BDToperator= (const BDT &)=delete
 BDT (BDT &&)=default
 default move ctor, move assignment and dtor
BDToperator= (BDT &&)=default
 ~BDT ()=default
unsigned int GetNTrees () const
 Number of trees in the whole forest.
int GetNVars () const
 Number of variables expected in the inputs.
float GetOffset () const
 Get the offset to the whole forest.
float GetResponse (const std::vector< float > &values) const
 Get response of the forest, for regression.
float GetResponse (const std::vector< float * > &pointers) const
float GetResponse () const
float GetClassification (const std::vector< float > &values) const
 Get response of the forest, for classification.
float GetClassification (const std::vector< float * > &pointers) const
float GetClassification () const
float GetGradBoostMVA (const std::vector< float > &values) const
float GetGradBoostMVA (const std::vector< float * > &pointers) const
std::vector< float > GetMultiResponse (const std::vector< float > &values, unsigned int numClasses) const
 Get response of the forest, for multiclassification (e.g.
std::vector< float > GetMultiResponse (const std::vector< float * > &pointers, unsigned int numClasses) const
std::vector< float > GetMultiResponse (unsigned int numClasses) const
std::vector< float > GetValues () const
 Return the values corresponding to m_pointers (or an empty vector)
const std::vector< float * > & GetPointers () const
 Return stored pointers (which are used by methods with no args)
void SetPointers (const std::vector< float * > &pointers)
 Set the stored pointers so that one can use methods with no args.
TTree * WriteTree (TString name="BDT") const
 Return a TTree representing the BDT: each entry is a binary tree, each element of the vectors is a node.
void PrintForest () const
 for debugging, print out tree or forest to stdout
void PrintTree (unsigned int itree) const
float GetTreeResponse (const std::vector< float > &values, MVAUtils::index_t index) const
 for debugging, return the response of a sigle tree given the index of its top node
float GetTreeResponse (const std::vector< float * > &pointers, MVAUtils::index_t index) const

Private Attributes

std::unique_ptr< IForestm_forest
 the implementation of the forest, doing the hard work
std::vector< float * > m_pointers
 where vars to cut on can be set (but can also be passed)

Detailed Description

Simplified Boosted Regression Tree, support TMVA, lgbm, and xgboost.

Holds a forest (vector of top nodes of each decision tree) and a constant offset or set of weights (not always used).

Each entry of the TTree represents a binary tree and each element of the vectors stored in the TTree represent a node.

The response can be evaluated from a vector of floats or a vector of pointers (to avoid creating vectors at each call) which can be stored internally (m_pointers)

Definition at line 34 of file Reconstruction/MVAUtils/MVAUtils/BDT.h.

Constructor & Destructor Documentation

◆ BDT() [1/5]

MVAUtils::BDT::BDT ( TTree * tree)
explicit

Constructor.

The input tree must be created with convertLGBMToRootTree.py (for lgbm training) or with convertXGBoostToRootTree.py (for xgboost training) or with convertXmlToRootTree (for tmva training)

◆ BDT() [2/5]

MVAUtils::BDT::BDT ( std::unique_ptr< IForest > forest)
inlineexplicit

Definition at line 44 of file Reconstruction/MVAUtils/MVAUtils/BDT.h.

44 :
45 m_forest(std::move(forest)){
46 }
std::unique_ptr< IForest > m_forest
the implementation of the forest, doing the hard work

◆ BDT() [3/5]

MVAUtils::BDT::BDT ( )
delete

◆ BDT() [4/5]

MVAUtils::BDT::BDT ( const BDT & )
delete

◆ BDT() [5/5]

MVAUtils::BDT::BDT ( BDT && )
default

default move ctor, move assignment and dtor

default move ctor, move assignment

◆ ~BDT()

MVAUtils::BDT::~BDT ( )
default

Member Function Documentation

◆ GetClassification() [1/3]

float MVAUtils::BDT::GetClassification ( ) const

◆ GetClassification() [2/3]

float MVAUtils::BDT::GetClassification ( const std::vector< float * > & pointers) const

◆ GetClassification() [3/3]

float MVAUtils::BDT::GetClassification ( const std::vector< float > & values) const

Get response of the forest, for classification.

◆ GetGradBoostMVA() [1/2]

float MVAUtils::BDT::GetGradBoostMVA ( const std::vector< float * > & pointers) const

◆ GetGradBoostMVA() [2/2]

float MVAUtils::BDT::GetGradBoostMVA ( const std::vector< float > & values) const

◆ GetMultiResponse() [1/3]

std::vector< float > MVAUtils::BDT::GetMultiResponse ( const std::vector< float * > & pointers,
unsigned int numClasses ) const

◆ GetMultiResponse() [2/3]

std::vector< float > MVAUtils::BDT::GetMultiResponse ( const std::vector< float > & values,
unsigned int numClasses ) const

Get response of the forest, for multiclassification (e.g.

b-tagging)

◆ GetMultiResponse() [3/3]

std::vector< float > MVAUtils::BDT::GetMultiResponse ( unsigned int numClasses) const

◆ GetNTrees()

unsigned int MVAUtils::BDT::GetNTrees ( ) const

Number of trees in the whole forest.

◆ GetNVars()

int MVAUtils::BDT::GetNVars ( ) const

Number of variables expected in the inputs.

◆ GetOffset()

float MVAUtils::BDT::GetOffset ( ) const

Get the offset to the whole forest.

◆ GetPointers()

const std::vector< float * > & MVAUtils::BDT::GetPointers ( ) const

Return stored pointers (which are used by methods with no args)

◆ GetResponse() [1/3]

float MVAUtils::BDT::GetResponse ( ) const

◆ GetResponse() [2/3]

float MVAUtils::BDT::GetResponse ( const std::vector< float * > & pointers) const

◆ GetResponse() [3/3]

float MVAUtils::BDT::GetResponse ( const std::vector< float > & values) const

Get response of the forest, for regression.

◆ GetTreeResponse() [1/2]

float MVAUtils::BDT::GetTreeResponse ( const std::vector< float * > & pointers,
MVAUtils::index_t index ) const

◆ GetTreeResponse() [2/2]

float MVAUtils::BDT::GetTreeResponse ( const std::vector< float > & values,
MVAUtils::index_t index ) const

for debugging, return the response of a sigle tree given the index of its top node

◆ GetValues()

std::vector< float > MVAUtils::BDT::GetValues ( ) const

Return the values corresponding to m_pointers (or an empty vector)

◆ operator=() [1/2]

BDT & MVAUtils::BDT::operator= ( BDT && )
default

◆ operator=() [2/2]

BDT & MVAUtils::BDT::operator= ( const BDT & )
delete

◆ PrintForest()

void BDT::PrintForest ( ) const

for debugging, print out tree or forest to stdout

Definition at line 92 of file BDT.cxx.

92{ m_forest->PrintForest(); }

◆ PrintTree()

void BDT::PrintTree ( unsigned int itree) const

Definition at line 93 of file BDT.cxx.

93{ m_forest->PrintTree(itree); }

◆ SetPointers()

void MVAUtils::BDT::SetPointers ( const std::vector< float * > & pointers)

Set the stored pointers so that one can use methods with no args.

◆ WriteTree()

TTree * BDT::WriteTree ( TString name = "BDT") const

Return a TTree representing the BDT: each entry is a binary tree, each element of the vectors is a node.

Definition at line 91 of file BDT.cxx.

91{ return m_forest->WriteTree(std::move(name)); }

Member Data Documentation

◆ m_forest

std::unique_ptr<IForest> MVAUtils::BDT::m_forest
private

the implementation of the forest, doing the hard work

Definition at line 107 of file Reconstruction/MVAUtils/MVAUtils/BDT.h.

◆ m_pointers

std::vector<float*> MVAUtils::BDT::m_pointers
private

where vars to cut on can be set (but can also be passed)

Definition at line 108 of file Reconstruction/MVAUtils/MVAUtils/BDT.h.


The documentation for this class was generated from the following files: