DTBRandom.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * @file DTBRandom.h
  3. * @brief random decision tree
  4. * @author Erik Rodner
  5. * @date 05/06/2008
  6. */
  7. #ifndef DTBRANDOMINCLUDE
  8. #define DTBRANDOMINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/MatrixT.h"
  11. #include "core/basics/Config.h"
  12. #include "DecisionTreeBuilder.h"
  13. #include "vislearning/cbaselib/CachedExample.h"
  14. namespace OBJREC {
  15. /** random decision tree */
  16. class DTBRandom : public DecisionTreeBuilder
  17. {
  18. protected:
  19. int random_split_tests;
  20. int random_features;
  21. int max_depth;
  22. int min_examples;
  23. double minimum_information_gain;
  24. double minimum_entropy;
  25. bool use_shannon_entropy;
  26. int random_split_mode;
  27. /** saves indices in leaves */
  28. bool save_indices;
  29. enum {
  30. RANDOM_SPLIT_INDEX = 0,
  31. RANDOM_SPLIT_UNIFORM
  32. };
  33. DecisionNode *buildRecursive ( const FeaturePool & fp,
  34. const Examples & examples,
  35. std::vector<int> & examples_selection,
  36. FullVector & distribution,
  37. double entropy,
  38. int maxClassNo,
  39. int depth );
  40. #if 0
  41. double entropy ( const FeatureValues & values,
  42. const FeatureValues::const_iterator & begin,
  43. const FeatureValues::const_iterator & end,
  44. std::vector<int> & examples,
  45. FullVector & stat );
  46. #endif
  47. bool entropyLeftRight ( const FeatureValuesUnsorted & values,
  48. double threshold,
  49. double* stat_left,
  50. double* stat_right,
  51. double & entropy_left,
  52. double & entropy_right,
  53. double & count_left,
  54. double & count_right,
  55. int maxClassNo );
  56. public:
  57. /** simple constructor */
  58. // refactor-nice.pl: check this substitution
  59. // old: DTBRandom( const NICE::Config *conf, string section = "DTBRandom" );
  60. DTBRandom( const NICE::Config *conf, std::string section = "DTBRandom" );
  61. /** simple destructor */
  62. virtual ~DTBRandom();
  63. DecisionNode *build ( const FeaturePool & fp,
  64. const Examples & examples,
  65. int maxClassNo );
  66. };
  67. } // namespace
  68. #endif