FPCSMLR.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 "core/image/ImageT.h"
  12. #include "core/imagedisplay/ImageDisplay.h"
  13. #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
  14. #include "vislearning/classifier/fpclassifier/logisticregression/SLR.h"
  15. #include "vislearning/cbaselib/FeaturePool.h"
  16. #include "core/algebra/GMSparseVectorMatrix.h"
  17. namespace OBJREC
  18. {
  19. class FPCSMLR : public FeaturePoolClassifier
  20. {
  21. protected:
  22. //! the configuration file
  23. const NICE::Config *conf;
  24. //! section in the configfile
  25. std::string confsection;
  26. //! the featurepool
  27. FeaturePool fp;
  28. //! the one vs all sparse logistic classifiers
  29. std::vector<SLR> classifiers;
  30. //! just use the features from pictures, which the class contains
  31. bool inpic;
  32. public:
  33. /**
  34. * standard constructor
  35. * @param conf configfile
  36. * @param section section name in configfile for classifier
  37. */
  38. FPCSMLR ( const NICE::Config *conf, std::string section="SMLR" );
  39. /**
  40. * simple constructor -> does nothing
  41. */
  42. FPCSMLR ();
  43. /**
  44. * simple destructor
  45. */
  46. ~FPCSMLR();
  47. /**
  48. * main classification function
  49. * @param pce input feature
  50. * @return a classification result
  51. */
  52. ClassificationResult classify ( Example & pce );
  53. /**
  54. * start training
  55. * @param fp a featurepool (how to handle which features...)
  56. * @param examples input features
  57. */
  58. void train ( FeaturePool & _fp, Examples & examples );
  59. /**
  60. * clone this object
  61. * @return a copy of this object
  62. */
  63. FeaturePoolClassifier *clone () const;
  64. /**
  65. * set complexity for the next training process e.g. number of weak classifiers
  66. * @param size new complexity
  67. */
  68. void setComplexity ( int size );
  69. /** IO functions */
  70. void restore ( std::istream & is, int format = 0 );
  71. void store ( std::ostream & os, int format = 0 ) const;
  72. void clear ();
  73. };
  74. } // namespace
  75. #endif