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.
RegressionTree.h
Go to the documentation of this file.
1 
31 #ifndef GRT_REGRESSION_TREE_HEADER
32 #define GRT_REGRESSION_TREE_HEADER
33 
34 #include "../../CoreModules/Regressifier.h"
35 #include "../../CoreAlgorithms/Tree/Tree.h"
36 #include "RegressionTreeNode.h"
37 
38 GRT_BEGIN_NAMESPACE
39 
40 class RegressionTree : public Tree, public Regressifier
41 {
42 public:
54  RegressionTree(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  RegressionTree(const RegressionTree &rhs);
62 
66  virtual ~RegressionTree(void);
67 
75 
83  virtual bool deepCopyFrom(const Regressifier *regressifier);
84 
92  virtual bool train_(RegressionData &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 
144 
150  const RegressionTreeNode* getTree() const;
151 
158  Float getMinRMSErrorPerNode() const;
159 
166  bool setMinRMSErrorPerNode(const Float minRMSErrorPerNode);
167 
168  //Tell the compiler we are using the base class train method to stop hidden virtual function warnings
171  using MLBase::train;
172  using MLBase::predict;
173 
174 protected:
176 
177  RegressionTreeNode* buildTree( const RegressionData &trainingData, RegressionTreeNode *parent, Vector< UINT > features, UINT nodeID );
178  bool computeBestSpilt( const RegressionData &trainingData, const Vector< UINT > &features, UINT &featureIndex, Float &threshold, Float &minError );
179  bool computeBestSpiltBestIterativeSpilt( const RegressionData &trainingData, const Vector< UINT > &features, UINT &featureIndex, Float &threshold, Float &minError );
180  //bool computeBestSpiltBestRandomSpilt( const RegressionData &trainingData, const Vector< UINT > &features, const Vector< UINT > &classLabels, UINT &featureIndex, Float &threshold, Float &minError );
181  bool computeNodeRegressionData( const RegressionData &trainingData, VectorFloat &regressionData );
182 
183  static RegisterRegressifierModule< RegressionTree > registerModule;
184 
185 };
186 
187 GRT_END_NAMESPACE
188 
189 #endif //GRT_REGRESSION_TREE_HEADER
190 
virtual bool loadModelFromFile(std::fstream &file)
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:112
Float getMinRMSErrorPerNode() const
Float minRMSErrorPerNode
virtual bool train_(RegressionData &trainingData)
const RegressionTreeNode * getTree() const
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:88
This file implements a RegressionTreeNode, which is a specific type of node used for a RegressionTree...
virtual bool clear()
Definition: Tree.h:38
bool setMinRMSErrorPerNode(const Float minRMSErrorPerNode)
virtual bool saveModelToFile(std::fstream &file) const
virtual bool saveModelToFile(std::string filename) const
Definition: MLBase.cpp:146
virtual bool deepCopyFrom(const Regressifier *regressifier)
RegressionTree & operator=(const RegressionTree &rhs)
virtual bool loadModelFromFile(std::string filename)
Definition: MLBase.cpp:168
RegressionTreeNode * deepCopyTree() const
virtual bool predict_(VectorFloat &inputVector)
RegressionTree(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)
virtual ~RegressionTree(void)
virtual bool print() const