/********************************************************************** CostFactory.h: select features, typical use: feature selection for classification Author(s): Pieter.Kempeneers@ec.europa.eu Copyright (C) 2016-2020 European Union (Joint Research Centre) This file is part of jiplib. jiplib is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. jiplib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with jiplib. If not, see . ***********************************************************************/ #ifndef _COSTFACTORY_H_ #define _COSTFACTORY_H_ /* #include */ #include #include #include #include "ConfusionMatrix.h" #include "base/Vector2d.h" class CostFactory{ public: CostFactory(void){}; CostFactory(unsigned short cv, short verbose) : m_cv(cv), m_verbose(verbose){}; virtual ~CostFactory(void){}; void setCv(unsigned short cv){m_cv=cv;}; void setClassValueMap(const std::string& classname, short classvalue){ m_classValueMap[classname]=classvalue;}; std::map getClassValueMap(){return m_classValueMap;}; std::vector getNameVector(){return m_nameVector;}; void setNameVector(std::vector& nameVector){m_nameVector=nameVector;}; int getClassIndex(std::string classname) const {return m_cm.getClassIndex(classname);}; //pushBackClassName is for confusion matrix void pushBackClassName(std::string classname){m_cm.pushBackClassName(classname,true);};//doSort=true //pushBackName is for nameVector in CostFactory void pushBackName(std::string classname){m_nameVector.push_back(classname);}; void setNcTraining(const std::vector nctraining){m_nctraining=nctraining;}; void setNcTest(const std::vector nctest){m_nctest=nctest;}; //getCost needs to be implemented case by case (e.g., SVM, ANN) virtual double getCost(const std::vector > &trainingFeatures)=0; protected: confusionmatrix::ConfusionMatrix m_cm; std::map m_classValueMap; std::vector m_nameVector; std::vector m_nctraining; std::vector m_nctest; unsigned short m_cv; /* std::string m_classname; */ short m_classvalue; short m_verbose; }; #endif