/** * @file GPHIKClassifierNICE.h * @author Alexander Freytag, Erik Rodner * @date 02/01/2012 */ #ifndef _NICE_GPHIKCLASSIFIERNICEINCLUDE #define _NICE_GPHIKCLASSIFIERNICEINCLUDE #include #include "core/basics/Config.h" #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h" #include #include #include namespace OBJREC { /** @class GPHIKClassifierNICE * Wrapper class (feature pool interface) for our GP HIK classifier * * @author Alexander Freytag, Erik Rodner */ class GPHIKClassifierNICE : public FeaturePoolClassifier { protected: OBJREC::GPHIKClassifier * classifier; /** verbose flag for useful output*/ bool verbose; /** a simple balancing strategy: use only that many examples of each class, as the smallest class provides*/ bool useSimpleBalancing; int minSamples; public: /** simple constructor */ GPHIKClassifierNICE( const NICE::Config *conf, const std::string & confSection = "GPHIKClassifier" ); /** simple destructor */ virtual ~GPHIKClassifierNICE(); /** * @brief classify a given example with the previously learnt model * @param pe example to be classified given in a sparse representation */ virtual ClassificationResult classify ( OBJREC::Example & pe ); /** * @brief classify a given example with the previously learnt model * @date 19-06-2012 (dd-mm-yyyy) * @author Alexander Freytag * @param examples example to be classified given in a sparse representation */ ClassificationResult classify ( const NICE::SparseVector * example ); /** training process */ virtual void train ( OBJREC::FeaturePool & fp, OBJREC::Examples & examples ); /** * @brief train this classifier using a given set of examples and a given set of binary label vectors * @date 19-06-2012 (dd-mm-yyyy) * @author Alexander Freytag * @param examples examples to use given in a sparse data structure * @param binLabels corresponding binary labels with class no. There is no need here that every examples has only on positive entry in this set (1,-1) */ void train ( const std::vector< NICE::SparseVector *> & examples, std::map & binLabels ); /** Persistent interface */ virtual void restore ( std::istream & is, int format = 0 ); virtual void store ( std::ostream & os, int format = 0 ) const; virtual void clear (); virtual FeaturePoolClassifier *clone () const; /** prediction of classification uncertainty */ void predictUncertainty( OBJREC::Example & pe, NICE::Vector & uncertainties ); /** * @brief prediction of classification uncertainty * @date 19-06-2012 (dd-mm-yyyy) * @author Alexander Freytag * @param examples example for which the classification uncertainty shall be predicted, given in a sparse representation * @param uncertainties contains the resulting classification uncertainties (1 entry for standard setting, m entries for binary-balanced setting) */ void predictUncertainty( const NICE::SparseVector * example, NICE::Vector & uncertainties ); void addExample( const OBJREC::Example & pe, const double & label, const bool & performOptimizationAfterIncrement = true); void addMultipleExamples( OBJREC::Examples & newExamples, const bool & performOptimizationAfterIncrement = true); }; } #endif