ROOT  6.06/09
Reference Guide
MethodCompositeBase.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss,Or Cohen
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : MethodCompositeBase *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Virtual base class for all MVA method *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
16  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
17  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
18  * Or Cohen <orcohenor@gmail.com> - Weizmann Inst., Israel *
19  * *
20  * Copyright (c) 2005: *
21  * CERN, Switzerland *
22  * U. of Victoria, Canada *
23  * MPI-K Heidelberg, Germany *
24  * LAPP, Annecy, France *
25  * *
26  * Redistribution and use in source and binary forms, with or without *
27  * modification, are permitted according to the terms listed in LICENSE *
28  * (http://tmva.sourceforge.net/LICENSE) *
29  **********************************************************************************/
30 
31 #ifndef ROOT_TMVA_MethodCompositeBase
32 #define ROOT_TMVA_MethodCompositeBase
33 
34 //////////////////////////////////////////////////////////////////////////
35 // //
36 // MethodCompositeBase //
37 // //
38 // Virtual base class for combining several TMVA method //
39 // //
40 //////////////////////////////////////////////////////////////////////////
41 
42 #include <iosfwd>
43 #include <vector>
44 
45 #ifndef ROOT_TMVA_MethodBase
46 #include "TMVA/MethodBase.h"
47 #endif
48 
49 namespace TMVA {
50  class IMethod;
51 
53 
54  public :
55  MethodCompositeBase( const TString& jobName,
56  Types::EMVA methodType,
57  const TString& methodTitle,
58  DataSetInfo& theData,
59  const TString& theOption = "",
60  TDirectory* theTargetDir = NULL );
61 
62 
63  MethodCompositeBase( Types::EMVA methodType,
64  DataSetInfo& dsi,
65  const TString& weightFile,
66  TDirectory* theBaseDir = 0 );
67 
69 
70  // write weights to file
71  void AddWeightsXMLTo( void* parent ) const;
72  void ReadWeightsFromXML( void* wghtnode );
73 
74  // calculate the MVA value combining all classifiers according to thier fMethodWeight
75  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
76 
78 
79  // read weights from file
80  void ReadWeightsFromStream( std::istream& istr );
81 
82  // performs classifier training
83  virtual void Train() = 0;
84 
85  // create ranking
86  virtual const Ranking* CreateRanking() = 0;
87 
88  virtual ~MethodCompositeBase( void );
89 
90  protected:
91 
92  void DeclareOptions() = 0;
93  void ProcessOptions() = 0;
94 
95  IMethod* GetMethod( const TString& title ) const; // accessor by name
96 
97  IMethod* GetMethod( const Int_t index ) const; // accessor by index in vector
98 
99  //the index of the classifier currently boosted
103 
104  IMethod* GetLastMethod() { return fMethods.back(); }
105 
106  IMethod* GetPreviousMethod() { return (fCurrentMethodIdx>0)?fMethods[fCurrentMethodIdx-1]:0; }
107 
109  MethodBase* GetCurrentMethod(UInt_t idx){return dynamic_cast<MethodBase*>(fMethods.at(idx)); }
110 
111 
112 
113  std::vector<IMethod*> fMethods; // vector of all classifiers
114 
115  //the weight of every classifier used in the GetMVA method
116  std::vector<Double_t> fMethodWeight;
117 
119 
120  };
121 }
122 
123 #endif
124 
virtual void Train()=0
virtual Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)=0
void ReadWeightsFromXML(void *wghtnode)
XML streamer.
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
void ReadWeightsFromStream(std::istream &istr)
text streamer
void AddWeightsXMLTo(void *parent) const
MethodCompositeBase(const TString &jobName, Types::EMVA methodType, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="", TDirectory *theTargetDir=NULL)
#define ClassDef(name, id)
Definition: Rtypes.h:254
std::vector< Double_t > fMethodWeight
virtual ~MethodCompositeBase(void)
delete methods
IMethod * GetMethod(const TString &title) const
returns pointer to MVA that corresponds to given method title
unsigned int UInt_t
Definition: RtypesCore.h:42
double Double_t
Definition: RtypesCore.h:55
Describe directory structure in memory.
Definition: TDirectory.h:41
std::vector< IMethod * > fMethods
Abstract ClassifierFactory template that handles arbitrary types.
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
return composite MVA response
#define NULL
Definition: Rtypes.h:82
virtual void ReadWeightsFromStream(std::istream &)=0
virtual const Ranking * CreateRanking()=0
MethodBase * GetCurrentMethod(UInt_t idx)