FPCRandomForestTransfer.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * @file FPCRandomForestTransfer.h
  3. * @brief implementation of random set forests with a priori knowledge
  4. * @author Erik Rodner
  5. * @date 04/24/2008
  6. */
  7. #ifndef FPCRandomForestTransferINCLUDE
  8. #define FPCRandomForestTransferINCLUDE
  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 "vislearning/cbaselib/ClassNames.h"
  16. #include "vislearning/classifier/fpclassifier/randomforest/DTEstimateAPriori.h"
  17. #include "FPCRandomForests.h"
  18. namespace OBJREC {
  19. /** implementation of random set forests */
  20. class FPCRandomForestTransfer : public FPCRandomForests
  21. {
  22. protected:
  23. /** set of class numbers which are substituted */
  24. std::set<int> substituteClasses;
  25. /** set of class numbers used to estimated */
  26. std::set<int> muClasses;
  27. /** set of new class numbers */
  28. std::set<int> newClass;
  29. /** whether to reduce to training set randomly */
  30. bool reduce_training_set;
  31. /** use only a fraction of original training data */
  32. double training_ratio;
  33. /** use only a absolute number of training samples */
  34. int training_absolute;
  35. /** extend map tree */
  36. bool extend_map_tree;
  37. /** partial ml estimation of lower levels of the tree */
  38. bool partial_ml_estimation;
  39. int partial_ml_estimation_depth;
  40. /** extend only leafs with a suitable entropy beyond this threshold */
  41. double entropy_rejection_threshold;
  42. bool extend_only_critical_leafs;
  43. /** variance of gaussian prior
  44. sigmaq \rightarrow 0 : a posteriori = prior
  45. sigmaq \rightarrow \infty : a posteriori = likelihood
  46. (non-informative prior) */
  47. double sigmaq;
  48. /** read a-priori decision tree structure from file */
  49. bool read_cached_prior_structure;
  50. /** file to store/read a-priori decision tree structure */
  51. // refactor-nice.pl: check this substitution
  52. // old: string cached_prior_structure;
  53. std::string cached_prior_structure;
  54. /** whether to learn tree structure including the new class examples */
  55. bool learn_ert_with_newclass;
  56. /** extend map tree */
  57. void extendMapTree ( FeaturePool & fp,
  58. DecisionTree & tree,
  59. Examples & examples_transfer,
  60. Examples & examples_new,
  61. int newClassNo,
  62. const std::set<int> & muClasses );
  63. /** ML estimation */
  64. void mlEstimate ( DecisionNode *node,
  65. Examples & examples_new,
  66. int newClassNo );
  67. /** perform ML estimation at inner nodes of a fixed depth */
  68. void partialMLEstimate ( DecisionTree & tree,
  69. Examples & examples_new,
  70. int newClassNo,
  71. int mldepth );
  72. DecisionTreeBuilder *builder_extend;
  73. DTEstimateAPriori dte;
  74. public:
  75. /** simple constructor */
  76. FPCRandomForestTransfer(
  77. const NICE::Config *conf,
  78. const ClassNames *classNames,
  79. // refactor-nice.pl: check this substitution
  80. // old: string section = "RandomForest"
  81. std::string section = "RandomForest"
  82. );
  83. /** simple destructor */
  84. virtual ~FPCRandomForestTransfer();
  85. void train ( FeaturePool & fp,
  86. Examples & examples );
  87. FeaturePoolClassifier *clone () const;
  88. };
  89. } // namespace
  90. #endif