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.
ClusterTree.h
Go to the documentation of this file.
1 
31 #ifndef GRT_CLUSTER_TREE_HEADER
32 #define GRT_CLUSTER_TREE_HEADER
33 
34 #include "../../CoreModules/Clusterer.h"
35 #include "../../CoreAlgorithms/Tree/Tree.h"
36 #include "ClusterTreeNode.h"
37 
38 namespace GRT{
39 
40 class ClusterTree : public Tree, public Clusterer
41 {
42 public:
54  ClusterTree(const UINT numSplittingSteps=100,const UINT minNumSamplesPerNode=5,const UINT maxDepth=10,const bool removeFeaturesAtEachSpilt = false,const UINT trainingMode = BEST_ITERATIVE_SPILT,const bool useScaling=false,const double minRMSErrorPerNode = 0.01);
55 
61  ClusterTree(const ClusterTree &rhs);
62 
66  virtual ~ClusterTree(void);
67 
74  ClusterTree &operator=(const ClusterTree &rhs);
75 
83  virtual bool deepCopyFrom(const Clusterer *cluster);
84 
92  virtual bool train_(MatrixDouble &trainingData);
93 
101  virtual bool predict_(VectorDouble &inputVector);
102 
109  virtual bool clear();
110 
116  virtual bool print() const;
117 
125  virtual bool saveModelToFile(fstream &file) const;
126 
134  virtual bool loadModelFromFile(fstream &file);
135 
143  ClusterTreeNode* deepCopyTree() const;
144 
150  const ClusterTreeNode* getTree() const;
151 
158  UINT getPredictedClusterLabel() const;
159 
166  double getMinRMSErrorPerNode() const;
167 
173  bool setMinRMSErrorPerNode(const double minRMSErrorPerNode);
174 
175  //Tell the compiler we are using the base class train method to stop hidden virtual function warnings
178  using MLBase::train;
179  using MLBase::predict;
180 
181 protected:
182  double minRMSErrorPerNode;
183 
184  ClusterTreeNode* buildTree( const MatrixDouble &trainingData, ClusterTreeNode *parent, vector< UINT > features, UINT &clusterLabel, UINT nodeID );
185  bool computeBestSpilt( const MatrixDouble &trainingData, const vector< UINT > &features, UINT &featureIndex, double &threshold, double &minError );
186  bool computeBestSpiltBestIterativeSpilt( const MatrixDouble &trainingData, const vector< UINT > &features, UINT &featureIndex, double &threshold, double &minError );
187  bool computeBestSpiltBestRandomSpilt( const MatrixDouble &trainingData, const vector< UINT > &features, UINT &featureIndex, double &threshold, double &minError );
188 
189  static RegisterClustererModule< ClusterTree > registerModule;
190 
191 };
192 
193 } //End of namespace GRT
194 
195 #endif //GRT_CLUSTER_TREE_HEADER
196 
virtual bool train_(MatrixDouble &trainingData)
virtual bool saveModelToFile(string filename) const
Definition: MLBase.cpp:135
virtual bool loadModelFromFile(fstream &file)
Definition: Tree.h:38
virtual bool saveModelToFile(fstream &file) const
virtual bool loadModelFromFile(string filename)
Definition: MLBase.cpp:157
virtual ~ClusterTree(void)
Definition: ClusterTree.cpp:60
ClusterTreeNode * deepCopyTree() const
Definition: AdaBoost.cpp:25
ClusterTree(const UINT numSplittingSteps=100, const UINT minNumSamplesPerNode=5, const UINT maxDepth=10, const bool removeFeaturesAtEachSpilt=false, const UINT trainingMode=BEST_ITERATIVE_SPILT, const bool useScaling=false, const double minRMSErrorPerNode=0.01)
Definition: ClusterTree.cpp:31
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:80
virtual bool deepCopyFrom(const Clusterer *cluster)
Definition: ClusterTree.cpp:89
ClusterTree & operator=(const ClusterTree &rhs)
Definition: ClusterTree.cpp:65
UINT getPredictedClusterLabel() const
This file implements a ClusterTreeNode, which is a specific type of node used for a ClusterTree...
virtual bool predict(VectorDouble inputVector)
Definition: MLBase.cpp:104
virtual bool clear()
bool setMinRMSErrorPerNode(const double minRMSErrorPerNode)
virtual bool print() const
const ClusterTreeNode * getTree() const
double getMinRMSErrorPerNode() const
virtual bool predict_(VectorDouble &inputVector)