GestureRecognitionToolkit  Version: 0.1.0
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
RandomForests.h
1 
35 #ifndef GRT_RANDOM_FORESTS_HEADER
36 #define GRT_RANDOM_FORESTS_HEADER
37 
38 #include "../DecisionTree/DecisionTree.h"
39 
40 GRT_BEGIN_NAMESPACE
41 
42 class RandomForests : public Classifier
43 {
44 public:
57  RandomForests(const DecisionTreeNode &decisionTreeNode = DecisionTreeClusterNode(),
58  const UINT forestSize=10,
59  const UINT numRandomSplits=100,
60  const UINT minNumSamplesPerNode=5,
61  const UINT maxDepth=10,
62  const UINT trainingMode = DecisionTree::BEST_RANDOM_SPLIT,
63  const bool removeFeaturesAtEachSpilt = true,
64  const bool useScaling=false,
65  const Float bootstrappedDatasetWeight = 0.8);
66 
72  RandomForests(const RandomForests &rhs);
73 
77  virtual ~RandomForests(void);
78 
86 
94  virtual bool deepCopyFrom(const Classifier *classifier);
95 
103  virtual bool train_(ClassificationData &trainingData);
104 
112  virtual bool predict_(VectorDouble &inputVector);
113 
119  virtual bool clear();
120 
126  virtual bool print() const;
127 
135  virtual bool saveModelToFile( std::fstream &file ) const;
136 
144  virtual bool loadModelFromFile( std::fstream &file );
145 
154  bool combineModels( const RandomForests &forest );
155 
161  UINT getForestSize() const;
162 
168  UINT getNumRandomSplits() const;
169 
176  UINT getMinNumSamplesPerNode() const;
177 
183  UINT getMaxDepth() const;
184 
190  UINT getTrainingMode() const;
191 
197  const Vector< DecisionTreeNode* > &getForest() const;
198 
206  bool getRemoveFeaturesAtEachSpilt() const;
207 
214  Float getBootstrappedDatasetWeight() const;
215 
222  DecisionTreeNode* getTree( const UINT index ) const;
223 
230 
243  VectorDouble getFeatureWeights( const bool normWeights = true ) const;
244 
257  MatrixDouble getLeafNodeFeatureWeights( const bool normWeights = true ) const;
258 
265  bool setForestSize(const UINT forestSize);
266 
276  bool setNumRandomSplits(const UINT numSplittingSteps);
277 
286  bool setMinNumSamplesPerNode(const UINT minNumSamplesPerNode);
287 
295  bool setMaxDepth(const UINT maxDepth);
296 
305  bool setRemoveFeaturesAtEachSpilt(const bool removeFeaturesAtEachSpilt);
306 
313  bool setTrainingMode(const UINT trainingMode);
314 
320  bool setDecisionTreeNode( const DecisionTreeNode &node );
321 
329  bool setBootstrappedDatasetWeight( const Float bootstrappedDatasetWeight );
330 
331  //Tell the compiler we are using the base class train method to stop hidden virtual function warnings
334 
335 protected:
336 
337  UINT forestSize;
338  UINT numRandomSplits;
339  UINT minNumSamplesPerNode;
340  UINT maxDepth;
341  UINT trainingMode;
342  bool removeFeaturesAtEachSpilt;
343  Float bootstrappedDatasetWeight;
344  DecisionTreeNode* decisionTreeNode;
346 
347 private:
348  static RegisterClassifierModule< RandomForests > registerModule;
349 
350 };
351 
352 GRT_END_NAMESPACE
353 
354 #endif //GRT_RANDOM_FORESTS_HEADER
355 
DecisionTreeNode * getTree(const UINT index) const
virtual bool loadModelFromFile(std::fstream &file)
UINT getForestSize() const
RandomForests(const DecisionTreeNode &decisionTreeNode=DecisionTreeClusterNode(), const UINT forestSize=10, const UINT numRandomSplits=100, const UINT minNumSamplesPerNode=5, const UINT maxDepth=10, const UINT trainingMode=DecisionTree::BEST_RANDOM_SPLIT, const bool removeFeaturesAtEachSpilt=true, const bool useScaling=false, const Float bootstrappedDatasetWeight=0.8)
virtual ~RandomForests(void)
virtual bool saveModelToFile(std::fstream &file) const
bool setBootstrappedDatasetWeight(const Float bootstrappedDatasetWeight)
UINT getMaxDepth() const
bool setMinNumSamplesPerNode(const UINT minNumSamplesPerNode)
bool combineModels(const RandomForests &forest)
RandomForests & operator=(const RandomForests &rhs)
bool setNumRandomSplits(const UINT numSplittingSteps)
virtual bool train_(ClassificationData &trainingData)
MatrixDouble getLeafNodeFeatureWeights(const bool normWeights=true) const
bool setForestSize(const UINT forestSize)
virtual bool saveModelToFile(std::string filename) const
Definition: MLBase.cpp:146
bool setMaxDepth(const UINT maxDepth)
UINT getNumRandomSplits() const
virtual bool deepCopyFrom(const Classifier *classifier)
Float getBootstrappedDatasetWeight() const
bool setTrainingMode(const UINT trainingMode)
virtual bool loadModelFromFile(std::string filename)
Definition: MLBase.cpp:168
UINT getMinNumSamplesPerNode() const
bool setDecisionTreeNode(const DecisionTreeNode &node)
virtual bool predict_(VectorDouble &inputVector)
VectorDouble getFeatureWeights(const bool normWeights=true) const
const Vector< DecisionTreeNode * > & getForest() const
bool getRemoveFeaturesAtEachSpilt() const
virtual bool clear()
virtual bool print() const
bool setRemoveFeaturesAtEachSpilt(const bool removeFeaturesAtEachSpilt)
UINT getTrainingMode() const
DecisionTreeNode * deepCopyDecisionTreeNode() const