RegPreRandomForests.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * @file RegPreRandomForests.h
  3. * @brief Combination of a regression method with a pre-clustering using a random forest
  4. * @author Sven Sickert
  5. * @date 07/12/2013
  6. */
  7. #ifndef REGPRERANDOMFORESTSINCLUDE
  8. #define REGPRERANDOMFORESTSINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/MatrixT.h"
  11. #include <map>
  12. #include "vislearning/regression/regressionbase/RegressionAlgorithm.h"
  13. #include "vislearning/regression/randomforest/RegRandomForests.h"
  14. namespace OBJREC{
  15. /** Combination of a regression method with a pre-clustering using a random forest */
  16. class RegPreRandomForests : public RegressionAlgorithm
  17. {
  18. protected:
  19. /** the regression prototype used to process
  20. all examples in a leaf */
  21. RegressionAlgorithm *leafRegressionPrototype;
  22. /** regression of each leaf */
  23. std::map<RegressionNode *, RegressionAlgorithm *> leafRegressions;
  24. /** the random forest used to pre-cluster the features */
  25. RegRandomForests *randomforest;
  26. /** maximum number of Examples in a leaf */
  27. int mEx;
  28. public:
  29. /** simple constructor */
  30. RegPreRandomForests( const NICE::Config *conf,
  31. const std::string & section,
  32. RegressionAlgorithm * _leafRegressionPrototype );
  33. /** simple destructor */
  34. virtual ~ RegPreRandomForests();
  35. /** learn parameters/models/whatever using a set of vectors and
  36. * their corresponding function values
  37. */
  38. void teach ( const NICE::VVector & X, const NICE::Vector & y );
  39. /** predict the function value for \c x */
  40. double predict ( const NICE::Vector & x );
  41. void clear();
  42. void store ( std::ostream & os, int format = 0 ) const;
  43. void restore ( std::istream & is, int format = 0 );
  44. };
  45. } // namespace
  46. #endif