Logo ROOT   6.14/05
Reference Guide
IPruneTool.h
Go to the documentation of this file.
1 /**********************************************************************************
2  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
3  * Package: TMVA *
4  * Class : TMVA::DecisionTree *
5  * Web : http://tmva.sourceforge.net *
6  * *
7  * Description: *
8  * IPruneTool - a helper interface class to prune a decision tree *
9  * *
10  * Authors (alphabetical): *
11  * Doug Schouten <dschoute@sfu.ca> - Simon Fraser U., Canada *
12  * *
13  * Copyright (c) 2005: *
14  * CERN, Switzerland *
15  * MPI-K Heidelberg, Germany *
16  * *
17  * Redistribution and use in source and binary forms, with or without *
18  * modification, are permitted according to the terms listed in LICENSE *
19  * (http://mva.sourceforge.net/license.txt) *
20  **********************************************************************************/
21 
22 #ifndef ROOT_TMVA_IPruneTool
23 #define ROOT_TMVA_IPruneTool
24 
25 #include <iosfwd>
26 #include <vector>
27 
28 #include "TMVA/SeparationBase.h"
29 
30 #include "TMVA/DecisionTree.h"
31 
32 namespace TMVA {
33 
34  // class MsgLogger;
35 
36  ////////////////////////////////////////////////////////////
37  // Basic struct for saving relevant pruning information //
38  ////////////////////////////////////////////////////////////
39  class PruningInfo {
40 
41  public:
42 
44  PruningInfo( Double_t q, Double_t alpha, std::vector<DecisionTreeNode*> sequence );
45  Double_t QualityIndex; //! quality measure for a pruned subtree T of T_max
46  Double_t PruneStrength; //! the regularization parameter for pruning
47  std::vector<DecisionTreeNode*> PruneSequence; //! the sequence of pruning locations in T_max that yields T
48  };
49 
50  inline PruningInfo::PruningInfo( Double_t q, Double_t alpha, std::vector<DecisionTreeNode*> sequence )
51  : QualityIndex(q), PruneStrength(alpha), PruneSequence(sequence) {}
52 
53 /*! \class TMVA::IPruneTool
54 \ingroup TMVA
55 IPruneTool - a helper interface class to prune a decision tree
56 
57 Any tool which implements the interface should provide two modes for tree pruning:
58 
59  1. automatically find the "best" prune strength by minimizing the error rate on a test sample
60  if SetAutomatic() is called, or if automatic = kTRUE argument is set in CalculatePruningInfo()
61  In this case, the PruningInfo object returned contains the error rate of the optimally pruned
62  tree, the optimal prune strength, and the sequence of nodes to prune to obtain the optimal
63  pruned tree from the original DecisionTree
64 
65  2. a user-provided pruning strength parameter is used to prune the tree, in which case the returned
66  PruningInfo object has QualityIndex = -1, PruneStrength = user prune strength, and PruneSequence
67  is the list of nodes to prune
68 */
69 
70  class IPruneTool {
71 
72  public:
73 
74  typedef std::vector<const Event*> EventSample;
75 
76  IPruneTool( );
77  virtual ~IPruneTool();
78 
79  public:
80 
81  // returns the PruningInfo object for a given tree and test sample
82  virtual PruningInfo* CalculatePruningInfo( DecisionTree* dt, const EventSample* testEvents = NULL,
83  Bool_t isAutomatic = kFALSE ) = 0;
84 
85  public:
86 
87  // set the prune strength parameter to use in pruning
88  inline void SetPruneStrength( Double_t alpha ) { fPruneStrength = alpha; }
89  // return the prune strength the tool is using
90  inline Double_t GetPruneStrength( ) const { return fPruneStrength; }
91 
92  // if the prune strength parameter is < 0, the tool will automatically find an optimal strength
93  // set the tool to automatic mode
94  inline void SetAutomatic( ) { fPruneStrength = -1.0; };
95  inline Bool_t IsAutomatic( ) const { return fPruneStrength <= 0.0; }
96 
97  protected:
98 
99  // mutable MsgLogger* fLogger; //! output stream to save logging information
100  // MsgLogger& Log() const { return *fLogger; }
101  Double_t fPruneStrength; //! regularization parameter in pruning
102 
103 
105  };
106 
108  fPruneStrength(0.0),
109  S(0),
110  B(0)
111  {}
113 
114 }
115 
116 #endif
static double B[]
Double_t PruneStrength
quality measure for a pruned subtree T of T_max
Definition: IPruneTool.h:46
Double_t fPruneStrength
Definition: IPruneTool.h:101
std::vector< DecisionTreeNode * > PruneSequence
the regularization parameter for pruning
Definition: IPruneTool.h:47
bool Bool_t
Definition: RtypesCore.h:59
void SetAutomatic()
Definition: IPruneTool.h:94
Double_t GetPruneStrength() const
Definition: IPruneTool.h:90
Bool_t IsAutomatic() const
Definition: IPruneTool.h:95
std::vector< const Event * > EventSample
Definition: IPruneTool.h:74
Double_t S
regularization parameter in pruning
Definition: IPruneTool.h:104
RooArgSet S(const RooAbsArg &v1)
Implementation of a Decision Tree.
Definition: DecisionTree.h:64
const Bool_t kFALSE
Definition: RtypesCore.h:88
double Double_t
Definition: RtypesCore.h:55
IPruneTool - a helper interface class to prune a decision tree.
Definition: IPruneTool.h:70
Abstract ClassifierFactory template that handles arbitrary types.
Double_t QualityIndex
Definition: IPruneTool.h:45
void SetPruneStrength(Double_t alpha)
Definition: IPruneTool.h:88
float * q
Definition: THbookFile.cxx:87
virtual ~IPruneTool()
Definition: IPruneTool.h:112