GestureRecognitionToolkit  Version: 0.2.0
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 GRT_BEGIN_NAMESPACE
39 
40 class GRT_API 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 Float 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_(MatrixFloat &trainingData);
93 
101  virtual bool predict_(VectorFloat &inputVector);
102 
109  virtual bool clear();
110 
116  virtual bool print() const;
117 
125  virtual bool saveModelToFile( std::fstream &file ) const;
126 
134  virtual bool loadModelFromFile( std::fstream &file );
135 
143  ClusterTreeNode* deepCopyTree() const;
144 
150  const ClusterTreeNode* getTree() const;
151 
158  UINT getPredictedClusterLabel() const;
159 
166  Float getMinRMSErrorPerNode() const;
167 
173  bool setMinRMSErrorPerNode(const Float minRMSErrorPerNode);
174 
175  //Tell the compiler we are using the base class train method to stop hidden virtual function warnings
176  using MLBase::saveModelToFile;
177  using MLBase::loadModelFromFile;
178  using MLBase::train;
179  using MLBase::predict;
180 
181 protected:
182  Float minRMSErrorPerNode;
183 
184  ClusterTreeNode* buildTree( const MatrixFloat &trainingData, ClusterTreeNode *parent, Vector< UINT > features, UINT &clusterLabel, UINT nodeID );
185  bool computeBestSpilt( const MatrixFloat &trainingData, const Vector< UINT > &features, UINT &featureIndex, Float &threshold, Float &minError );
186  bool computeBestSpiltBestIterativeSpilt( const MatrixFloat &trainingData, const Vector< UINT > &features, UINT &featureIndex, Float &threshold, Float &minError );
187  bool computeBestSpiltBestRandomSpilt( const MatrixFloat &trainingData, const Vector< UINT > &features, UINT &featureIndex, Float &threshold, Float &minError );
188 
189  static RegisterClustererModule< ClusterTree > registerModule;
190 
191 };
192 
193 GRT_END_NAMESPACE
194 
195 #endif //GRT_CLUSTER_TREE_HEADER
196 
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:113
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:115
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:89
virtual bool deepCopyFrom(const Clusterer *clusterer)
Definition: Clusterer.h:58
Definition: Tree.h:38
This file implements a ClusterTreeNode, which is a specific type of node used for a ClusterTree...
virtual bool print() const
Definition: MLBase.cpp:141
const Node * getTree() const
Definition: Tree.cpp:88
UINT getPredictedClusterLabel() const
Definition: Clusterer.cpp:237
virtual Node * deepCopyTree() const
Definition: Tree.cpp:79
virtual bool train_(MatrixFloat &trainingData)
Definition: Clusterer.cpp:114
virtual bool clear()
Definition: Clusterer.cpp:142