GestureRecognitionToolkit  Version: 0.2.5
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:
50  Regressifier( const std::string &id = "" );
51 
55  virtual ~Regressifier(void);
56 
64  virtual bool deepCopyFrom(const Regressifier *regressifier){ return false; }
65 
72  bool copyBaseVariables(const Regressifier *regressifier);
73 
80  virtual bool reset() override;
81 
87  virtual bool clear() override;
88 
94  VectorFloat getRegressionData() const;
95 
101  Vector< MinMax > getInputRanges() const;
102 
108  Vector< MinMax > getOutputRanges() const;
109 
113  typedef std::map< std::string, Regressifier*(*)() > StringRegressifierMap;
114 
122  Regressifier* deepCopy() const;
123 
129  const Regressifier& getBaseRegressifier() const;
130 
136  static Vector< std::string > getRegisteredRegressifiers();
137 
144  static Regressifier* create( const std::string &id );
145 
151  Regressifier* create() const;
152 
153  GRT_DEPRECATED_MSG( "createNewInstance is deprecated, use create() instead.", Regressifier* createNewInstance() const );
154  GRT_DEPRECATED_MSG( "createInstanceFromString(id) is deprecated, use create(id) instead.", static Regressifier* createInstanceFromString( const std::string &id ) );
155  GRT_DEPRECATED_MSG( "getRegressifierType is deprecated, use getId() instead", std::string getRegressifierType() const );
156 
157 protected:
163  bool saveBaseSettingsToFile( std::fstream &file ) const;
164 
170  bool loadBaseSettingsFromFile( std::fstream &file );
171 
172  std::string regressifierType;
173  VectorFloat regressionData;
174  Vector< MinMax > inputVectorRanges;
175  Vector< MinMax > targetVectorRanges;
176 
177  static StringRegressifierMap *getMap() {
178  if( !stringRegressifierMap ){ stringRegressifierMap = new StringRegressifierMap; }
179  return stringRegressifierMap;
180  }
181 
182 private:
183  static StringRegressifierMap *stringRegressifierMap;
184  static UINT numRegressifierInstances;
185 
186 };
187 
188 template< typename T >
190 
195 template< typename T >
197 public:
198  RegisterRegressifierModule( const std::string &newRegresionModuleName ) {
199  getMap()->insert( std::pair< std::string, Regressifier*(*)() >(newRegresionModuleName, &createNewRegressionInstance< T > ) );
200  }
201 };
202 
203 GRT_END_NAMESPACE
204 
205 #endif //GRT_REGRESSIFIER_HEADER
206 
bool saveBaseSettingsToFile(std::fstream &file) const
Definition: MLBase.cpp:435
std::map< std::string, Regressifier *(*)() > StringRegressifierMap
Definition: Regressifier.h:113
virtual bool reset()
Definition: MLBase.cpp:147
Regressifier * createNewRegressionInstance()
Returns a pointer to a new instance of the template class, the caller is responsible for deleting the...
Definition: Regressifier.h:189
This class provides an interface for classes to register themselves with the regressifier base class...
Definition: Regressifier.h:196
virtual bool deepCopyFrom(const Regressifier *regressifier)
Definition: Regressifier.h:64
bool loadBaseSettingsFromFile(std::fstream &file)
Definition: MLBase.cpp:458
virtual bool clear()
Definition: MLBase.cpp:149
GRT_DEPRECATED_MSG("saveModelToFile(std::string filename) is deprecated, use save(const std::string &filename) instead", virtual bool saveModelToFile(const std::string &filename) const )
This is the main base class that all GRT machine learning algorithms should inherit from...
Definition: MLBase.h:72