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.
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 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 
101 
108 
115 
119  typedef std::map< std::string, Regressifier*(*)() > StringRegressifierMap;
120 
127  static Regressifier* createInstanceFromString( const std::string &regressifierType );
128 
135 
143  Regressifier* deepCopy() const;
144 
150  const Regressifier& getBaseRegressifier() const;
151 
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 
Vector< MinMax > getOutputRanges() const
std::map< std::string, Regressifier *(*)() > StringRegressifierMap
Definition: Regressifier.h:119
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:88
virtual bool reset()
Regressifier * createNewInstance() const
static Regressifier * createInstanceFromString(const std::string &regressifierType)
bool copyBaseVariables(const Regressifier *regressifier)
static Vector< std::string > getRegisteredRegressifiers()
virtual bool deepCopyFrom(const Regressifier *regressifier)
Definition: Regressifier.h:63
bool saveBaseSettingsToFile(std::fstream &file) const
This is the main base class that all GRT machine learning algorithms should inherit from...
std::string getRegressifierType() const
bool loadBaseSettingsFromFile(std::fstream &file)
Vector< MinMax > getInputRanges() const
Regressifier * deepCopy() const
virtual ~Regressifier(void)
Regressifier(void)
const Regressifier & getBaseRegressifier() const
VectorFloat getRegressionData() const
Definition: MLBase.h:70
virtual bool clear()