DTBRandom.h 1.9 KB

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