GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
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 namespace GRT{
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  string getRegressifierType() const;
94 
100  VectorDouble getRegressionData() const;
101 
107  vector< MinMax > getInputRanges() const;
108 
114  vector< MinMax > getOutputRanges() const;
115 
119  typedef std::map< string, Regressifier*(*)() > StringRegressifierMap;
120 
127  static Regressifier* createInstanceFromString(string const &regressifierType);
128 
135 
143  Regressifier* deepCopy() const;
144 
150  const Regressifier& getBaseRegressifier() const;
151 
157  static vector< 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(fstream &file) const;
169 
175  bool loadBaseSettingsFromFile(fstream &file);
176 
177  string regressifierType;
178  VectorDouble 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(string const &newRegresionModuleName) {
200  getMap()->insert( std::pair<string, Regressifier*(*)()>(newRegresionModuleName, &newRegressionModuleInstance< T > ) );
201  }
202 };
203 
204 } //End of namespace GRT
205 
206 #endif //GRT_REGRESSIFIER_HEADER
207 
static vector< string > getRegisteredRegressifiers()
static Regressifier * createInstanceFromString(string const &regressifierType)
bool copyBaseVariables(const Regressifier *regressifier)
vector< MinMax > getOutputRanges() const
VectorDouble getRegressionData() const
Definition: AdaBoost.cpp:25
vector< MinMax > getInputRanges() const
virtual ~Regressifier(void)
virtual bool reset()
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:80
bool loadBaseSettingsFromFile(fstream &file)
std::map< string, Regressifier *(*)() > StringRegressifierMap
Definition: Regressifier.h:119
bool saveBaseSettingsToFile(fstream &file) const
This is the main base class that all GRT machine learning algorithms should inherit from...
Regressifier * createNewInstance() const
Regressifier * deepCopy() const
string getRegressifierType() const
const Regressifier & getBaseRegressifier() const
virtual bool clear()
virtual bool deepCopyFrom(const Regressifier *regressifier)
Definition: Regressifier.h:63