Logo ROOT   6.08/07
Reference Guide
Envelope.h
Go to the documentation of this file.
1 // @(#)root/tmva:$Id$
2 // Author: Omar Zapata 2016
3 
4 /*************************************************************************
5  * Copyright (C) 2016, Omar Andres Zapata Mesa *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 #ifndef ROOT_TMVA_Envelope
12 #define ROOT_TMVA_Envelope
13 
14 #include <sstream>
15 #include<iostream>
16 #include <memory>
17 
18 #ifndef ROOT_TROOT
19 #include<TROOT.h>
20 #endif
21 
22 #ifndef ROOT_TStopwatch
23 #include<TStopwatch.h>
24 #endif
25 
26 #ifndef ROOT_TMVA_OptionMap
27 #include<TMVA/OptionMap.h>
28 #endif
29 
30 #ifndef ROOT_TMVA_Config
31 #include "TMVA/Config.h"
32 #endif
33 
34 #ifndef ROOT_TMVA_Tools
35 #include "TMVA/Tools.h"
36 #endif
37 
38 #ifndef ROOT_TMVA_DataLoader
39 #include "TMVA/DataLoader.h"
40 #endif
41 
42 #ifndef ROOT_TMVA_ROCCurve
43 #include "TMVA/DataLoader.h"
44 #endif
45 
46 
47 namespace TMVA {
48 
49  /**
50  * \class Envelope
51  * Base class for all machine learning algorithms
52  * \ingroup TMVA
53  */
54 
55  class Envelope:public Configurable
56  {
57  protected:
58  OptionMap fMethod; //Booked method information
59  std::shared_ptr<DataLoader> fDataLoader; //data
60  std::shared_ptr<TFile> fFile; //!file to save the results
61  Bool_t fModelPersistence; //flag to save the trained model
62  Bool_t fVerbose; //flag for extra information
63 
64  /**
65  Constructor for the initialization of Envelopes,
66  differents Envelopes may needs differents constructors then
67  this is a generic one protected.
68  \param name the name algorithm.
69  \param dataloader TMVA::DataLoader object with the data.
70  \param file optional file to save the results.
71  \param options extra options for the algorithm.
72  */
73 
74  Envelope(const TString &name,DataLoader *dataloader=nullptr,TFile *file=nullptr,const TString options="");
75 
76  public:
77  /**
78  Default destructor
79  */
80  ~Envelope();
81 
82  /**
83  Method to book the machine learning method to perform the algorithm.
84  \param methodname String with the name of the mva method
85  \param methodtitle String with the method title.
86  \param options String with the options for the method.
87  */
88  virtual void BookMethod( TString methodname, TString methodtitle, TString options = "");
89  /**
90  Method to book the machine learning method to perform the algorithm.
91  \param method enum TMVA::Types::EMVA with the type of the mva method
92  \param methodtitle String with the method title.
93  \param options String with the options for the method.
94  */
95  virtual void BookMethod( Types::EMVA method, TString methodtitle, TString options = "");
96 
97  /**
98  Method to see if a file is available to save results
99  \return Boolean with the status.
100  */
102  /**
103  Method to get the pointer to TFile object.
104  \return pointer to TFile object.
105  */
106  TFile* GetFile();
107  /**
108  Method to set the pointer to TFile object,
109  with a writable file.
110  \param file pointer to TFile object.
111  */
112  void SetFile(TFile *file);
113 
114  /**
115  Method to get the pointer to TMVA::DataLoader object.
116  \return pointer to TMVA::DataLoader object.
117  */
119 
120  /**
121  Method to set the pointer to TMVA::DataLoader object.
122  \param file pointer to TFile object.
123  */
124  void SetDataLoader(DataLoader *dalaloader);
125 
126  /**
127  Method to see if the algorithm model is saved in xml or serialized files.
128  \return Boolean with the status.
129  */
131 
132  /**
133  Method enable model persistence, then algorithms model is saved in xml or serialized files.
134  \param status Boolean with the status.
135  */
136  void SetModelPersistence(Bool_t status=kTRUE);
137 
138  /**
139  Method to see if the algorithm should print extra information.
140  \return Boolean with the status.
141  */
142  Bool_t IsVerbose();
143 
144  /**
145  Method enable print extra information in the algorithms.
146  \param status Boolean with the status.
147  */
148  void SetVerbose(Bool_t status);
149 
150  /**
151  Virtual method to be implmented with your algorithm.
152  */
153  virtual void Evaluate() = 0;
154 
155  protected:
156  /**
157  Method get the Booked method in a option map object.
158  \return TMVA::OptionMap with the information of the Booked method
159  */
160  OptionMap &GetMethod();
161 
162  /**
163  Utility method to get TMVA::DataInputHandler reference from the DataLoader.
164  \return TMVA::DataInputHandler reference.
165  */
166  DataInputHandler& GetDataLoaderDataInput() { return *fDataLoader->fDataInputHandler; }
167 
168  /**
169  Utility method to get TMVA::DataSetInfo reference from the DataLoader.
170  \return TMVA::DataSetInfo reference.
171  */
172  DataSetInfo& GetDataLoaderDataSetInfo(){return fDataLoader->DefaultDataSetInfo();}
173 
174  /**
175  Utility method to get TMVA::DataSetManager pointer from the DataLoader.
176  \return TMVA::DataSetManager pointer.
177  */
178  DataSetManager* GetDataLoaderDataSetManager(){return fDataLoader->fDataSetManager;}
179  ClassDef(Envelope,0);
180 
181  };
182 }
183 
184 #endif
virtual void BookMethod(TString methodname, TString methodtitle, TString options="")
Method to book the machine learning method to perform the algorithm.
Definition: Envelope.cxx:72
DataSetInfo & GetDataLoaderDataSetInfo()
Utility method to get TMVA::DataSetInfo reference from the DataLoader.
Definition: Envelope.h:172
Bool_t fVerbose
Definition: Envelope.h:62
~Envelope()
Default destructor.
Definition: Envelope.cxx:30
void SetFile(TFile *file)
Method to set the pointer to TFile object, with a writable file.
Definition: Envelope.cxx:41
Bool_t IsModelPersistence()
Method to see if the algorithm model is saved in xml or serialized files.
Definition: Envelope.cxx:61
class to storage options for the differents methods
Definition: OptionMap.h:43
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
Basic string class.
Definition: TString.h:137
bool Bool_t
Definition: RtypesCore.h:59
std::shared_ptr< TFile > fFile
Definition: Envelope.h:60
Bool_t IsSilentFile()
Method to see if a file is available to save results.
Definition: Envelope.cxx:34
DataLoader * GetDataLoader()
Method to get the pointer to TMVA::DataLoader object.
Definition: Envelope.cxx:53
#define ClassDef(name, id)
Definition: Rtypes.h:254
OptionMap fMethod
Definition: Envelope.h:58
Envelope(const TString &name, DataLoader *dataloader=nullptr, TFile *file=nullptr, const TString options="")
Constructor for the initialization of Envelopes, differents Envelopes may needs differents constructo...
Definition: Envelope.cxx:24
Base class for all machine learning algorithms.
Definition: Envelope.h:55
void SetVerbose(Bool_t status)
Method enable print extra information in the algorithms.
Definition: Envelope.cxx:47
void SetDataLoader(DataLoader *dalaloader)
Method to set the pointer to TMVA::DataLoader object.
Definition: Envelope.cxx:56
Bool_t IsVerbose()
Method to see if the algorithm should print extra information.
Definition: Envelope.cxx:44
void SetModelPersistence(Bool_t status=kTRUE)
Method enable model persistence, then algorithms model is saved in xml or serialized files...
Definition: Envelope.cxx:64
OptionMap & GetMethod()
Method get the Booked method in a option map object.
Definition: Envelope.cxx:50
Bool_t fModelPersistence
file to save the results
Definition: Envelope.h:61
std::shared_ptr< DataLoader > fDataLoader
Definition: Envelope.h:59
Abstract ClassifierFactory template that handles arbitrary types.
TFile * GetFile()
Method to get the pointer to TFile object.
Definition: Envelope.cxx:37
Definition: file.py:1
DataSetManager * GetDataLoaderDataSetManager()
Utility method to get TMVA::DataSetManager pointer from the DataLoader.
Definition: Envelope.h:178
DataInputHandler & GetDataLoaderDataInput()
Utility method to get TMVA::DataInputHandler reference from the DataLoader.
Definition: Envelope.h:166
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void Evaluate()=0
Virtual method to be implmented with your algorithm.
char name[80]
Definition: TGX11.cxx:109