PandaRoot
PndMultiClassBdtTrain.h
Go to the documentation of this file.
1 /* ***************************************
2  * MultiClass BDTG Training functions *
3  * Author: M.Babai@rug.nl *
4  * Version: *
5  * LICENSE: *
6  * ***************************************
7  */
8 /*
9  * Note: This is just an interface to the original TMVA
10  * implementation. To find out the available options, please read TMVA
11  * manuals. In case of errors or wrong outputs produced by TMVA
12  * classifiers, try to read their mailing list and send your questions
13  * to the same list.
14  ******* VERY IMORTANT ****
15  * You NEED (TMVA version) > 4.1.X before this works.
16  */
17 //#pragma once
18 #ifndef PND_MULTICLASS_BDT_TRAIN_H
19 #define PND_MULTICLASS_BDT_TRAIN_H
20 
21 // Local includes
22 #include "PndMvaTrainer.h"
23 
24 // TMVA && ROOT
25 #include "TMVA/Factory.h"
26 #include "TMVA/Config.h"
27 
28 // Interface definition for Multiclass MLP trainers.
30  //----------------------------------------
31  //================== public ==============
32  public:
40  explicit PndMultiClassBdtTrain(std::string const &InPut, std::vector<std::string> const &ClassNames, std::vector<std::string> const &VarNames, bool trim = true);
44  virtual ~PndMultiClassBdtTrain();
45 
49  void Train();
50 
55  void storeWeights();
56 
60  void Initialize();
61 
62  //______________________________________________
63  //====== Getters and setters.
64  // Set the name of the current job
65  inline void SetJobName(std::string const &name);
66 
67  // Set data Transformation scheme
68  inline void SetTransformation(std::string const &tran);
69 
70  // Set the options for the MLP alg. See TMVA manuals.
71  inline void SetBdtOptions(std::string const &opts);
72 
73  // Set the file name to store evaluation outputs.
74  inline void SetEvalFileName(std::string const &fname);
75 
76  // Set the directory where weights are stored.
77  inline void SetWeightsOutDir(std::string const &dirName);
78 
79  // Evaluate the classifier?
80  inline void SetEvaluation(bool evaluate);
81 
82  // Get the current job name.
83  inline std::string const &GetJobName() const;
84 
85  // Get the current transformation info.
86  inline std::string const &GetTransformation() const;
87 
88  // Get the classifier options.
89  inline std::string const &GetBdtOptions() const;
90 
91  // Get the name of the weight file.
92  inline std::string const &GetEvalFileName() const;
93 
94  // Get the directory where the weights are stored.
95  inline std::string const &GetWeightsOutDir() const;
96  //----------------------------------------
97 
98  //================== protected ============
99  // protected:
100  //----------------------------------------
101 
102  //================== private =============
103  private:
104  // To avoid mistakes.
106  PndMultiClassBdtTrain &operator=(PndMultiClassBdtTrain const &oth);
107 
108  // Initialize mlp object and set the options.
109  void InitBdt();
110  // Add the variables to the TMVA factory object.
111  void AddVariables();
112 
113  //==============================
114  TMVA::Factory *m_factory; // TMVA factory
115  TFile *EvalFile; // To store evaluation file
116  std::string m_JName; // Job name
117  std::string m_transform; // Transformation opt.
118  std::string m_BdtOptions; // Bdt options.
119  std::string m_evalFileName; // evaluation file name.
120  std::string m_weightDirName; // Directory name to store weights.
121  bool m_Evaluate;
122 }; // End of interface definition.
123 //=============== inline functions implementation. ========
124 //__________________________________________
125 inline void PndMultiClassBdtTrain::SetJobName(std::string const &name)
126 {
127  this->m_JName = name;
128 };
129 
130 inline void PndMultiClassBdtTrain::SetTransformation(std::string const &tr)
131 {
132  this->m_transform = tr;
133 };
134 
135 inline void PndMultiClassBdtTrain::SetBdtOptions(std::string const &opt)
136 {
137  this->m_BdtOptions = opt;
138 };
139 
140 inline std::string const &PndMultiClassBdtTrain::GetJobName() const
141 {
142  return m_JName;
143 };
144 
145 inline std::string const &PndMultiClassBdtTrain::GetTransformation() const
146 {
147  return m_transform;
148 };
149 
150 inline std::string const &PndMultiClassBdtTrain::GetBdtOptions() const
151 {
152  return m_BdtOptions;
153 };
154 
155 inline void PndMultiClassBdtTrain::SetEvalFileName(std::string const &fname)
156 {
157  this->m_evalFileName = fname;
158 };
159 
160 inline std::string const &PndMultiClassBdtTrain::GetEvalFileName() const
161 {
162  return m_evalFileName;
163 };
164 
165 inline void PndMultiClassBdtTrain::SetWeightsOutDir(std::string const &dirName)
166 {
167  this->m_weightDirName = dirName;
168 };
169 
170 inline std::string const &PndMultiClassBdtTrain::GetWeightsOutDir() const
171 {
172  return m_weightDirName;
173 };
174 
175 inline void PndMultiClassBdtTrain::SetEvaluation(bool evaluate)
176 {
177  this->m_Evaluate = evaluate;
178 };
179 #endif
std::string const & GetTransformation() const
std::string const & GetBdtOptions() const
void SetEvaluation(bool evaluate)
std::string const & GetWeightsOutDir() const
PndMultiClassBdtTrain(std::string const &InPut, std::vector< std::string > const &ClassNames, std::vector< std::string > const &VarNames, bool trim=true)
void SetTransformation(std::string const &tran)
void SetEvalFileName(std::string const &fname)
void SetJobName(std::string const &name)
void SetBdtOptions(std::string const &opts)
void SetWeightsOutDir(std::string const &dirName)
std::string const & GetJobName() const
virtual ~PndMultiClassBdtTrain()
std::string const & GetEvalFileName() const