ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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. More...
 
 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 More...
 
BDToperator= (BDT &&)=default
 
 ~BDT ()=default
 
unsigned int GetNTrees () const
 Number of trees in the whole forest. More...
 
int GetNVars () const
 Number of variables expected in the inputs. More...
 
float GetOffset () const
 Get the offset to the whole forest. More...
 
float GetResponse (const std::vector< float > &values) const
 Get response of the forest, for regression. More...
 
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. More...
 
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. More...
 
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) More...
 
const std::vector< float * > & GetPointers () const
 Return stored pointers (which are used by methods with no args) More...
 
void SetPointers (const std::vector< float * > &pointers)
 Set the stored pointers so that one can use methods with no args. More...
 
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. More...
 
void PrintForest () const
 for debugging, print out tree or forest to stdout More...
 
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 More...
 
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 More...
 
std::vector< float * > m_pointers
 where vars to cut on can be set (but can also be passed) More...
 

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 33 of file 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 43 of file BDT.h.

43  :
44  m_forest(std::move(forest)){
45  }

◆ 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 106 of file 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 107 of file BDT.h.


The documentation for this class was generated from the following files:
MVAUtils::BDT::m_forest
std::unique_ptr< IForest > m_forest
the implementation of the forest, doing the hard work
Definition: BDT.h:106
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221