123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- /**
- * @file GPHIKClassifierNICE.h
- * @author Alexander Freytag, Erik Rodner
- * @date 02/01/2012
- */
- #ifndef _NICE_GPHIKCLASSIFIERNICEINCLUDE
- #define _NICE_GPHIKCLASSIFIERNICEINCLUDE
- // STL includes
- #include <string>
- // NICE-core includes
- #include <core/basics/Config.h>
- // NICE-vislearning includes
- #include <vislearning/classifier/classifierbase/FeaturePoolClassifier.h>
- // NICE-gp-hik-core includes
- #include <gp-hik-core/GPHIKClassifier.h>
- #include <gp-hik-core/FMKGPHyperparameterOptimization.h>
- #include <gp-hik-core/parameterizedFunctions/ParameterizedFunction.h>
- namespace OBJREC {
-
- /** @class GPHIKClassifierNICE
- * Wrapper class (feature pool interface) for our GP HIK classifier
- *
- * @author Alexander Freytag, Erik Rodner
- */
- class GPHIKClassifierNICE : public FeaturePoolClassifier
- {
- protected:
-
- /////////////////////////
- /////////////////////////
- // PROTECTED VARIABLES //
- /////////////////////////
- /////////////////////////
-
- NICE::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;
-
- /** When adding new examples, do we want to run a whole optimization of all involved hyperparameters? default: true*/
- bool performOptimizationAfterIncrement;
-
- /////////////////////////
- /////////////////////////
- // PROTECTED METHODS //
- /////////////////////////
- /////////////////////////
-
- /**
- * @brief Setup internal variables and objects used
- * @author Alexander Freytag
- * @param conf Config file to specify variable settings
- * @param s_confSection
- */
- void init ( const NICE::Config *conf, const std::string & s_confSection = "GPHIKClassifier" );
- public:
- /** simple constructor */
- GPHIKClassifierNICE( );
-
- /** default 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< const NICE::SparseVector *> & examples, std::map<int, NICE::Vector> & binLabels );
-
- ///////////////////// INTERFACE PERSISTENT /////////////////////
- // interface specific methods for store and restore
- ///////////////////// INTERFACE PERSISTENT /////////////////////
- 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;
-
- /**
- * @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 uncertainty contains the resulting classification uncertainty
- */
- void predictUncertainty( OBJREC::Example & pe, double & uncertainty );
-
- /**
- * @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 uncertainty contains the resulting classification uncertainty
- */
- void predictUncertainty( const NICE::SparseVector * example, double & uncertainty );
-
- ///////////////////// INTERFACE ONLINE LEARNABLE (SIMILAR) /////////////////////
- // interface specific methods for incremental extensions
- ///////////////////// INTERFACE ONLINE LEARNABLE (SIMILAR) /////////////////////
-
- void addExample( const OBJREC::Example & pe, const double & label);
- virtual void addMultipleExamples( OBJREC::Examples & newExamples);
-
- };
- }
- #endif
|