Logo ROOT   6.12/07
Reference Guide
Classification.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$ 2017
2 // Authors: Omar Zapata, Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss, Kai Voss, Eckhard von Toerne,
3 // Jan Therhaag
4 
5 #ifndef ROOT_TMVA_Classification
6 #define ROOT_TMVA_Classification
7 
8 #include <TString.h>
9 #include <TMultiGraph.h>
10 
11 #include <TMVA/IMethod.h>
12 #include <TMVA/MethodBase.h>
13 #include <TMVA/Configurable.h>
14 #include <TMVA/Types.h>
15 #include <TMVA/DataSet.h>
16 #include <TMVA/Event.h>
17 #include <TMVA/Results.h>
19 #include <TMVA/ResultsMulticlass.h>
20 #include <TMVA/Factory.h>
21 #include <TMVA/DataLoader.h>
22 #include <TMVA/OptionMap.h>
23 #include <TMVA/Envelope.h>
24 
25 /*! \class TMVA::ClassificationResult
26  * Class to save the results of the classifier.
27 \ingroup TMVA
28 */
29 
30 /*! \class TMVA::Classification
31  * Class to perform two class classification.
32 \ingroup TMVA
33 */
34 
35 namespace TMVA {
36 class ResultsClassification;
37 namespace Experimental {
38 class ClassificationResult : public TObject {
39  friend class Classification;
40 
41 private:
45  std::map<UInt_t, std::vector<std::tuple<Float_t, Float_t, Bool_t>>> fMvaTrain; // Mvas for two-class classification
46  std::map<UInt_t, std::vector<std::tuple<Float_t, Float_t, Bool_t>>>
47  fMvaTest; // Mvas for two-class and multiclass classification
48  std::vector<TString> fClassNames; //
49 
50  Bool_t IsMethod(TString methodname, TString methodtitle);
51 
52 public:
56 
57  const TString GetMethodName() const { return fMethod.GetValue<TString>("MethodName"); }
58  const TString GetMethodTitle() const { return fMethod.GetValue<TString>("MethodTitle"); }
62 
63  void Show();
64 
67 
69 };
70 
71 class Classification : public Envelope {
72  std::vector<ClassificationResult> fResults; //!
73  std::vector<IMethod *> fIMethods; //! vector of objects with booked methods
76  Bool_t fROC; //!
77 public:
78  explicit Classification(DataLoader *loader, TFile *file, TString options);
79  explicit Classification(DataLoader *loader, TString options);
80  ~Classification();
81 
82  virtual void Train();
83  virtual void TrainMethod(TString methodname, TString methodtitle);
84  virtual void TrainMethod(Types::EMVA method, TString methodtitle);
85 
86  virtual void Test();
87  virtual void TestMethod(TString methodname, TString methodtitle);
88  virtual void TestMethod(Types::EMVA method, TString methodtitle);
89 
90  virtual void Evaluate();
91 
92  std::vector<ClassificationResult> &GetResults();
93 
94  MethodBase *GetMethod(TString methodname, TString methodtitle);
95 
96 protected:
97  void CreateEnvironment();
98  TString GetMethodOptions(TString methodname, TString methodtitle);
99  Bool_t HasMethodObject(TString methodname, TString methodtitle, Int_t &index);
100  Bool_t IsCutsMethod(TMVA::MethodBase *method);
103  TMVA::ROCCurve *GetROC(TString methodname, TString methodtitle, UInt_t iClass = 0,
105 
106  Double_t GetROCIntegral(TString methodname, TString methodtitle, UInt_t iClass = 0);
107 
108  ClassificationResult &GetResults(TString methodname, TString methodtitle);
110 };
111 } // namespace Experimental
112 } // namespace TMVA
113 
114 #endif // ROOT_TMVA_Classification
std::map< UInt_t, std::vector< std::tuple< Float_t, Float_t, Bool_t > > > fMvaTest
Types::EAnalysisType fAnalysisType
vector of objects with booked methods
T GetValue(const TString &key)
Definition: OptionMap.h:145
class to storage options for the differents methods
Definition: OptionMap.h:35
Double_t GetROCIntegral(UInt_t iClass=0, TMVA::Types::ETreeType type=TMVA::Types::kTesting)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
EAnalysisType
Definition: Types.h:125
Virtual base Class for all MVA method.
Definition: MethodBase.h:109
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
std::map< UInt_t, std::vector< std::tuple< Float_t, Float_t, Bool_t > > > fMvaTrain
ClassificationResult & operator=(const ClassificationResult &r)
#define ClassDef(name, id)
Definition: Rtypes.h:320
Abstract base class for all high level ml algorithms, you can book ml methods like BDT...
Definition: Envelope.h:43
std::vector< IMethod * > fIMethods
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:727
ROOT::R::TRInterface & r
Definition: Object.C:4
unsigned int UInt_t
Definition: RtypesCore.h:42
double Double_t
Definition: RtypesCore.h:55
int type
Definition: TGX11.cxx:120
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t IsMethod(TString methodname, TString methodtitle)
Abstract ClassifierFactory template that handles arbitrary types.
Definition: file.py:1
TGraph * GetROCGraph(UInt_t iClass=0, TMVA::Types::ETreeType type=TMVA::Types::kTesting)
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
std::vector< ClassificationResult > fResults
ROCCurve * GetROC(UInt_t iClass=0, TMVA::Types::ETreeType type=TMVA::Types::kTesting)