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.
ClassificationDataStream.h
Go to the documentation of this file.
1 
32 #ifndef GRT_CLASSIFICATION_DATA_STREAM_HEADER
33 #define GRT_CLASSIFICATION_DATA_STREAM_HEADER
34 
35 #include "../Util/GRTCommon.h"
37 #include "ClassificationData.h"
39 
40 GRT_BEGIN_NAMESPACE
41 
43 public:
44 
53  ClassificationDataStream(const UINT numDimensions=0,const std::string datasetName = "NOT_SET",const std::string infoText = "");
54 
61 
65  virtual ~ClassificationDataStream();
66 
73  ClassificationDataStream& operator= (const ClassificationDataStream &rhs);
74 
82  inline ClassificationSample& operator[] (const UINT i){
83  return data[i];
84  }
85 
93  inline const ClassificationSample& operator[] (const UINT i) const {
94  return data[i];
95  }
96 
100  void clear();
101 
112  bool setNumDimensions(const UINT numDimensions);
113 
122  bool setDatasetName(const std::string datasetName);
123 
131  bool setInfoText(const std::string infoText);
132 
142  bool setClassNameForCorrespondingClassLabel(const std::string className,const UINT classLabel);
143 
153  bool addSample(const UINT classLabel,const VectorFloat &sample);
154 
164  bool addSample(const UINT classLabel,const MatrixFloat &sample);
165 
171  bool removeLastSample();
172 
179  UINT eraseAllSamplesWithClassLabel(const UINT classLabel);
180 
188  bool relabelAllSamplesWithClassLabel(const UINT oldClassLabel,const UINT newClassLabel);
189 
198  bool setExternalRanges(const Vector< MinMax > &externalRanges,const bool useExternalRanges = false);
199 
207  bool enableExternalRangeScaling(const bool useExternalRanges);
208 
216  bool scale(const Float minTarget,const Float maxTarget);
217 
226  bool scale(const Vector<MinMax> &ranges,const Float minTarget,const Float maxTarget);
227 
234  bool resetPlaybackIndex(const UINT playbackIndex);
235 
242  ClassificationSample getNextSample();
243 
250  TimeSeriesClassificationData getAllTrainingExamplesWithClassLabel(const UINT classLabel) const;
251 
260  bool save(const std::string &filename);
261 
270  bool load(const std::string &filename);
271 
278  bool saveDatasetToFile(const std::string &filename);
279 
287  bool saveDatasetToCSVFile(const std::string &filename);
288 
295  bool loadDatasetFromFile(const std::string &filename);
296 
307  bool loadDatasetFromCSVFile(const std::string &filename,const UINT classLabelColumnIndex=0);
308 
315  bool printStats() const;
316 
322  std::string getDatasetName() const { return datasetName; }
323 
329  std::string getInfoText() const { return infoText; }
330 
336  UINT inline getNumDimensions() const { return numDimensions; }
337 
343  UINT inline getNumSamples() const { return totalNumSamples; }
344 
350  UINT inline getNumClasses() const { return (UINT)classTracker.size(); }
351 
357  UINT getMinimumClassLabel() const;
358 
364  UINT getMaximumClassLabel() const;
365 
371  UINT getClassLabelIndexValue(const UINT classLabel) const;
372 
378  std::string getClassNameForCorrespondingClassLabel(const UINT classLabel);
379 
385  Vector<MinMax> getRanges() const;
386 
392  Vector< ClassTracker > getClassTracker() const { return classTracker; }
393 
399  Vector< TimeSeriesPositionTracker > getTimeSeriesPositionTracker() const { return timeSeriesPositionTracker; }
400 
406  std::deque< ClassificationSample > getClassificationSamples() const { return data; }
407 
417  ClassificationDataStream getSubset(const UINT startIndex,const UINT endIndex) const;
418 
427  TimeSeriesClassificationData getTimeSeriesClassificationData( const bool includeNullGestures = false ) const;
428 
437  ClassificationData getClassificationData( const bool includeNullGestures = false ) const;
438 
449  MatrixFloat getTimeSeriesData( const TimeSeriesPositionTracker &trackerInfo ) const;
450 
457  MatrixFloat getDataAsMatrixFloat() const;
458 
464  Vector< UINT > getClassLabels() const;
465 
466 protected:
467  std::string datasetName;
468  std::string infoText;
470  UINT totalNumSamples;
471  UINT lastClassID;
472  UINT playbackIndex;
473  bool trackingClass;
476  Vector< ClassTracker > classTracker;
477  std::deque< ClassificationSample > data;
478  Vector< TimeSeriesPositionTracker > timeSeriesPositionTracker;
479 
483 };
484 
485 GRT_END_NAMESPACE
486 
487 #endif //GRT_TIME_SERIES_CLASSIFICATION_DATA_STREAM_HEADER
488 
Vector< TimeSeriesPositionTracker > getTimeSeriesPositionTracker() const
The ClassificationData is the main data structure for recording, labeling, managing, saving, and loading training data for supervised learning problems.
This class can be used to track the class label, start and end indexs for labelled data...
DebugLog debugLog
Default debugging log.
ErrorLog errorLog
Default error log.
bool useExternalRanges
A flag to show if the dataset should be scaled using the externalRanges values.
Vector< MinMax > externalRanges
A Vector containing a set of externalRanges set by the user.
The TimeSeriesClassificationData is the main data structure for recording, labeling, managing, saving, and loading training data for supervised temporal learning problems. Unlike the ClassificationData, in which each sample consists of 1 N dimensional datum, a TimeSeriesClassificationData sample will consist of an N dimensional time series of length M. The length of each time series sample (i.e. M) can be different for each datum in the dataset.
std::string infoText
Some infoText about the dataset.
UINT numDimensions
The number of dimensions in the dataset.
std::string datasetName
The name of the dataset.
Vector< ClassTracker > getClassTracker() const
std::deque< ClassificationSample > getClassificationSamples() const
WarningLog warningLog
Default warning log.
std::string getDatasetName() const