FPCGPHIK.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @file FPCGPHIK.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 FPCGPHIK
  16. * Wrapper class (feature pool interface) for our GP HIK classifier
  17. *
  18. * @author Alexander Freytag, Erik Rodner
  19. */
  20. class FPCGPHIK : public FeaturePoolClassifier
  21. {
  22. protected:
  23. NICE::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. /** When adding new examples, do we want to run a whole optimization of all involved hyperparameters? default: true*/
  30. bool performOptimizationAfterIncrement;
  31. public:
  32. /** simple constructor */
  33. FPCGPHIK( const NICE::Config *conf, const std::string & confSection = "GPHIKClassifier" );
  34. /** simple destructor */
  35. virtual ~FPCGPHIK();
  36. /**
  37. * @brief classify a given example with the previously learnt model
  38. * @param pe example to be classified given in a sparse representation
  39. */
  40. virtual ClassificationResult classify ( OBJREC::Example & pe );
  41. /**
  42. * @brief classify a given example with the previously learnt model
  43. * @date 19-06-2012 (dd-mm-yyyy)
  44. * @author Alexander Freytag
  45. * @param examples example to be classified given in a sparse representation
  46. */
  47. ClassificationResult classify ( const NICE::SparseVector * example );
  48. /** training process */
  49. virtual void train ( OBJREC::FeaturePool & fp, OBJREC::Examples & examples );
  50. /**
  51. * @brief train this classifier using a given set of examples and a given set of binary label vectors
  52. * @date 19-06-2012 (dd-mm-yyyy)
  53. * @author Alexander Freytag
  54. * @param examples examples to use given in a sparse data structure
  55. * @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)
  56. */
  57. void train ( const std::vector< NICE::SparseVector *> & examples, std::map<int, NICE::Vector> & binLabels );
  58. /** Persistent interface */
  59. virtual void restore ( std::istream & is, int format = 0 );
  60. virtual void store ( std::ostream & os, int format = 0 ) const;
  61. virtual void clear ();
  62. virtual FeaturePoolClassifier *clone () const;
  63. /** prediction of classification uncertainty */
  64. void predictUncertainty( OBJREC::Example & pe, NICE::Vector & uncertainties );
  65. /**
  66. * @brief prediction of classification uncertainty
  67. * @date 19-06-2012 (dd-mm-yyyy)
  68. * @author Alexander Freytag
  69. * @param examples example for which the classification uncertainty shall be predicted, given in a sparse representation
  70. * @param uncertainties contains the resulting classification uncertainties (1 entry for standard setting, m entries for binary-balanced setting)
  71. */
  72. void predictUncertainty( const NICE::SparseVector * example, NICE::Vector & uncertainties );
  73. void addExample( const OBJREC::Example & pe, const double & label);
  74. virtual void addMultipleExamples( OBJREC::Examples & newExamples);
  75. };
  76. }
  77. #endif