FPCRandomForestTransfer.h 3.0 KB

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