71 #ifndef IClassifierReader__def 72 #define IClassifierReader__def 74 class IClassifierReader {
79 IClassifierReader() : fStatusIsClean(
true ) {}
80 virtual ~IClassifierReader() {}
83 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
86 bool IsStatusClean()
const {
return fStatusIsClean; }
95 class ReadRuleFit :
public IClassifierReader {
100 ReadRuleFit( std::vector<std::string>& theInputVars )
101 : IClassifierReader(),
102 fClassName(
"ReadRuleFit" ),
104 fIsNormalised(
false )
107 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
110 if (theInputVars.size() <= 0) {
111 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
112 fStatusIsClean =
false;
115 if (theInputVars.size() != fNvars) {
116 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 117 << theInputVars.size() <<
" != " << fNvars << std::endl;
118 fStatusIsClean =
false;
122 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
123 if (theInputVars[ivar] != inputVars[ivar]) {
124 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
125 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
126 fStatusIsClean =
false;
152 virtual ~ReadRuleFit() {
159 double GetMvaValue(
const std::vector<double>& inputValues )
const;
167 const char* fClassName;
170 size_t GetNvar()
const {
return fNvars; }
174 const bool fIsNormalised;
175 bool IsNormalised()
const {
return fIsNormalised; }
178 double NormVariable(
double x,
double xmin,
double xmax )
const {
180 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
188 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
194 void ReadRuleFit::Clear(){}
195 double ReadRuleFit::GetMvaValue__(
const std::vector<double>& inputValues )
const {
196 double rval=1.818436747;
201 if ((inputValues[2]<0.2859873176)&&(inputValues[3]<-0.6145658493)) rval+=-0.5379093668;
202 if ((0.6637439728<inputValues[0])&&(inputValues[3]<1.852592468)) rval+=-0.3660666206;
203 if ((-0.8042526245<inputValues[0])) rval+=-0.3482884165;
204 if ((inputValues[2]<0.2859873176)&&(-0.6145658493<inputValues[3])) rval+=0.3266429992;
205 if ((inputValues[0]<1.397742271)&&(-0.7250279784<inputValues[1])&&(inputValues[3]<-0.6721984744)) rval+=-0.358918334;
206 if ((inputValues[0]<2.865738869)&&(inputValues[3]<1.206904054)) rval+=-0.3232525673;
207 if ((inputValues[3]<1.110067248)) rval+=-0.301074141;
208 if ((inputValues[0]<1.361399651)&&(inputValues[1]<0.2200206369)&&(inputValues[3]<-0.411757946)) rval+=-0.2633455358;
209 if ((0.2200206369<inputValues[1])) rval+=-0.1989356993;
210 if ((-0.07025432587<inputValues[0])&&(0.3575037718<inputValues[1])) rval+=-0.2333956588;
211 if ((-1.538250923<inputValues[0])&&(inputValues[0]<1.266595125)&&(inputValues[3]<0.3321121633)) rval+=-0.1880227743;
212 if ((inputValues[2]<-1.044834495)) rval+=-0.2458634586;
213 if ((inputValues[1]<0.07876376063)&&(inputValues[3]<0.1014136598)) rval+=-0.2060729782;
214 if ((-0.6012272835<inputValues[2])&&(0.9022580981<inputValues[3])) rval+=0.1708052558;
215 if ((inputValues[1]<0.2200206369)) rval+=-0.1516181657;
216 if ((-0.4926698804<inputValues[2])&&(inputValues[3]<0.3393571973)) rval+=-0.1697182182;
217 if ((inputValues[0]<1.361399651)&&(inputValues[1]<0.2200206369)) rval+=0.1415105291;
218 if ((-0.737119019<inputValues[1])&&(inputValues[1]<0.02489273809)&&(inputValues[3]<0.605740428)) rval+=-0.1829364476;
219 if ((inputValues[0]<2.487332582)&&(-0.4926698804<inputValues[2])&&(inputValues[3]<1.069083929)) rval+=-0.1373253511;
220 if ((0.2200206369<inputValues[1])&&(inputValues[3]<0.7960036993)) rval+=-0.1428094066;
221 if ((0.2200206369<inputValues[1])&&(-1.044834495<inputValues[2])&&(inputValues[3]<0.196363762)) rval+=-0.1744087832;
222 if ((0.07876376063<inputValues[1])&&(0.2859873176<inputValues[2])) rval+=-0.1577677638;
223 if ((-1.856152892<inputValues[0])&&(inputValues[0]<0.6637439728)&&(0.2456704378<inputValues[3])) rval+=0.1659540232;
224 if ((inputValues[0]<-0.3903895915)&&(-0.1605666727<inputValues[1])&&(inputValues[2]<1.173201919)) rval+=0.1323516278;
225 if ((-0.876881063<inputValues[0])&&(inputValues[1]<-0.1346641928)&&(0.605740428<inputValues[3])) rval+=0.1374161829;
226 if ((inputValues[0]<2.865738869)&&(1.206904054<inputValues[3])) rval+=0.1293777376;
227 if ((inputValues[0]<2.865738869)) rval+=-0.1926274403;
228 if ((inputValues[0]<0.6637439728)&&(-0.237038821<inputValues[1])&&(0.2456704378<inputValues[3])) rval+=0.1433609086;
229 if ((-0.07025432587<inputValues[0])&&(inputValues[1]<0.3575037718)) rval+=-0.08498720074;
230 if ((-1.044834495<inputValues[2])) rval+=-0.1045792093;
231 if ((0.02489273809<inputValues[1])&&(inputValues[2]<0.7852135301)&&(inputValues[3]<0.605740428)) rval+=-0.08330828564;
232 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])&&(inputValues[3]<1.066591382)) rval+=-0.09245421628;
233 if ((inputValues[0]<-0.3790929615)&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])) rval+=0.09276894678;
234 if ((0.2200206369<inputValues[1])&&(inputValues[1]<0.774100244)&&(-1.044834495<inputValues[2])&&(inputValues[3]<0.196363762)) rval+=-0.1209340777;
235 if ((-0.3903895915<inputValues[0])&&(-0.1605666727<inputValues[1])&&(inputValues[2]<1.173201919)) rval+=-0.06948582893;
236 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])&&(inputValues[2]<1.375104785)&&(inputValues[3]<1.066591382)) rval+=-0.07751604737;
237 if ((0.6637439728<inputValues[0])&&(1.386405587<inputValues[3])) rval+=-0.08062844867;
238 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])) rval+=-0.0618347695;
239 if ((inputValues[0]<1.397742271)&&(-0.7250279784<inputValues[1])) rval+=0.05880617942;
240 if ((-0.4885016978<inputValues[0])&&(-1.044834495<inputValues[2])&&(1.261463404<inputValues[3])) rval+=-0.06993446415;
241 if ((-0.5954368114<inputValues[1])&&(inputValues[2]<-0.6012272835)) rval+=-0.06613817409;
242 if ((-0.876881063<inputValues[0])&&(-0.1346641928<inputValues[1])&&(0.605740428<inputValues[3])) rval+=-0.0585316703;
243 if ((-0.5954368114<inputValues[1])&&(inputValues[1]<-0.06197149307)&&(inputValues[2]<0.2926391363)) rval+=-0.05672564152;
244 if ((0.2200206369<inputValues[1])&&(0.7960036993<inputValues[3])) rval+=-0.05359126258;
245 if ((inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])) rval+=0.03045857436;
246 if ((0.2200206369<inputValues[1])&&(-1.044834495<inputValues[2])&&(0.196363762<inputValues[3])) rval+=0.03558506898;
247 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])&&(1.066591382<inputValues[3])) rval+=0.03176435311;
248 if ((-1.810295105<inputValues[2])&&(inputValues[2]<-1.044834495)) rval+=-0.02569197519;
249 if ((inputValues[0]<0.6637439728)&&(inputValues[1]<-0.237038821)&&(0.2456704378<inputValues[3])) rval+=0.0229313273;
250 if ((-1.411566615<inputValues[3])) rval+=-0.0154040687;
251 if ((inputValues[1]<-0.1605666727)&&(inputValues[2]<1.173201919)) rval+=-0.008607035181;
252 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])&&(inputValues[2]<0.340533644)&&(1.066591382<inputValues[3])) rval+=0.02734064113;
257 rval+=-0.2303439238*std::min(
double(3.434663296), std::max(
double(inputValues[0]),
double(-3.440958977)));
258 rval+=-0.03967082836*std::min(
double(2.07433629), std::max(
double(inputValues[1]),
double(-2.206938982)));
259 rval+=0.00702630339*std::min(
double(2.088175535), std::max(
double(inputValues[2]),
double(-2.172396898)));
260 rval+=0.3518686371*std::min(
double(2.604138613), std::max(
double(inputValues[3]),
double(-2.361749649)));
263 inline double ReadRuleFit::GetMvaValue(
const std::vector<double>& inputValues )
const 269 if (!IsStatusClean()) {
270 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 271 <<
" because status is dirty" << std::endl;
275 if (IsNormalised()) {
277 std::vector<double> iV;
278 iV.reserve(inputValues.size());
280 for (std::vector<double>::const_iterator varIt = inputValues.begin();
281 varIt != inputValues.end(); varIt++, ivar++) {
282 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
284 retval = GetMvaValue__( iV );
287 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)