55 #ifndef IClassifierReader__def 56 #define IClassifierReader__def 58 class IClassifierReader {
63 IClassifierReader() : fStatusIsClean(
true ) {}
64 virtual ~IClassifierReader() {}
67 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
70 bool IsStatusClean()
const {
return fStatusIsClean; }
79 class ReadFisher :
public IClassifierReader {
84 ReadFisher( std::vector<std::string>& theInputVars )
85 : IClassifierReader(),
86 fClassName(
"ReadFisher" ),
88 fIsNormalised(
false )
91 const char* inputVars[] = {
"x",
"y" };
94 if (theInputVars.size() <= 0) {
95 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
96 fStatusIsClean =
false;
99 if (theInputVars.size() != fNvars) {
100 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 101 << theInputVars.size() <<
" != " << fNvars << std::endl;
102 fStatusIsClean =
false;
106 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
107 if (theInputVars[ivar] != inputVars[ivar]) {
108 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
109 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
110 fStatusIsClean =
false;
130 virtual ~ReadFisher() {
137 double GetMvaValue(
const std::vector<double>& inputValues )
const override;
145 const char* fClassName;
148 size_t GetNvar()
const {
return fNvars; }
152 const bool fIsNormalised;
153 bool IsNormalised()
const {
return fIsNormalised; }
156 double NormVariable(
double x,
double xmin,
double xmax )
const {
158 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
166 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
169 inline double ReadFisher::GetMvaValue(
const std::vector<double>& inputValues )
const 175 if (!IsStatusClean()) {
176 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 177 <<
" because status is dirty" << std::endl;
181 if (IsNormalised()) {
183 std::vector<double> iV;
184 iV.reserve(inputValues.size());
186 for (std::vector<double>::const_iterator varIt = inputValues.begin();
187 varIt != inputValues.end(); varIt++, ivar++) {
188 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
190 retval = GetMvaValue__( iV );
193 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)