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.
Regressifier.h
Go to the documentation of this file.
1 
31 #ifndef GRT_REGRESSIFIER_HEADER
32 #define GRT_REGRESSIFIER_HEADER
33 
34 #include "MLBase.h"
35 #include "../DataStructures/ClassificationData.h"
36 #include "../DataStructures/TimeSeriesClassificationData.h"
37 
38 GRT_BEGIN_NAMESPACE
39 
40 #define DEFAULT_NULL_LIKELIHOOD_VALUE 0
41 #define DEFAULT_NULL_DISTANCE_VALUE 0
42 
43 class GRT_API Regressifier : public MLBase
44 {
45 public:
49  Regressifier(void);
50 
54  virtual ~Regressifier(void);
55 
63  virtual bool deepCopyFrom(const Regressifier *regressifier){ return false; }
64 
71  bool copyBaseVariables(const Regressifier *regressifier);
72 
79  virtual bool reset();
80 
86  virtual bool clear();
87 
93  std::string getRegressifierType() const;
94 
100  VectorFloat getRegressionData() const;
101 
107  Vector< MinMax > getInputRanges() const;
108 
114  Vector< MinMax > getOutputRanges() const;
115 
119  typedef std::map< std::string, Regressifier*(*)() > StringRegressifierMap;
120 
127  static Regressifier* createInstanceFromString( const std::string &regressifierType );
128 
134  Regressifier* createNewInstance() const;
135 
143  Regressifier* deepCopy() const;
144 
150  const Regressifier& getBaseRegressifier() const;
151 
157  static Vector< std::string > getRegisteredRegressifiers();
158 
159  //Tell the compiler we are explicitly using the following classes from the base class (this stops hidden overloaded virtual function warnings)
160  using MLBase::train;
161 
162 protected:
168  bool saveBaseSettingsToFile( std::fstream &file ) const;
169 
175  bool loadBaseSettingsFromFile( std::fstream &file );
176 
177  std::string regressifierType;
178  VectorFloat regressionData;
179  Vector< MinMax > inputVectorRanges;
180  Vector< MinMax > targetVectorRanges;
181 
182  static StringRegressifierMap *getMap() {
183  if( !stringRegressifierMap ){ stringRegressifierMap = new StringRegressifierMap; }
184  return stringRegressifierMap;
185  }
186 
187 private:
188  static StringRegressifierMap *stringRegressifierMap;
189  static UINT numRegressifierInstances;
190 
191 };
192 
193 //These two functions/classes are used to register any new Regression Module with the Regressifier base class
194 template< typename T > Regressifier *newRegressionModuleInstance() { return new T; }
195 
196 template< typename T >
198 public:
199  RegisterRegressifierModule( const std::string &newRegresionModuleName ) {
200  getMap()->insert( std::pair< std::string, Regressifier*(*)() >(newRegresionModuleName, &newRegressionModuleInstance< T > ) );
201  }
202 };
203 
204 GRT_END_NAMESPACE
205 
206 #endif //GRT_REGRESSIFIER_HEADER
207 
bool saveBaseSettingsToFile(std::fstream &file) const
Definition: MLBase.cpp:375
std::map< std::string, Regressifier *(*)() > StringRegressifierMap
Definition: Regressifier.h:119
virtual bool reset()
Definition: MLBase.cpp:125
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:89
virtual bool deepCopyFrom(const Regressifier *regressifier)
Definition: Regressifier.h:63
This is the main base class that all GRT machine learning algorithms should inherit from...
bool loadBaseSettingsFromFile(std::fstream &file)
Definition: MLBase.cpp:398
virtual bool clear()
Definition: MLBase.cpp:127
Definition: MLBase.h:70