72 #ifndef IClassifierReader__def 73 #define IClassifierReader__def 75 class IClassifierReader {
80 IClassifierReader() : fStatusIsClean(
true ) {}
81 virtual ~IClassifierReader() {}
84 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
87 bool IsStatusClean()
const {
return fStatusIsClean; }
96 class ReadRuleFit :
public IClassifierReader {
101 ReadRuleFit( std::vector<std::string>& theInputVars )
102 : IClassifierReader(),
103 fClassName(
"ReadRuleFit" ),
105 fIsNormalised(
false )
108 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
111 if (theInputVars.size() <= 0) {
112 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
113 fStatusIsClean =
false;
116 if (theInputVars.size() != fNvars) {
117 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 118 << theInputVars.size() <<
" != " << fNvars << std::endl;
119 fStatusIsClean =
false;
123 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
124 if (theInputVars[ivar] != inputVars[ivar]) {
125 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
126 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
127 fStatusIsClean =
false;
153 virtual ~ReadRuleFit() {
160 double GetMvaValue(
const std::vector<double>& inputValues )
const;
168 const char* fClassName;
171 size_t GetNvar()
const {
return fNvars; }
175 const bool fIsNormalised;
176 bool IsNormalised()
const {
return fIsNormalised; }
179 double NormVariable(
double x,
double xmin,
double xmax )
const {
181 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
189 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
195 void ReadRuleFit::Clear(){}
196 double ReadRuleFit::GetMvaValue__(
const std::vector<double>& inputValues )
const {
197 double rval=1.821665671;
202 if ((inputValues[2]<0.2859873176)&&(inputValues[3]<-0.6145658493)) rval+=-0.5383069125;
203 if ((0.6637439728<inputValues[0])&&(inputValues[3]<1.852592468)) rval+=-0.365472615;
204 if ((-0.8042526245<inputValues[0])) rval+=-0.3487120504;
205 if ((inputValues[2]<0.2859873176)&&(-0.6145658493<inputValues[3])) rval+=0.3265835596;
206 if ((inputValues[0]<1.397742271)&&(-0.7250279784<inputValues[1])&&(inputValues[3]<-0.6721984744)) rval+=-0.3591921639;
207 if ((inputValues[0]<2.865738869)&&(inputValues[3]<1.206904054)) rval+=-0.3235634573;
208 if ((inputValues[3]<1.110067248)) rval+=-0.3014417789;
209 if ((inputValues[0]<1.361399651)&&(inputValues[1]<0.2200206369)&&(inputValues[3]<-0.411757946)) rval+=-0.2635351483;
210 if ((0.2200206369<inputValues[1])) rval+=-0.199620194;
211 if ((-0.07025432587<inputValues[0])&&(0.3575037718<inputValues[1])) rval+=-0.2338918124;
212 if ((inputValues[2]<-1.044834495)) rval+=-0.2463489969;
213 if ((-1.538250923<inputValues[0])&&(inputValues[0]<1.266595125)&&(inputValues[3]<0.3321121633)) rval+=-0.1879163686;
214 if ((inputValues[1]<0.07876376063)&&(inputValues[3]<0.1014136598)) rval+=-0.2062533705;
215 if ((-0.6012272835<inputValues[2])&&(0.9022580981<inputValues[3])) rval+=0.1703085413;
216 if ((inputValues[1]<0.2200206369)) rval+=-0.1519403671;
217 if ((-0.4926698804<inputValues[2])&&(inputValues[3]<0.3393571973)) rval+=-0.1698124189;
218 if ((inputValues[0]<1.361399651)&&(inputValues[1]<0.2200206369)) rval+=0.1412135028;
219 if ((-0.737119019<inputValues[1])&&(inputValues[1]<0.02489273809)&&(inputValues[3]<0.605740428)) rval+=-0.1831062971;
220 if ((inputValues[0]<2.487332582)&&(-0.4926698804<inputValues[2])&&(inputValues[3]<1.069083929)) rval+=-0.1373525789;
221 if ((0.2200206369<inputValues[1])&&(inputValues[3]<0.7960036993)) rval+=-0.1430605103;
222 if ((0.2200206369<inputValues[1])&&(-1.044834495<inputValues[2])&&(inputValues[3]<0.196363762)) rval+=-0.1744597681;
223 if ((0.07876376063<inputValues[1])&&(0.2859873176<inputValues[2])) rval+=-0.1581814857;
224 if ((-1.856152892<inputValues[0])&&(inputValues[0]<0.6637439728)&&(0.2456704378<inputValues[3])) rval+=0.1660814983;
225 if ((inputValues[0]<-0.3903895915)&&(-0.1605666727<inputValues[1])&&(inputValues[2]<1.173201919)) rval+=0.1320495424;
226 if ((-0.876881063<inputValues[0])&&(inputValues[1]<-0.1346641928)&&(0.605740428<inputValues[3])) rval+=0.1373748234;
227 if ((inputValues[0]<2.865738869)&&(1.206904054<inputValues[3])) rval+=0.1301838684;
228 if ((inputValues[0]<2.865738869)) rval+=-0.1921057245;
229 if ((inputValues[0]<0.6637439728)&&(-0.237038821<inputValues[1])&&(0.2456704378<inputValues[3])) rval+=0.1434630503;
230 if ((-0.07025432587<inputValues[0])&&(inputValues[1]<0.3575037718)) rval+=-0.08493248301;
231 if ((-1.044834495<inputValues[2])) rval+=-0.1051437122;
232 if ((0.02489273809<inputValues[1])&&(inputValues[2]<0.7852135301)&&(inputValues[3]<0.605740428)) rval+=-0.08363995833;
233 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])&&(inputValues[3]<1.066591382)) rval+=-0.09249249872;
234 if ((inputValues[0]<-0.3790929615)&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])) rval+=0.09272184004;
235 if ((0.2200206369<inputValues[1])&&(inputValues[1]<0.774100244)&&(-1.044834495<inputValues[2])&&(inputValues[3]<0.196363762)) rval+=-0.1208843459;
236 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])&&(inputValues[2]<1.375104785)&&(inputValues[3]<1.066591382)) rval+=-0.07764621172;
237 if ((-0.3903895915<inputValues[0])&&(-0.1605666727<inputValues[1])&&(inputValues[2]<1.173201919)) rval+=-0.0690361005;
238 if ((0.6637439728<inputValues[0])&&(1.386405587<inputValues[3])) rval+=-0.08141573768;
239 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])) rval+=-0.06193442764;
240 if ((inputValues[0]<1.397742271)&&(-0.7250279784<inputValues[1])) rval+=0.05855968621;
241 if ((-0.4885016978<inputValues[0])&&(-1.044834495<inputValues[2])&&(1.261463404<inputValues[3])) rval+=-0.07066745959;
242 if ((-0.5954368114<inputValues[1])&&(inputValues[2]<-0.6012272835)) rval+=-0.06641189659;
243 if ((-0.876881063<inputValues[0])&&(-0.1346641928<inputValues[1])&&(0.605740428<inputValues[3])) rval+=-0.0589214863;
244 if ((-0.5954368114<inputValues[1])&&(inputValues[1]<-0.06197149307)&&(inputValues[2]<0.2926391363)) rval+=-0.05675071978;
245 if ((0.2200206369<inputValues[1])&&(0.7960036993<inputValues[3])) rval+=-0.05407344724;
246 if ((inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])) rval+=0.03043669572;
247 if ((0.2200206369<inputValues[1])&&(-1.044834495<inputValues[2])&&(0.196363762<inputValues[3])) rval+=0.03522315626;
248 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])&&(1.066591382<inputValues[3])) rval+=0.03174133575;
249 if ((-1.810295105<inputValues[2])&&(inputValues[2]<-1.044834495)) rval+=-0.02586694411;
250 if ((inputValues[0]<0.6637439728)&&(inputValues[1]<-0.237038821)&&(0.2456704378<inputValues[3])) rval+=0.02297392817;
251 if ((-1.411566615<inputValues[3])) rval+=-0.01612698015;
252 if ((inputValues[1]<-0.1605666727)&&(inputValues[2]<1.173201919)) rval+=-0.008633417105;
253 if ((-0.3790929615<inputValues[0])&&(inputValues[1]<0.2200206369)&&(-1.044834495<inputValues[2])&&(inputValues[2]<0.340533644)&&(1.066591382<inputValues[3])) rval+=0.02724536541;
258 rval+=-0.230579859*std::min(
double(3.424694538), std::max(
double(inputValues[0]),
double(-3.440958977)));
259 rval+=-0.03918419635*std::min(
double(2.07433629), std::max(
double(inputValues[1]),
double(-2.206938982)));
260 rval+=0.007237378388*std::min(
double(2.088175535), std::max(
double(inputValues[2]),
double(-2.172396898)));
261 rval+=0.3519137031*std::min(
double(2.604138613), std::max(
double(inputValues[3]),
double(-2.361749649)));
264 inline double ReadRuleFit::GetMvaValue(
const std::vector<double>& inputValues )
const 270 if (!IsStatusClean()) {
271 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 272 <<
" because status is dirty" << std::endl;
276 if (IsNormalised()) {
278 std::vector<double> iV;
279 iV.reserve(inputValues.size());
281 for (std::vector<double>::const_iterator varIt = inputValues.begin();
282 varIt != inputValues.end(); varIt++, ivar++) {
283 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
285 retval = GetMvaValue__( iV );
288 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)