FPCSMLR.h 2.0 KB

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