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.
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 GRT_BEGIN_NAMESPACE
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_(VectorFloat &inputVector);
109 
116  virtual bool clear();
117 
124  virtual bool recomputeNullRejectionThresholds();
125 
133  virtual bool saveModelToFile( std::fstream &file ) const;
134 
142  virtual bool loadModelFromFile( std::fstream &file );
143 
151  virtual bool getModel( std::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( std::fstream &file );
192  bool loadLegacyModelFromFile_v2( std::fstream &file );
193  bool loadLegacyModelFromFile_v3( std::fstream &file );
194 
195  DecisionTreeNode* buildTree(ClassificationData &trainingData, DecisionTreeNode *parent, Vector< UINT > features, const Vector< UINT > &classLabels, UINT nodeID );
196  Float getNodeDistance( const VectorFloat &x, const UINT nodeID );
197  Float getNodeDistance( const VectorFloat &x, const VectorFloat &y );
198 
199  DecisionTreeNode* decisionTreeNode;
200  std::map< UINT, VectorFloat > nodeClusters;
201  VectorFloat classClusterMean;
202  VectorFloat classClusterStdDev;
203  static RegisterClassifierModule< DecisionTree > registerModule;
204 
205 };
206 
207 GRT_END_NAMESPACE
208 
209 #endif //GRT_DECISION_TREE_HEADER
210 
virtual bool saveModelToFile(std::fstream &file) const
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:112
This file implements a DecisionTreeTripleFeatureNode, which is a specific type of node used for a Dec...
const DecisionTreeNode * getTree() const
DecisionTreeNode * deepCopyDecisionTreeNode() const
bool loadLegacyModelFromFile_v1(std::fstream &file)
virtual bool train_(ClassificationData &trainingData)
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:88
virtual bool predict_(VectorFloat &inputVector)
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 deepCopyFrom(const Classifier *classifier)
This file implements a DecisionTreeClusterNode, which is a specific type of node used for a DecisionT...
DecisionTreeNode * deepCopyTree() const
virtual bool recomputeNullRejectionThresholds()
Definition: Tree.h:38
virtual bool clear()
virtual bool saveModelToFile(std::string filename) const
Definition: MLBase.cpp:146
virtual bool print() const
Definition: MLBase.cpp:140
virtual bool loadModelFromFile(std::fstream &file)
This file implements a DecisionTreeNode, which is a specific base node used for a DecisionTree...
virtual bool loadModelFromFile(std::string filename)
Definition: MLBase.cpp:168
DecisionTree & operator=(const DecisionTree &rhs)
bool setDecisionTreeNode(const DecisionTreeNode &node)
virtual ~DecisionTree(void)
virtual bool getModel(std::ostream &stream) const
This file implements a DecisionTreeThresholdNode, which is a specific type of node used for a Decisio...