Logo ROOT   6.10/09
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 #include <TROOT.h>
19 
20 #include <TStopwatch.h>
21 
22 #include <TMVA/OptionMap.h>
23 
24 #include "TMVA/Config.h"
25 
26 #include "TMVA/Tools.h"
27 
28 #include "TMVA/DataLoader.h"
29 
30 #include "TMVA/DataLoader.h"
31 
32 
33 namespace TMVA {
34 
35  class Envelope:public Configurable
36  {
37  protected:
38  OptionMap fMethod; //Booked method information
39  std::shared_ptr<DataLoader> fDataLoader; //data
40  std::shared_ptr<TFile> fFile; //!file to save the results
41  Bool_t fModelPersistence; //flag to save the trained model
42  Bool_t fVerbose; //flag for extra information
43 
44  /**
45  Constructor for the initialization of Envelopes,
46  differents Envelopes may needs differents constructors then
47  this is a generic one protected.
48  \param name the name algorithm.
49  \param dataloader TMVA::DataLoader object with the data.
50  \param file optional file to save the results.
51  \param options extra options for the algorithm.
52  */
53 
54  Envelope(const TString &name,DataLoader *dataloader=nullptr,TFile *file=nullptr,const TString options="");
55 
56  public:
57  /**
58  Default destructor
59  */
60  ~Envelope();
61 
62  /**
63  Method to book the machine learning method to perform the algorithm.
64  \param methodname String with the name of the mva method
65  \param methodtitle String with the method title.
66  \param options String with the options for the method.
67  */
68  virtual void BookMethod( TString methodname, TString methodtitle, TString options = "");
69  /**
70  Method to book the machine learning method to perform the algorithm.
71  \param method enum TMVA::Types::EMVA with the type of the mva method
72  \param methodtitle String with the method title.
73  \param options String with the options for the method.
74  */
75  virtual void BookMethod( Types::EMVA method, TString methodtitle, TString options = "");
76 
77  /**
78  Method to see if a file is available to save results
79  \return Boolean with the status.
80  */
82  /**
83  Method to get the pointer to TFile object.
84  \return pointer to TFile object.
85  */
86  TFile* GetFile();
87  /**
88  Method to set the pointer to TFile object,
89  with a writable file.
90  \param file pointer to TFile object.
91  */
92  void SetFile(TFile *file);
93 
94  /**
95  Method to get the pointer to TMVA::DataLoader object.
96  \return pointer to TMVA::DataLoader object.
97  */
99 
100  /**
101  Method to set the pointer to TMVA::DataLoader object.
102  \param file pointer to TFile object.
103  */
104  void SetDataLoader(DataLoader *dalaloader);
105 
106  /**
107  Method to see if the algorithm model is saved in xml or serialized files.
108  \return Boolean with the status.
109  */
111 
112  /**
113  Method enable model persistence, then algorithms model is saved in xml or serialized files.
114  \param status Boolean with the status.
115  */
116  void SetModelPersistence(Bool_t status=kTRUE);
117 
118  /**
119  Method to see if the algorithm should print extra information.
120  \return Boolean with the status.
121  */
122  Bool_t IsVerbose();
123 
124  /**
125  Method enable print extra information in the algorithms.
126  \param status Boolean with the status.
127  */
128  void SetVerbose(Bool_t status);
129 
130  /**
131  Virtual method to be implemented with your algorithm.
132  */
133  virtual void Evaluate() = 0;
134 
135  protected:
136  /**
137  Method get the Booked method in a option map object.
138  \return TMVA::OptionMap with the information of the Booked method
139  */
140  OptionMap &GetMethod();
141 
142  /**
143  Utility method to get TMVA::DataInputHandler reference from the DataLoader.
144  \return TMVA::DataInputHandler reference.
145  */
146  DataInputHandler& GetDataLoaderDataInput() { return *fDataLoader->fDataInputHandler; }
147 
148  /**
149  Utility method to get TMVA::DataSetInfo reference from the DataLoader.
150  \return TMVA::DataSetInfo reference.
151  */
152  DataSetInfo& GetDataLoaderDataSetInfo(){return fDataLoader->DefaultDataSetInfo();}
153 
154  /**
155  Utility method to get TMVA::DataSetManager pointer from the DataLoader.
156  \return TMVA::DataSetManager pointer.
157  */
158  DataSetManager* GetDataLoaderDataSetManager(){return fDataLoader->fDataSetManager;}
159  ClassDef(Envelope,0);
160 
161  };
162 }
163 
164 #endif
virtual void BookMethod(TString methodname, TString methodtitle, TString options="")
Method to book the machine learning method to perform the algorithm.
Definition: Envelope.cxx:94
DataSetInfo & GetDataLoaderDataSetInfo()
Utility method to get TMVA::DataSetInfo reference from the DataLoader.
Definition: Envelope.h:152
Bool_t fVerbose
Definition: Envelope.h:42
~Envelope()
Default destructor.
Definition: Envelope.cxx:40
void SetFile(TFile *file)
Method to set the pointer to TFile object, with a writable file.
Definition: Envelope.cxx:54
Bool_t IsModelPersistence()
Method to see if the algorithm model is saved in xml or serialized files.
Definition: Envelope.cxx:80
class to storage options for the differents methods
Definition: OptionMap.h:35
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
Basic string class.
Definition: TString.h:129
bool Bool_t
Definition: RtypesCore.h:59
std::shared_ptr< TFile > fFile
Definition: Envelope.h:40
Bool_t IsSilentFile()
Method to see if a file is available to save results.
Definition: Envelope.cxx:45
DataLoader * GetDataLoader()
Method to get the pointer to TMVA::DataLoader object.
Definition: Envelope.cxx:70
#define ClassDef(name, id)
Definition: Rtypes.h:297
OptionMap fMethod
Definition: Envelope.h:38
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:32
Base class for all machine learning algorithms.
Definition: Envelope.h:35
Class that contains all the data information.
Definition: DataSetInfo.h:60
Class that contains all the data information.
void SetVerbose(Bool_t status)
Method enable print extra information in the algorithms.
Definition: Envelope.cxx:62
void SetDataLoader(DataLoader *dalaloader)
Method to set the pointer to TMVA::DataLoader object.
Definition: Envelope.cxx:74
Bool_t IsVerbose()
Method to see if the algorithm should print extra information.
Definition: Envelope.cxx:58
void SetModelPersistence(Bool_t status=kTRUE)
Method enable model persistence, then algorithms model is saved in xml or serialized files...
Definition: Envelope.cxx:84
OptionMap & GetMethod()
Method get the Booked method in a option map object.
Definition: Envelope.cxx:66
Class that contains all the data information.
Bool_t fModelPersistence
file to save the results
Definition: Envelope.h:41
std::shared_ptr< DataLoader > fDataLoader
Definition: Envelope.h:39
Abstract ClassifierFactory template that handles arbitrary types.
TFile * GetFile()
Method to get the pointer to TFile object.
Definition: Envelope.cxx:49
Definition: file.py:1
DataSetManager * GetDataLoaderDataSetManager()
Utility method to get TMVA::DataSetManager pointer from the DataLoader.
Definition: Envelope.h:158
DataInputHandler & GetDataLoaderDataInput()
Utility method to get TMVA::DataInputHandler reference from the DataLoader.
Definition: Envelope.h:146
virtual void Evaluate()=0
Virtual method to be implemented with your algorithm.
const Bool_t kTRUE
Definition: RtypesCore.h:91