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.
TimeSeriesClassificationDataStream.h
Go to the documentation of this file.
1 
31 #ifndef GRT_TIME_SERIES_CLASSIFICATION_DATA_STREAM_HEADER
32 #define GRT_TIME_SERIES_CLASSIFICATION_DATA_STREAM_HEADER
33 
34 #include "../Util/GRTCommon.h"
36 #include "ClassificationData.h"
38 
39 namespace GRT{
40 
42 public:
43 
52  TimeSeriesClassificationDataStream(const UINT numDimensions=0,const string datasetName = "NOT_SET",const string infoText = "");
53 
60 
65 
73 
81  inline ClassificationSample& operator[] (const UINT i){
82  return data[i];
83  }
84 
88  void clear();
89 
100  bool setNumDimensions(const UINT numDimensions);
101 
109  bool setDatasetName(const string datasetName);
110 
118  bool setInfoText(const string infoText);
119 
127  bool setClassNameForCorrespondingClassLabel(const string className,const UINT classLabel);
128 
138  bool addSample(const UINT classLabel,const VectorDouble &trainingSample);
139 
145  bool removeLastSample();
146 
153  UINT eraseAllSamplesWithClassLabel(const UINT classLabel);
154 
162  bool relabelAllSamplesWithClassLabel(const UINT oldClassLabel,const UINT newClassLabel);
163 
172  bool setExternalRanges(const vector< MinMax > &externalRanges,const bool useExternalRanges = false);
173 
182 
190  bool scale(const double minTarget,const double maxTarget);
191 
200  bool scale(const vector<MinMax> &ranges,const double minTarget,const double maxTarget);
201 
208  bool resetPlaybackIndex(const UINT playbackIndex);
209 
217 
225 
234  bool save(const string &filename);
235 
244  bool load(const string &filename);
245 
252  bool saveDatasetToFile(const string &filename);
253 
261  bool saveDatasetToCSVFile(const string &filename);
262 
269  bool loadDatasetFromFile(const string &filename);
270 
281  bool loadDatasetFromCSVFile(const string &filename,const UINT classLabelColumnIndex=0);
282 
289  bool printStats() const;
290 
296  string getDatasetName() const { return datasetName; }
297 
303  string getInfoText() const { return infoText; }
304 
310  UINT inline getNumDimensions() const { return numDimensions; }
311 
317  UINT inline getNumSamples() const { return totalNumSamples; }
318 
324  UINT inline getNumClasses() const { return (UINT)classTracker.size(); }
325 
331  UINT getMinimumClassLabel() const;
332 
338  UINT getMaximumClassLabel() const;
339 
345  UINT getClassLabelIndexValue(const UINT classLabel) const;
346 
352  string getClassNameForCorrespondingClassLabel(const UINT classLabel);
353 
359  vector<MinMax> getRanges() const;
360 
366  vector< ClassTracker > getClassTracker() const { return classTracker; }
367 
373  vector< TimeSeriesPositionTracker > getTimeSeriesPositionTracker() const { return timeSeriesPositionTracker; }
374 
380  vector< ClassificationSample > getClassificationSamples() const { return data; }
381 
391  TimeSeriesClassificationDataStream getSubset(const UINT startIndex,const UINT endIndex) const;
392 
401  TimeSeriesClassificationData getTimeSeriesClassificationData( const bool includeNullGestures = false ) const;
402 
411  ClassificationData getClassificationData( const bool includeNullGestures = false ) const;
412 
423  MatrixDouble getTimeSeriesData( const TimeSeriesPositionTracker &trackerInfo ) const;
424 
432 
438  vector< UINT > getClassLabels() const;
439 
440 protected:
441  string datasetName;
442  string infoText;
444  UINT totalNumSamples;
445  UINT lastClassID;
446  UINT playbackIndex;
447  bool trackingClass;
449  vector< MinMax > externalRanges;
450  vector< ClassTracker > classTracker;
451  vector< ClassificationSample > data;
452  vector< TimeSeriesPositionTracker > timeSeriesPositionTracker;
453 
457 };
458 
459 } //End of namespace GRT
460 
461 #endif //GRT_TIME_SERIES_CLASSIFICATION_DATA_STREAM_HEADER
462 
TimeSeriesClassificationDataStream getSubset(const UINT startIndex, const UINT endIndex) const
The ClassificationData is the main data structure for recording, labeling, managing, saving, and loading training data for supervised learning problems.
vector< MinMax > externalRanges
A vector containing a set of externalRanges set by the user.
MatrixDouble getTimeSeriesData(const TimeSeriesPositionTracker &trackerInfo) const
This class can be used to track the class label, start and end indexs for labelled data...
TimeSeriesClassificationDataStream(const UINT numDimensions=0, const string datasetName="NOT_SET", const string infoText="")
Definition: AdaBoost.cpp:25
vector< ClassificationSample > getClassificationSamples() const
bool setExternalRanges(const vector< MinMax > &externalRanges, const bool useExternalRanges=false)
TimeSeriesClassificationData getTimeSeriesClassificationData(const bool includeNullGestures=false) const
TimeSeriesClassificationData getAllTrainingExamplesWithClassLabel(const UINT classLabel) const
bool useExternalRanges
A flag to show if the dataset should be scaled using the externalRanges values.
UINT numDimensions
The number of dimensions in the dataset.
TimeSeriesClassificationDataStream & operator=(const TimeSeriesClassificationDataStream &rhs)
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.
bool enableExternalRangeScaling(const bool useExternalRanges)
bool relabelAllSamplesWithClassLabel(const UINT oldClassLabel, const UINT newClassLabel)
bool scale(const double minTarget, const double maxTarget)
vector< TimeSeriesPositionTracker > getTimeSeriesPositionTracker() const
bool setClassNameForCorrespondingClassLabel(const string className, const UINT classLabel)
bool addSample(const UINT classLabel, const VectorDouble &trainingSample)
string infoText
Some infoText about the dataset.
bool loadDatasetFromCSVFile(const string &filename, const UINT classLabelColumnIndex=0)
ClassificationData getClassificationData(const bool includeNullGestures=false) const