GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
DecisionTree.h
Go to the documentation of this file.
1 
35 #ifndef GRT_DECISION_TREE_HEADER
36 #define GRT_DECISION_TREE_HEADER
37 
38 #include "../../CoreModules/Classifier.h"
39 #include "../../CoreAlgorithms/Tree/Tree.h"
40 #include "DecisionTreeNode.h"
44 
45 namespace GRT{
46 
47 class DecisionTree : public Tree, public Classifier
48 {
49 public:
61  DecisionTree(const DecisionTreeNode &decisionTreeNode = DecisionTreeClusterNode(),const UINT minNumSamplesPerNode=5,const UINT maxDepth=10,const bool removeFeaturesAtEachSpilt = false,const UINT trainingMode = BEST_ITERATIVE_SPILT,const UINT numSplittingSteps=100,const bool useScaling=false );
62 
68  DecisionTree(const DecisionTree &rhs);
69 
73  virtual ~DecisionTree(void);
74 
81  DecisionTree &operator=(const DecisionTree &rhs);
82 
90  virtual bool deepCopyFrom(const Classifier *classifier);
91 
99  virtual bool train_(ClassificationData &trainingData);
100 
108  virtual bool predict_(VectorDouble &inputVector);
109 
116  virtual bool clear();
117 
124  virtual bool recomputeNullRejectionThresholds();
125 
133  virtual bool saveModelToFile(fstream &file) const;
134 
142  virtual bool loadModelFromFile(fstream &file);
143 
151  virtual bool getModel(ostream &stream) const;
152 
161 
167  const DecisionTreeNode* getTree() const;
168 
175 
181  bool setDecisionTreeNode( const DecisionTreeNode &node );
182 
183  //Tell the compiler we are using the base class train method to stop hidden virtual function warnings
186  using MLBase::train;
187  using MLBase::predict;
188  using MLBase::print;
189 
190 protected:
191  bool loadLegacyModelFromFile_v1( fstream &file );
192  bool loadLegacyModelFromFile_v2( fstream &file );
193  bool loadLegacyModelFromFile_v3( fstream &file );
194 
195  DecisionTreeNode* buildTree(ClassificationData &trainingData, DecisionTreeNode *parent, vector< UINT > features, const vector< UINT > &classLabels, UINT nodeID );
196  double getNodeDistance( const VectorDouble &x, const UINT nodeID );
197  double getNodeDistance( const VectorDouble &x, const VectorDouble &y );
198 
199  DecisionTreeNode* decisionTreeNode;
200  std::map< UINT, VectorDouble > nodeClusters;
201  VectorDouble classClusterMean;
202  VectorDouble classClusterStdDev;
203  static RegisterClassifierModule< DecisionTree > registerModule;
204 
205 };
206 
207 } //End of namespace GRT
208 
209 #endif //GRT_DECISION_TREE_HEADER
210 
DecisionTree(const DecisionTreeNode &decisionTreeNode=DecisionTreeClusterNode(), const UINT minNumSamplesPerNode=5, const UINT maxDepth=10, const bool removeFeaturesAtEachSpilt=false, const UINT trainingMode=BEST_ITERATIVE_SPILT, const UINT numSplittingSteps=100, const bool useScaling=false)
virtual bool saveModelToFile(string filename) const
Definition: MLBase.cpp:135
This file implements a DecisionTreeTripleFeatureNode, which is a specific type of node used for a Dec...
Definition: Tree.h:38
virtual bool deepCopyFrom(const Classifier *classifier)
virtual bool print() const
Definition: MLBase.cpp:129
virtual bool loadModelFromFile(string filename)
Definition: MLBase.cpp:157
virtual ~DecisionTree(void)
Definition: AdaBoost.cpp:25
virtual bool getModel(ostream &stream) const
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:80
virtual bool recomputeNullRejectionThresholds()
virtual bool loadModelFromFile(fstream &file)
This file implements a DecisionTreeClusterNode, which is a specific type of node used for a DecisionT...
virtual bool train_(ClassificationData &trainingData)
bool loadLegacyModelFromFile_v1(fstream &file)
DecisionTreeNode * deepCopyTree() const
virtual bool predict(VectorDouble inputVector)
Definition: MLBase.cpp:104
bool setDecisionTreeNode(const DecisionTreeNode &node)
This file implements a DecisionTreeNode, which is a specific base node used for a DecisionTree...
DecisionTreeNode * deepCopyDecisionTreeNode() const
virtual bool clear()
DecisionTree & operator=(const DecisionTree &rhs)
virtual bool saveModelToFile(fstream &file) const
virtual bool predict_(VectorDouble &inputVector)
const DecisionTreeNode * getTree() const
This file implements a DecisionTreeThresholdNode, which is a specific type of node used for a Decisio...