57#ifndef IClassifierReader__def
58#define IClassifierReader__def
60class IClassifierReader {
65 IClassifierReader() : fStatusIsClean(
true ) {}
66 virtual ~IClassifierReader() {}
69 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
72 bool IsStatusClean()
const {
return fStatusIsClean; }
81class ReadFisher :
public IClassifierReader {
86 ReadFisher( std::vector<std::string>& theInputVars )
87 : IClassifierReader(),
88 fClassName(
"ReadFisher" ),
92 const char* inputVars[] = {
"var1",
"var2",
"var3",
"var4" };
95 if (theInputVars.size() <= 0) {
96 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
97 fStatusIsClean =
false;
100 if (theInputVars.size() != fNvars) {
101 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: "
102 << theInputVars.size() <<
" != " << fNvars << std::endl;
103 fStatusIsClean =
false;
107 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
108 if (theInputVars[ivar] != inputVars[ivar]) {
109 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
110 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
111 fStatusIsClean =
false;
137 virtual ~ReadFisher() {
144 double GetMvaValue(
const std::vector<double>& inputValues )
const override;
152 const char* fClassName;
155 size_t GetNvar()
const {
return fNvars; }
161 double NormVariable(
double x,
double xmin,
double xmax )
const {
171 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
175 std::vector<double> fFisherCoefficients;
180 fFisher0 = -0.0233784980026;
181 fFisherCoefficients.push_back( -0.0529463889001 );
182 fFisherCoefficients.push_back( -0.0136473747837 );
183 fFisherCoefficients.push_back( 0.0960349295198 );
184 fFisherCoefficients.push_back( 0.21637932158 );
187 if (fFisherCoefficients.size() != fNvars) {
188 std::cout <<
"Problem in class \"" << fClassName <<
"\"::Initialize: mismatch in number of input values"
189 << fFisherCoefficients.size() <<
" != " << fNvars << std::endl;
190 fStatusIsClean =
false;
194inline double ReadFisher::GetMvaValue__(
const std::vector<double>& inputValues )
const
196 double retval = fFisher0;
197 for (
size_t ivar = 0; ivar < fNvars; ivar++) {
198 retval += fFisherCoefficients[ivar]*inputValues[ivar];
205inline void ReadFisher::Clear()
208 fFisherCoefficients.clear();
210 inline double ReadFisher::GetMvaValue(
const std::vector<double>& inputValues )
const
216 if (!IsStatusClean()) {
217 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response"
218 <<
" because status is dirty" << std::endl;
222 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)