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.
BAG.h
Go to the documentation of this file.
1 
37 #ifndef GRT_BAG_HEADER
38 #define GRT_BAG_HEADER
39 
40 #include "../../CoreModules/Classifier.h"
41 
42 GRT_BEGIN_NAMESPACE
43 
44 class BAG : public Classifier
45 {
46 public:
52  BAG(bool useScaling=false);
53 
59  BAG(const BAG &rhs);
60 
64  virtual ~BAG(void);
65 
72  BAG &operator=(const BAG &rhs);
73 
81  virtual bool deepCopyFrom(const Classifier *classifier);
82 
90  virtual bool train_(ClassificationData &trainingData);
91 
99  virtual bool predict_(VectorFloat &inputVector);
100 
106  virtual bool reset();
107 
114  virtual bool clear();
115 
123  virtual bool saveModelToFile( std::fstream &file ) const;
124 
132  virtual bool loadModelFromFile( std::fstream &file );
133 
139  UINT getEnsembleSize() const;
140 
147 
153  const Vector< Classifier* > getEnsemble() const;
154 
163  bool addClassifierToEnsemble(const Classifier &classifier,Float weight=1);
164 
170  bool clearEnsemble();
171 
182  bool setWeights(const VectorFloat &weights);
183 
184  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
187  using MLBase::train;
188  using MLBase::train_;
189  using MLBase::predict;
190  using MLBase::predict_;
191 
192 protected:
193  bool loadLegacyModelFromFile( std::fstream &file );
194 
195  VectorFloat weights;
196  Vector< Classifier* > ensemble;
197 
198  static RegisterClassifierModule< BAG > registerModule;
199 };
200 
201 GRT_END_NAMESPACE
202 
203 #endif //GRT_BAG_HEADER
Definition: BAG.h:44
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:112
const Vector< Classifier * > getEnsemble() const
Definition: BAG.cpp:417
VectorFloat getEnsembleWeights() const
Definition: BAG.cpp:413
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:114
virtual bool clear()
Definition: BAG.cpp:237
UINT getEnsembleSize() const
Definition: BAG.cpp:409
virtual bool reset()
Definition: BAG.cpp:225
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:88
BAG(bool useScaling=false)
Definition: BAG.cpp:28
virtual ~BAG(void)
Definition: BAG.cpp:52
virtual bool deepCopyFrom(const Classifier *classifier)
Definition: BAG.cpp:75
virtual bool saveModelToFile(std::fstream &file) const
Definition: BAG.cpp:252
virtual bool saveModelToFile(std::string filename) const
Definition: MLBase.cpp:146
bool addClassifierToEnsemble(const Classifier &classifier, Float weight=1)
Definition: BAG.cpp:421
virtual bool loadModelFromFile(std::string filename)
Definition: MLBase.cpp:168
virtual bool train_(ClassificationData &trainingData)
Definition: BAG.cpp:98
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:90
BAG & operator=(const BAG &rhs)
Definition: BAG.cpp:57
bool clearEnsemble()
Definition: BAG.cpp:441
virtual bool predict_(VectorFloat &inputVector)
Definition: BAG.cpp:159
virtual bool loadModelFromFile(std::fstream &file)
Definition: BAG.cpp:308
bool setWeights(const VectorFloat &weights)
Definition: BAG.cpp:456