51 #ifndef IClassifierReader__def 52 #define IClassifierReader__def 54 class IClassifierReader {
59 IClassifierReader() : fStatusIsClean(
true ) {}
60 virtual ~IClassifierReader() {}
63 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
66 bool IsStatusClean()
const {
return fStatusIsClean; }
75 class ReadFisher_fold2 :
public IClassifierReader {
80 ReadFisher_fold2( std::vector<std::string>& theInputVars )
81 : IClassifierReader(),
82 fClassName(
"ReadFisher_fold2" ),
84 fIsNormalised(
false )
87 const char* inputVars[] = {
"x",
"y" };
90 if (theInputVars.size() <= 0) {
91 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
92 fStatusIsClean =
false;
95 if (theInputVars.size() != fNvars) {
96 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 97 << theInputVars.size() <<
" != " << fNvars << std::endl;
98 fStatusIsClean =
false;
102 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
103 if (theInputVars[ivar] != inputVars[ivar]) {
104 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
105 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
106 fStatusIsClean =
false;
126 virtual ~ReadFisher_fold2() {
133 double GetMvaValue(
const std::vector<double>& inputValues )
const override;
141 const char* fClassName;
144 size_t GetNvar()
const {
return fNvars; }
148 const bool fIsNormalised;
149 bool IsNormalised()
const {
return fIsNormalised; }
152 double NormVariable(
double x,
double xmin,
double xmax )
const {
154 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
162 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
166 std::vector<double> fFisherCoefficients;
171 fFisher0 = 0.0107410639466;
172 fFisherCoefficients.push_back( 0.446192390326 );
173 fFisherCoefficients.push_back( 0.47863679649 );
176 if (fFisherCoefficients.size() != fNvars) {
177 std::cout <<
"Problem in class \"" << fClassName <<
"\"::Initialize: mismatch in number of input values" 178 << fFisherCoefficients.size() <<
" != " << fNvars << std::endl;
179 fStatusIsClean =
false;
183 inline double ReadFisher_fold2::GetMvaValue__(
const std::vector<double>& inputValues )
const 185 double retval = fFisher0;
186 for (
size_t ivar = 0; ivar < fNvars; ivar++) {
187 retval += fFisherCoefficients[ivar]*inputValues[ivar];
194 inline void ReadFisher_fold2::Clear()
197 fFisherCoefficients.clear();
199 inline double ReadFisher_fold2::GetMvaValue(
const std::vector<double>& inputValues )
const 205 if (!IsStatusClean()) {
206 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 207 <<
" because status is dirty" << std::endl;
211 if (IsNormalised()) {
213 std::vector<double> iV;
214 iV.reserve(inputValues.size());
216 for (std::vector<double>::const_iterator varIt = inputValues.begin();
217 varIt != inputValues.end(); varIt++, ivar++) {
218 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
220 retval = GetMvaValue__( iV );
223 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)