FPCSMLR.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * @file FPCSMLR.h
  3. * @brief implementation of Sparse Multinomial Logistic Regression (SMLR) Classififier, it uses a SLR for each class and combines the results
  4. * @author Björn Fröhlich
  5. * @date 06/23/2009
  6. */
  7. #ifndef FPCSMLRDEF
  8. #define FPCSMLRDEF
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/MatrixT.h"
  11. #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
  12. #include "vislearning/classifier/fpclassifier/logisticregression/SLR.h"
  13. #include "vislearning/cbaselib/FeaturePool.h"
  14. #include "core/algebra/GMSparseVectorMatrix.h"
  15. namespace OBJREC
  16. {
  17. class FPCSMLR : public FeaturePoolClassifier
  18. {
  19. protected:
  20. //! the configuration file
  21. const NICE::Config *conf;
  22. //! section in the configfile
  23. std::string confsection;
  24. //! the featurepool
  25. FeaturePool fp;
  26. //! the one vs all sparse logistic classifiers
  27. std::vector<SLR> classifiers;
  28. //! just use the features from pictures, which the class contains
  29. bool inpic;
  30. public:
  31. /**
  32. * standard constructor
  33. * @param conf configfile
  34. * @param section section name in configfile for classifier
  35. */
  36. FPCSMLR ( const NICE::Config *conf, std::string section="SMLR" );
  37. /**
  38. * simple constructor -> does nothing
  39. */
  40. FPCSMLR ();
  41. /**
  42. * simple destructor
  43. */
  44. ~FPCSMLR();
  45. /**
  46. * main classification function
  47. * @param pce input feature
  48. * @return a classification result
  49. */
  50. ClassificationResult classify ( Example & pce );
  51. /**
  52. * start training
  53. * @param fp a featurepool (how to handle which features...)
  54. * @param examples input features
  55. */
  56. void train ( FeaturePool & _fp, Examples & examples );
  57. /**
  58. * clone this object
  59. * @return a copy of this object
  60. */
  61. FeaturePoolClassifier *clone () const;
  62. /**
  63. * set complexity for the next training process e.g. number of weak classifiers
  64. * @param size new complexity
  65. */
  66. void setComplexity ( int size );
  67. /** IO functions */
  68. void restore ( std::istream & is, int format = 0 );
  69. void store ( std::ostream & os, int format = 0 ) const;
  70. void clear ();
  71. };
  72. } // namespace
  73. #endif