FPCSMLR.h 2.1 KB

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