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.
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 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
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 
const ClusterTreeNode * getTree() const
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:112
virtual bool train_(MatrixFloat &trainingData)
bool setMinRMSErrorPerNode(const Float minRMSErrorPerNode)
virtual ~ClusterTree(void)
Definition: ClusterTree.cpp:60
virtual bool saveModelToFile(std::fstream &file) const
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:88
ClusterTreeNode * deepCopyTree() const
Definition: Tree.h:38
This file implements a ClusterTreeNode, which is a specific type of node used for a ClusterTree...
virtual bool saveModelToFile(std::string filename) const
Definition: MLBase.cpp:146
ClusterTree & operator=(const ClusterTree &rhs)
Definition: ClusterTree.cpp:65
virtual bool loadModelFromFile(std::string filename)
Definition: MLBase.cpp:168
virtual bool deepCopyFrom(const Clusterer *cluster)
Definition: ClusterTree.cpp:89
virtual bool predict_(VectorFloat &inputVector)
virtual bool clear()
virtual bool print() const
virtual bool loadModelFromFile(std::fstream &file)
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)
Definition: ClusterTree.cpp:31
UINT getPredictedClusterLabel() const
Float getMinRMSErrorPerNode() const