Logo ROOT   6.07/09
Reference Guide
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TMVA::DecisionTree Class Reference

Definition at line 73 of file DecisionTree.h.

Public Types

enum  EPruneMethod { kExpectedErrorPruning =0, kCostComplexityPruning, kNoPruning }
 
typedef std::vector< const TMVA::Event * > EventConstList
 
typedef std::vector< TMVA::Event * > EventList
 

Public Member Functions

 DecisionTree (void)
 
 DecisionTree (SeparationBase *sepType, Float_t minSize, Int_t nCuts, DataSetInfo *=NULL, UInt_t cls=0, Bool_t randomisedTree=kFALSE, Int_t useNvars=0, Bool_t usePoissonNvars=kFALSE, UInt_t nMaxDepth=9999999, Int_t iSeed=fgRandomSeed, Float_t purityLimit=0.5, Int_t treeID=0)
 constructor specifying the separation type, the min number of events in a no that is still subjected to further splitting, the number of bins in the grid used in applying the cut for the node splitting. More...
 
 DecisionTree (const DecisionTree &d)
 copy constructor that creates a true copy, i.e. More...
 
virtual ~DecisionTree (void)
 destructor More...
 
void ApplyValidationSample (const EventConstList *validationSample) const
 run the validation sample through the (pruned) tree and fill in the nodes the variables NSValidation and NBValidadtion (i.e. More...
 
UInt_t BuildTree (const EventConstList &eventSample, DecisionTreeNode *node=NULL)
 building the decision tree by recursively calling the splitting of one (root-) node into two daughter nodes (returns the number of nodes) More...
 
Double_t CheckEvent (const TMVA::Event *, Bool_t UseYesNoLeaf=kFALSE) const
 the event e is put into the decision tree (starting at the root node) and the output is NodeType (signal) or (background) of the final node (basket) in which the given events ends up. More...
 
void CheckEventWithPrunedTree (const TMVA::Event *) const
 pass a single validation event throught a pruned decision tree on the way down the tree, fill in all the "intermediate" information that would normally be there from training. More...
 
virtual const char * ClassName () const
 
UInt_t CleanTree (DecisionTreeNode *node=NULL)
 remove those last splits that result in two leaf nodes that are both of the type (i.e. More...
 
void ClearTree ()
 clear the tree nodes (their S/N, Nevents etc), just keep the structure of the tree More...
 
UInt_t CountLeafNodes (TMVA::Node *n=NULL)
 return the number of terminal nodes in the sub-tree below Node n More...
 
virtual DecisionTreeNodeCreateNode (UInt_t) const
 
virtual BinaryTreeCreateTree () const
 
void DescendTree (Node *n=NULL)
 descend a tree to find all its leaf nodes More...
 
Bool_t DoRegression () const
 
void FillEvent (const TMVA::Event &event, TMVA::DecisionTreeNode *node)
 fill the existing the decision tree structure by filling event in from the top node and see where they happen to end up More...
 
void FillTree (const EventList &eventSample)
 
Types::EAnalysisType GetAnalysisType (void)
 
TMVA::DecisionTreeNodeGetEventNode (const TMVA::Event &e) const
 get the pointer to the leaf node where a particular event ends up in... More...
 
std::vector< Double_tGetFisherCoefficients (const EventConstList &eventSample, UInt_t nFisherVars, UInt_t *mapVarInFisher)
 calculate the fisher coefficients for the event sample and the variables used More...
 
Int_t GetNNodesBeforePruning ()
 
NodeGetNode (ULong_t sequence, UInt_t depth)
 retrieve node from the tree. More...
 
Double_t GetNodePurityLimit () const
 
Double_t GetPruneStrength () const
 
void GetRandomisedVariables (Bool_t *useVariable, UInt_t *variableMap, UInt_t &nVars)
 
virtual DecisionTreeNodeGetRoot () const
 
Double_t GetSumWeights (const EventConstList *validationSample) const
 calculate the normalization factor for a pruning validation sample More...
 
Int_t GetTreeID ()
 
std::vector< Double_tGetVariableImportance ()
 Return the relative variable importance, normalized to all variables together having the importance 1. More...
 
Double_t GetVariableImportance (UInt_t ivar)
 returns the relative improtance of variable ivar More...
 
void PruneNode (TMVA::DecisionTreeNode *node)
 prune away the subtree below the node More...
 
void PruneNodeInPlace (TMVA::DecisionTreeNode *node)
 prune a node temporaily (without actually deleting its decendants which allows testing the pruned tree quality for many different pruning stages without "touching" the tree. More...
 
Double_t PruneTree (const EventConstList *validationSample=NULL)
 prune (get rid of internal nodes) the Decision tree to avoid overtraining serveral different pruning methods can be applied as selected by the variable "fPruneMethod". More...
 
void SetAnalysisType (Types::EAnalysisType t)
 
void SetMinLinCorrForFisher (Double_t min)
 
void SetNodePurityLimit (Double_t p)
 
void SetNVars (Int_t n)
 
void SetParentTreeInNodes (Node *n=NULL)
 descend a tree to find all its leaf nodes, fill max depth reached in the tree at the same time. More...
 
void SetPruneMethod (EPruneMethod m=kCostComplexityPruning)
 
void SetPruneStrength (Double_t p)
 
void SetTreeID (Int_t treeID)
 
void SetUseExclusiveVars (Bool_t t=kTRUE)
 
void SetUseFisherCuts (Bool_t t=kTRUE)
 
Double_t TestPrunedTreeQuality (const DecisionTreeNode *dt=NULL, Int_t mode=0) const
 return the misclassification rate of a pruned tree a "pruned tree" may have set the variable "IsTerminal" to "arbitrary" at any node, hence this tree quality testing will stop there, hence test the pruned tree (while the full tree is still in place for normal/later use) More...
 
Double_t TrainNode (const EventConstList &eventSample, DecisionTreeNode *node)
 
Double_t TrainNodeFast (const EventConstList &eventSample, DecisionTreeNode *node)
 Decide how to split a node using one of the variables that gives the best separation of signal/background. More...
 
Double_t TrainNodeFull (const EventConstList &eventSample, DecisionTreeNode *node)
 
- Public Member Functions inherited from TMVA::BinaryTree
 BinaryTree (void)
 constructor for a yet "empty" tree. Needs to be filled afterwards More...
 
virtual ~BinaryTree ()
 destructor (deletes the nodes and "events" if owned by the tree More...
 
virtual voidAddXMLTo (void *parent) const
 add attributes to XML More...
 
UInt_t CountNodes (Node *n=NULL)
 return the number of nodes in the tree. (make a new count –> takes time) More...
 
NodeGetLeftDaughter (Node *n)
 get left daughter node current node "n" More...
 
UInt_t GetNNodes () const
 
NodeGetRightDaughter (Node *n)
 get right daughter node current node "n" More...
 
UInt_t GetTotalTreeDepth () const
 
virtual void Print (std::ostream &os) const
 recursively print the tree More...
 
virtual void Read (std::istream &istr, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
 Read the binary tree from an input stream. More...
 
virtual void ReadXML (void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
 read attributes from XML More...
 
void SetRoot (Node *r)
 
void SetTotalTreeDepth (Int_t depth)
 
void SetTotalTreeDepth (Node *n=NULL)
 descend a tree to find all its leaf nodes, fill max depth reached in the tree at the same time. More...
 

Static Public Member Functions

static DecisionTreeCreateFromXML (void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
 re-create a new tree (decision tree or search tree) from XML More...
 

Private Member Functions

Double_t SamplePurity (EventList eventSample)
 calculates the purity S/(S+B) of a given event sample More...
 

Private Attributes

Types::EAnalysisType fAnalysisType
 
DataSetInfofDataSetInfo
 
UInt_t fMaxDepth
 
Double_t fMinLinCorrForFisher
 
Double_t fMinNodeSize
 
Double_t fMinSepGain
 
Double_t fMinSize
 
TRandom3fMyTrandom
 
Int_t fNCuts
 
Int_t fNNodesBeforePruning
 
Double_t fNodePurityLimit
 
UInt_t fNvars
 
EPruneMethod fPruneMethod
 
Double_t fPruneStrength
 
Bool_t fRandomisedTree
 
RegressionVariancefRegType
 
SeparationBasefSepType
 
UInt_t fSigClass
 
Int_t fTreeID
 
Bool_t fUseExclusiveVars
 
Bool_t fUseFisherCuts
 
Int_t fUseNvars
 
Bool_t fUsePoissonNvars
 
Bool_t fUseSearchTree
 
std::vector< Double_tfVariableImportance
 

Static Private Attributes

static const Int_t fgDebugLevel = 0
 
static const Int_t fgRandomSeed = 0
 

Additional Inherited Members

- Protected Member Functions inherited from TMVA::BinaryTree
void DeleteNode (Node *)
 protected, recursive, function used by the class destructor and when Pruning More...
 
MsgLoggerLog () const
 
- Protected Attributes inherited from TMVA::BinaryTree
UInt_t fDepth
 
UInt_t fNNodes
 
NodefRoot
 

#include <TMVA/DecisionTree.h>

Inheritance diagram for TMVA::DecisionTree:
[legend]

Member Typedef Documentation

typedef std::vector<const TMVA::Event*> TMVA::DecisionTree::EventConstList

Definition at line 82 of file DecisionTree.h.

Definition at line 81 of file DecisionTree.h.

Member Enumeration Documentation

Enumerator
kExpectedErrorPruning 
kCostComplexityPruning 
kNoPruning 

Definition at line 147 of file DecisionTree.h.

Constructor & Destructor Documentation

TMVA::DecisionTree::DecisionTree ( void  )

Definition at line 114 of file DecisionTree.cxx.

TMVA::DecisionTree::DecisionTree ( TMVA::SeparationBase sepType,
Float_t  minSize,
Int_t  nCuts,
DataSetInfo dataInfo = NULL,
UInt_t  cls = 0,
Bool_t  randomisedTree = kFALSE,
Int_t  useNvars = 0,
Bool_t  usePoissonNvars = kFALSE,
UInt_t  nMaxDepth = 9999999,
Int_t  iSeed = fgRandomSeed,
Float_t  purityLimit = 0.5,
Int_t  treeID = 0 
)

constructor specifying the separation type, the min number of events in a no that is still subjected to further splitting, the number of bins in the grid used in applying the cut for the node splitting.

Definition at line 149 of file DecisionTree.cxx.

TMVA::DecisionTree::DecisionTree ( const DecisionTree d)

copy constructor that creates a true copy, i.e.

a completely independent tree the node copy will recursively copy all the nodes

Definition at line 199 of file DecisionTree.cxx.

TMVA::DecisionTree::~DecisionTree ( void  )
virtual

destructor

Definition at line 234 of file DecisionTree.cxx.

Member Function Documentation

void TMVA::DecisionTree::ApplyValidationSample ( const EventConstList validationSample) const

run the validation sample through the (pruned) tree and fill in the nodes the variables NSValidation and NBValidadtion (i.e.

how many of the Signal and Background events from the validation sample. This is then later used when asking for the "tree quality" ..

Definition at line 686 of file DecisionTree.cxx.

UInt_t TMVA::DecisionTree::BuildTree ( const EventConstList eventSample,
DecisionTreeNode node = NULL 
)

building the decision tree by recursively calling the splitting of one (root-) node into two daughter nodes (returns the number of nodes)

Definition at line 293 of file DecisionTree.cxx.

Double_t TMVA::DecisionTree::CheckEvent ( const TMVA::Event e,
Bool_t  UseYesNoLeaf = kFALSE 
) const

the event e is put into the decision tree (starting at the root node) and the output is NodeType (signal) or (background) of the final node (basket) in which the given events ends up.

I.e. the result of the classification if the event for this decision tree.

Definition at line 1712 of file DecisionTree.cxx.

void TMVA::DecisionTree::CheckEventWithPrunedTree ( const TMVA::Event e) const

pass a single validation event throught a pruned decision tree on the way down the tree, fill in all the "intermediate" information that would normally be there from training.

Definition at line 742 of file DecisionTree.cxx.

virtual const char* TMVA::DecisionTree::ClassName ( ) const
inlinevirtual

Implements TMVA::BinaryTree.

Definition at line 106 of file DecisionTree.h.

UInt_t TMVA::DecisionTree::CleanTree ( DecisionTreeNode node = NULL)

remove those last splits that result in two leaf nodes that are both of the type (i.e.

both signal or both background) this of course is only a reasonable thing to do when you use "YesOrNo" leafs, while it might loose s.th. if you use the purity information in the nodes. –> hence I don't call it automatically in the tree building

Definition at line 590 of file DecisionTree.cxx.

void TMVA::DecisionTree::ClearTree ( )

clear the tree nodes (their S/N, Nevents etc), just keep the structure of the tree

Definition at line 576 of file DecisionTree.cxx.

UInt_t TMVA::DecisionTree::CountLeafNodes ( TMVA::Node n = NULL)

return the number of terminal nodes in the sub-tree below Node n

Definition at line 790 of file DecisionTree.cxx.

TMVA::DecisionTree * TMVA::DecisionTree::CreateFromXML ( void node,
UInt_t  tmva_Version_Code = TMVA_VERSION_CODE 
)
static

re-create a new tree (decision tree or search tree) from XML

Definition at line 279 of file DecisionTree.cxx.

virtual DecisionTreeNode* TMVA::DecisionTree::CreateNode ( UInt_t  ) const
inlinevirtual

Implements TMVA::BinaryTree.

Definition at line 103 of file DecisionTree.h.

virtual BinaryTree* TMVA::DecisionTree::CreateTree ( ) const
inlinevirtual

Implements TMVA::BinaryTree.

Definition at line 104 of file DecisionTree.h.

void TMVA::DecisionTree::DescendTree ( Node n = NULL)

descend a tree to find all its leaf nodes

Definition at line 819 of file DecisionTree.cxx.

Bool_t TMVA::DecisionTree::DoRegression ( ) const
inline

Definition at line 196 of file DecisionTree.h.

void TMVA::DecisionTree::FillEvent ( const TMVA::Event event,
TMVA::DecisionTreeNode node 
)

fill the existing the decision tree structure by filling event in from the top node and see where they happen to end up

Definition at line 542 of file DecisionTree.cxx.

void TMVA::DecisionTree::FillTree ( const EventList eventSample)

Definition at line 528 of file DecisionTree.cxx.

Types::EAnalysisType TMVA::DecisionTree::GetAnalysisType ( void  )
inline

Definition at line 198 of file DecisionTree.h.

TMVA::DecisionTreeNode * TMVA::DecisionTree::GetEventNode ( const TMVA::Event e) const

get the pointer to the leaf node where a particular event ends up in...

(used in gradient boosting)

Definition at line 1695 of file DecisionTree.cxx.

std::vector< Double_t > TMVA::DecisionTree::GetFisherCoefficients ( const EventConstList eventSample,
UInt_t  nFisherVars,
UInt_t mapVarInFisher 
)

calculate the fisher coefficients for the event sample and the variables used

Definition at line 1369 of file DecisionTree.cxx.

Int_t TMVA::DecisionTree::GetNNodesBeforePruning ( )
inline

Definition at line 188 of file DecisionTree.h.

TMVA::Node * TMVA::DecisionTree::GetNode ( ULong_t  sequence,
UInt_t  depth 
)

retrieve node from the tree.

Its position (up to a maximal tree depth of 64) is coded as a sequence of left-right moves starting from the root, coded as 0-1 bit patterns stored in the "long-integer" (i.e. 0:left ; 1:right

Definition at line 890 of file DecisionTree.cxx.

Double_t TMVA::DecisionTree::GetNodePurityLimit ( ) const
inline

Definition at line 170 of file DecisionTree.h.

Double_t TMVA::DecisionTree::GetPruneStrength ( ) const
inline

Definition at line 155 of file DecisionTree.h.

void TMVA::DecisionTree::GetRandomisedVariables ( Bool_t useVariable,
UInt_t variableMap,
UInt_t nVars 
)

Definition at line 907 of file DecisionTree.cxx.

virtual DecisionTreeNode* TMVA::DecisionTree::GetRoot ( ) const
inlinevirtual

Reimplemented from TMVA::BinaryTree.

Definition at line 102 of file DecisionTree.h.

Double_t TMVA::DecisionTree::GetSumWeights ( const EventConstList validationSample) const

calculate the normalization factor for a pruning validation sample

Definition at line 775 of file DecisionTree.cxx.

Int_t TMVA::DecisionTree::GetTreeID ( )
inline

Definition at line 194 of file DecisionTree.h.

vector< Double_t > TMVA::DecisionTree::GetVariableImportance ( )

Return the relative variable importance, normalized to all variables together having the importance 1.

The importance in evaluated as the total separation-gain that this variable had in the decision trees (weighted by the number of events)

Definition at line 1765 of file DecisionTree.cxx.

Double_t TMVA::DecisionTree::GetVariableImportance ( UInt_t  ivar)

returns the relative improtance of variable ivar

Definition at line 1786 of file DecisionTree.cxx.

void TMVA::DecisionTree::PruneNode ( TMVA::DecisionTreeNode node)

prune away the subtree below the node

Definition at line 853 of file DecisionTree.cxx.

void TMVA::DecisionTree::PruneNodeInPlace ( TMVA::DecisionTreeNode node)

prune a node temporaily (without actually deleting its decendants which allows testing the pruned tree quality for many different pruning stages without "touching" the tree.

Definition at line 876 of file DecisionTree.cxx.

Double_t TMVA::DecisionTree::PruneTree ( const EventConstList validationSample = NULL)

prune (get rid of internal nodes) the Decision tree to avoid overtraining serveral different pruning methods can be applied as selected by the variable "fPruneMethod".

Definition at line 617 of file DecisionTree.cxx.

Double_t TMVA::DecisionTree::SamplePurity ( EventList  eventSample)
private

calculates the purity S/(S+B) of a given event sample

Definition at line 1742 of file DecisionTree.cxx.

void TMVA::DecisionTree::SetAnalysisType ( Types::EAnalysisType  t)
inline

Definition at line 197 of file DecisionTree.h.

void TMVA::DecisionTree::SetMinLinCorrForFisher ( Double_t  min)
inline

Definition at line 200 of file DecisionTree.h.

void TMVA::DecisionTree::SetNodePurityLimit ( Double_t  p)
inline

Definition at line 169 of file DecisionTree.h.

void TMVA::DecisionTree::SetNVars ( Int_t  n)
inline

Definition at line 202 of file DecisionTree.h.

void TMVA::DecisionTree::SetParentTreeInNodes ( Node n = NULL)

descend a tree to find all its leaf nodes, fill max depth reached in the tree at the same time.

Definition at line 246 of file DecisionTree.cxx.

void TMVA::DecisionTree::SetPruneMethod ( EPruneMethod  m = kCostComplexityPruning)
inline

Definition at line 148 of file DecisionTree.h.

void TMVA::DecisionTree::SetPruneStrength ( Double_t  p)
inline

Definition at line 154 of file DecisionTree.h.

void TMVA::DecisionTree::SetTreeID ( Int_t  treeID)
inline

Definition at line 193 of file DecisionTree.h.

void TMVA::DecisionTree::SetUseExclusiveVars ( Bool_t  t = kTRUE)
inline

Definition at line 201 of file DecisionTree.h.

void TMVA::DecisionTree::SetUseFisherCuts ( Bool_t  t = kTRUE)
inline

Definition at line 199 of file DecisionTree.h.

Double_t TMVA::DecisionTree::TestPrunedTreeQuality ( const DecisionTreeNode dt = NULL,
Int_t  mode = 0 
) const

return the misclassification rate of a pruned tree a "pruned tree" may have set the variable "IsTerminal" to "arbitrary" at any node, hence this tree quality testing will stop there, hence test the pruned tree (while the full tree is still in place for normal/later use)

Definition at line 700 of file DecisionTree.cxx.

Double_t TMVA::DecisionTree::TrainNode ( const EventConstList eventSample,
DecisionTreeNode node 
)
inline

Definition at line 116 of file DecisionTree.h.

Double_t TMVA::DecisionTree::TrainNodeFast ( const EventConstList eventSample,
TMVA::DecisionTreeNode node 
)

Decide how to split a node using one of the variables that gives the best separation of signal/background.

In order to do this, for each variable a scan of the different cut values in a grid (grid = fNCuts) is performed and the resulting separation gains are compared. in addition to the individual variables, one can also ask for a fisher discriminant being built out of (some) of the variables and used as a possible multivariate split.

Definition at line 940 of file DecisionTree.cxx.

Double_t TMVA::DecisionTree::TrainNodeFull ( const EventConstList eventSample,
TMVA::DecisionTreeNode node 
)

Definition at line 1561 of file DecisionTree.cxx.

Member Data Documentation

Types::EAnalysisType TMVA::DecisionTree::fAnalysisType
private

Definition at line 248 of file DecisionTree.h.

DataSetInfo* TMVA::DecisionTree::fDataSetInfo
private

Definition at line 250 of file DecisionTree.h.

const Int_t TMVA::DecisionTree::fgDebugLevel = 0
staticprivate

Definition at line 245 of file DecisionTree.h.

const Int_t TMVA::DecisionTree::fgRandomSeed = 0
staticprivate

Definition at line 77 of file DecisionTree.h.

UInt_t TMVA::DecisionTree::fMaxDepth
private

Definition at line 243 of file DecisionTree.h.

Double_t TMVA::DecisionTree::fMinLinCorrForFisher
private

Definition at line 217 of file DecisionTree.h.

Double_t TMVA::DecisionTree::fMinNodeSize
private

Definition at line 224 of file DecisionTree.h.

Double_t TMVA::DecisionTree::fMinSepGain
private

Definition at line 225 of file DecisionTree.h.

Double_t TMVA::DecisionTree::fMinSize
private

Definition at line 223 of file DecisionTree.h.

TRandom3* TMVA::DecisionTree::fMyTrandom
private

Definition at line 239 of file DecisionTree.h.

Int_t TMVA::DecisionTree::fNCuts
private

Definition at line 215 of file DecisionTree.h.

Int_t TMVA::DecisionTree::fNNodesBeforePruning
private

Definition at line 231 of file DecisionTree.h.

Double_t TMVA::DecisionTree::fNodePurityLimit
private

Definition at line 233 of file DecisionTree.h.

UInt_t TMVA::DecisionTree::fNvars
private

Definition at line 214 of file DecisionTree.h.

EPruneMethod TMVA::DecisionTree::fPruneMethod
private

Definition at line 230 of file DecisionTree.h.

Double_t TMVA::DecisionTree::fPruneStrength
private

Definition at line 228 of file DecisionTree.h.

Bool_t TMVA::DecisionTree::fRandomisedTree
private

Definition at line 235 of file DecisionTree.h.

RegressionVariance* TMVA::DecisionTree::fRegType
private

Definition at line 221 of file DecisionTree.h.

SeparationBase* TMVA::DecisionTree::fSepType
private

Definition at line 220 of file DecisionTree.h.

UInt_t TMVA::DecisionTree::fSigClass
private

Definition at line 244 of file DecisionTree.h.

Int_t TMVA::DecisionTree::fTreeID
private

Definition at line 246 of file DecisionTree.h.

Bool_t TMVA::DecisionTree::fUseExclusiveVars
private

Definition at line 218 of file DecisionTree.h.

Bool_t TMVA::DecisionTree::fUseFisherCuts
private

Definition at line 216 of file DecisionTree.h.

Int_t TMVA::DecisionTree::fUseNvars
private

Definition at line 236 of file DecisionTree.h.

Bool_t TMVA::DecisionTree::fUsePoissonNvars
private

Definition at line 237 of file DecisionTree.h.

Bool_t TMVA::DecisionTree::fUseSearchTree
private

Definition at line 227 of file DecisionTree.h.

std::vector< Double_t > TMVA::DecisionTree::fVariableImportance
private

Definition at line 241 of file DecisionTree.h.


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