FPCSMLR.h 2.0 KB

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