Logo ROOT   6.16/01
Reference Guide
TMVACrossValidation_BDTG.class.C
Go to the documentation of this file.
1// Class: ReadBDTG
2// Automatically generated by MethodBase::MakeClass
3//
4
5/* configuration options =====================================================
6
7#GEN -*-*-*-*-*-*-*-*-*-*-*- general info -*-*-*-*-*-*-*-*-*-*-*-
8
9Method : CrossValidation::BDTG
10TMVA Release : 4.2.1 [262657]
11ROOT Release : 6.16/01 [397313]
12Creator : sftnight
13Date : Sun Dec 19 22:14:15 2021
14Host : Linux root-ubuntu-2004-3 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
15Dir : /home/sftnight/build/workspace/root-makedoc-v616/rootspi/rdoc/src/v6-16-00-patches/documentation/doxygen
16Training events: 1998
17Analysis type : [Classification]
18
19
20#OPT -*-*-*-*-*-*-*-*-*-*-*-*- options -*-*-*-*-*-*-*-*-*-*-*-*-
21
22# Set by User:
23EncapsulatedMethodName: "BDTG" []
24EncapsulatedMethodTypeName: "BDT" []
25NumFolds: "2" [Number of folds to generate]
26OutputEnsembling: "None" [Combines output from contained methods. If None, no combination is performed. (default None)]
27SplitExpr: "" [The expression used to assign events to folds]
28# Default:
29V: "False" [Verbose output (short form of "VerbosityLevel" below - overrides the latter one)]
30VerbosityLevel: "Default" [Verbosity level]
31VarTransform: "None" [List of variable transformations performed before training, e.g., "D_Background,P_Signal,G,N_AllClasses" for: "Decorrelation, PCA-transformation, Gaussianisation, Normalisation, each for the given class of events ('AllClasses' denotes all events of all classes, if no class indication is given, 'All' is assumed)"]
32H: "False" [Print method-specific help message]
33CreateMVAPdfs: "False" [Create PDFs for classifier outputs (signal and background)]
34IgnoreNegWeightsInTraining: "False" [Events with negative weights are ignored in the training (but are included for testing and performance evaluation)]
35##
36
37
38#VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-
39
40NVar 2
41x x x x 'F' [-4.10750675201,4.09692668915]
42y y y y 'F' [-4.85200452805,4.07606744766]
43NSpec 1
44eventID eventID eventID I 'F' [1,1000]
45
46
47============================================================================ */
48
49#include <array>
50#include <vector>
51#include <cmath>
52#include <string>
53#include <iostream>
54
55#ifndef IClassifierReader__def
56#define IClassifierReader__def
57
58class IClassifierReader {
59
60 public:
61
62 // constructor
63 IClassifierReader() : fStatusIsClean( true ) {}
64 virtual ~IClassifierReader() {}
65
66 // return classifier response
67 virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;
68
69 // returns classifier status
70 bool IsStatusClean() const { return fStatusIsClean; }
71
72 protected:
73
74 bool fStatusIsClean;
75};
76
77#endif
78
79class ReadBDTG : public IClassifierReader {
80
81 public:
82
83 // constructor
84 ReadBDTG( std::vector<std::string>& theInputVars )
85 : IClassifierReader(),
86 fClassName( "ReadBDTG" ),
87 fNvars( 2 )
88 {
89 // the training input variables
90 const char* inputVars[] = { "x", "y" };
91
92 // sanity checks
93 if (theInputVars.size() <= 0) {
94 std::cout << "Problem in class \"" << fClassName << "\": empty input vector" << std::endl;
95 fStatusIsClean = false;
96 }
97
98 if (theInputVars.size() != fNvars) {
99 std::cout << "Problem in class \"" << fClassName << "\": mismatch in number of input values: "
100 << theInputVars.size() << " != " << fNvars << std::endl;
101 fStatusIsClean = false;
102 }
103
104 // validate input variables
105 for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
106 if (theInputVars[ivar] != inputVars[ivar]) {
107 std::cout << "Problem in class \"" << fClassName << "\": mismatch in input variable names" << std::endl
108 << " for variable [" << ivar << "]: " << theInputVars[ivar].c_str() << " != " << inputVars[ivar] << std::endl;
109 fStatusIsClean = false;
110 }
111 }
112
113 // initialize min and max vectors (for normalisation)
114 fVmin[0] = 0;
115 fVmax[0] = 0;
116 fVmin[1] = 0;
117 fVmax[1] = 0;
118
119 // initialize input variable types
120 fType[0] = 'F';
121 fType[1] = 'F';
122
123 // initialize constants
124 Initialize();
125
126 }
127
128 // destructor
129 virtual ~ReadBDTG() {
130 Clear(); // method-specific
131 }
132
133 // the classifier response
134 // "inputValues" is a vector of input values in the same order as the
135 // variables given to the constructor
136 double GetMvaValue( const std::vector<double>& inputValues ) const override;
137
138 private:
139
140 // method-specific destructor
141 void Clear();
142
143 // common member variables
144 const char* fClassName;
145
146 const size_t fNvars;
147 size_t GetNvar() const { return fNvars; }
148 char GetType( int ivar ) const { return fType[ivar]; }
149
150 // normalisation of input variables
151 double fVmin[2];
152 double fVmax[2];
153 double NormVariable( double x, double xmin, double xmax ) const {
154 // normalise to output range: [-1, 1]
155 return 2*(x - xmin)/(xmax - xmin) - 1.0;
156 }
157
158 // type of input variable: 'F' or 'I'
159 char fType[2];
160
161 // initialize internal variables
162 void Initialize();
163 double GetMvaValue__( const std::vector<double>& inputValues ) const;
164
165 // private members (method specific)
166 inline double ReadBDTG::GetMvaValue( const std::vector<double>& inputValues ) const
167 {
168 // classifier response value
169 double retval = 0;
170
171 // classifier response, sanity check first
172 if (!IsStatusClean()) {
173 std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response"
174 << " because status is dirty" << std::endl;
175 retval = 0;
176 }
177 else {
178 retval = GetMvaValue__( inputValues );
179 }
180
181 return retval;
182 }
PyObject * fType
float xmin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
Double_t x[n]
Definition: legend1.C:17
Type GetType(const std::string &Name)
Definition: Systematics.cxx:34
void Initialize(Bool_t useTMVAStyle=kTRUE)
Definition: tmvaglob.cxx:176