Bagging.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * @file Bagging.h
  3. * @brief implementation of breimans bagging idea
  4. * @author Erik Rodner
  5. * @date 04/24/2008
  6. */
  7. #ifndef BaggingINCLUDE
  8. #define BaggingINCLUDE
  9. #ifdef NOVISUAL
  10. #include <vislearning/nice_nonvis.h>
  11. #else
  12. #include <vislearning/nice.h>
  13. #endif
  14. #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
  15. #include "vislearning/features/fpfeatures/FeaturePool.h"
  16. namespace OBJREC {
  17. /** implementation of random set forests */
  18. class Bagging : public FeaturePoolClassifier
  19. {
  20. protected:
  21. std::vector<FeaturePoolClassifier *> ensemble;
  22. int number_of_classifiers;
  23. double features_per_tree;
  24. double samples_per_tree;
  25. bool use_simple_balancing;
  26. bool weight_examples;
  27. double minimum_entropy;
  28. bool memory_efficient;
  29. const NICE::Config *conf;
  30. // refactor-nice.pl: check this substitution
  31. // old: string confsection;
  32. std::string confsection;
  33. DecisionTreeBuilder *builder;
  34. public:
  35. /** train */
  36. Bagging( const NICE::Config *conf,
  37. // refactor-nice.pl: check this substitution
  38. // old: string section );
  39. std::string section );
  40. /** simple destructor */
  41. virtual ~Bagging();
  42. ClassificationResult classify ( Example & pce );
  43. int classify_optimize ( Example & pce );
  44. void getLeafNodes ( Example & pce,
  45. std::vector<DecisionNode *> & leafNodes,
  46. int depth = 100000 );
  47. virtual void train ( FeaturePool & fp,
  48. Examples & examples );
  49. void restore (std::istream & is, int format = 0);
  50. void store (std::ostream & os, int format = 0) const;
  51. void clear ();
  52. void indexDescendants ( std::map<DecisionNode *, std::pair<long, int> > & index ) const;
  53. void resetCounters ();
  54. const std::vector<DecisionTree *> & getForest () const { return forest; };
  55. FeaturePoolClassifier *clone () const;
  56. };
  57. } // namespace
  58. #endif