GPHIKClassifierNICE.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * @file GPHIKClassifierNICE.h
  3. * @author Alexander Freytag, Erik Rodner
  4. * @date 02/01/2012
  5. */
  6. #ifndef _NICE_GPHIKCLASSIFIERNICEINCLUDE
  7. #define _NICE_GPHIKCLASSIFIERNICEINCLUDE
  8. #include <string>
  9. #include "core/basics/Config.h"
  10. #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
  11. #include <gp-hik-core/GPHIKClassifier.h>
  12. #include <gp-hik-core/FMKGPHyperparameterOptimization.h>
  13. #include <gp-hik-core/parameterizedFunctions/ParameterizedFunction.h>
  14. namespace OBJREC {
  15. /** @class GPHIKClassifierNICE
  16. * Wrapper class (feature pool interface) for our GP HIK classifier
  17. *
  18. * @author Alexander Freytag, Erik Rodner
  19. */
  20. class GPHIKClassifierNICE : public FeaturePoolClassifier
  21. {
  22. protected:
  23. OBJREC::GPHIKClassifier * classifier;
  24. /** verbose flag for useful output*/
  25. bool verbose;
  26. /** a simple balancing strategy: use only that many examples of each class, as the smallest class provides*/
  27. bool useSimpleBalancing;
  28. int minSamples;
  29. public:
  30. /** simple constructor */
  31. GPHIKClassifierNICE( const NICE::Config *conf, const std::string & confSection = "GPHIKClassifier" );
  32. /** simple destructor */
  33. virtual ~GPHIKClassifierNICE();
  34. /**
  35. * @brief classify a given example with the previously learnt model
  36. * @param pe example to be classified given in a sparse representation
  37. */
  38. virtual ClassificationResult classify ( OBJREC::Example & pe );
  39. /**
  40. * @brief classify a given example with the previously learnt model
  41. * @date 19-06-2012 (dd-mm-yyyy)
  42. * @author Alexander Freytag
  43. * @param examples example to be classified given in a sparse representation
  44. */
  45. ClassificationResult classify ( const NICE::SparseVector * example );
  46. /** training process */
  47. virtual void train ( OBJREC::FeaturePool & fp, OBJREC::Examples & examples );
  48. /**
  49. * @brief train this classifier using a given set of examples and a given set of binary label vectors
  50. * @date 19-06-2012 (dd-mm-yyyy)
  51. * @author Alexander Freytag
  52. * @param examples examples to use given in a sparse data structure
  53. * @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)
  54. */
  55. void train ( const std::vector< NICE::SparseVector *> & examples, std::map<int, NICE::Vector> & binLabels );
  56. /** Persistent interface */
  57. virtual void restore ( std::istream & is, int format = 0 );
  58. virtual void store ( std::ostream & os, int format = 0 ) const;
  59. virtual void clear ();
  60. virtual FeaturePoolClassifier *clone () const;
  61. /** prediction of classification uncertainty */
  62. void predictUncertainty( OBJREC::Example & pe, NICE::Vector & uncertainties );
  63. /**
  64. * @brief prediction of classification uncertainty
  65. * @date 19-06-2012 (dd-mm-yyyy)
  66. * @author Alexander Freytag
  67. * @param examples example for which the classification uncertainty shall be predicted, given in a sparse representation
  68. * @param uncertainties contains the resulting classification uncertainties (1 entry for standard setting, m entries for binary-balanced setting)
  69. */
  70. void predictUncertainty( const NICE::SparseVector * example, NICE::Vector & uncertainties );
  71. void addExample( const OBJREC::Example & pe, const double & label, const bool & performOptimizationAfterIncrement = true);
  72. void addMultipleExamples( OBJREC::Examples & newExamples, const bool & performOptimizationAfterIncrement = true);
  73. };
  74. }
  75. #endif