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.
TimeSeriesClassificationData.h
Go to the documentation of this file.
1 
31 #ifndef GRT_TIME_SERIES_CLASSIFICATION_DATA_HEADER
32 #define GRT_TIME_SERIES_CLASSIFICATION_DATA_HEADER
33 
34 #include "VectorFloat.h"
35 #include "MatrixFloat.h"
36 #include "../Util/GRTCommon.h"
38 #include "UnlabelledData.h"
39 
40 GRT_BEGIN_NAMESPACE
41 
43 public:
44 
53  TimeSeriesClassificationData(UINT numDimensions = 0,std::string datasetName = "NOT_SET",std::string infoText = "");
54 
61 
66 
74 
82  inline TimeSeriesClassificationSample& operator[] (const UINT &i){
83  return data[i];
84  }
85 
93  inline const TimeSeriesClassificationSample& 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 setAllowNullGestureClass(const bool allowNullGestureClass);
154 
164  bool addSample(const UINT classLabel,const MatrixFloat &trainingSample);
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 
236  bool save(const std::string &filename) const;
237 
246  bool load(const std::string &filename);
247 
254  bool saveDatasetToFile(const std::string filename) const;
255 
262  bool loadDatasetFromFile(const std::string filename);
263 
271  bool saveDatasetToCSVFile(const std::string &filename) const;
272 
282  bool loadDatasetFromCSVFile(const std::string &filename);
283 
290  bool printStats() const;
291 
298  std::string getStatsAsString() const;
299 
306  GRT_DEPRECATED_MSG( "partition(...) is deprecated, use split(...) instead", TimeSeriesClassificationData partition(const UINT partitionPercentage,const bool useStratifiedSampling = false) );
307 
316  TimeSeriesClassificationData split(const UINT partitionPercentage,const bool useStratifiedSampling = false);
317 
326  bool merge(const TimeSeriesClassificationData &labelledData);
327 
335  bool spiltDataIntoKFolds(const UINT K, const bool useStratifiedSampling = false);
336 
344  TimeSeriesClassificationData getTrainingFoldData(const UINT foldIndex) const;
345 
353  TimeSeriesClassificationData getTestFoldData(const UINT foldIndex) const;
354 
362  TimeSeriesClassificationData getClassData(const UINT classLabel) const;
363 
369  UnlabelledData reformatAsUnlabelledData() const;
370 
376  std::string getDatasetName() const { return datasetName; }
377 
383  std::string getInfoText() const { return infoText; }
384 
390  UINT inline getNumDimensions() const { return numDimensions; }
391 
397  UINT inline getNumSamples() const { return totalNumSamples; }
398 
404  UINT inline getNumClasses() const { return classTracker.getSize(); }
405 
411  UINT getMinimumClassLabel() const;
412 
418  UINT getMaximumClassLabel() const;
419 
425  UINT getClassLabelIndexValue(const UINT classLabel) const;
426 
432  std::string getClassNameForCorrespondingClassLabel(const UINT classLabel) const;
433 
439  Vector<MinMax> getRanges() const;
440 
446  Vector< ClassTracker > getClassTracker() const { return classTracker; }
447 
454 
461  MatrixFloat getDataAsMatrixFloat() const;
462 
463 protected:
464 
465  std::string datasetName;
466  std::string infoText;
469  UINT kFoldValue;
477 
481 
482 };
483 
484 GRT_END_NAMESPACE
485 
486 #endif //GRT_LABELLED_TIME_SERIES_CLASSIFICATION_DATA_HEADER
487 
UINT numDimensions
The number of dimensions in the dataset.
Vector< MinMax > externalRanges
A vector containing a set of externalRanges set by the user.
Vector< TimeSeriesClassificationSample > data
The labelled time series classification data.
UINT kFoldValue
The number of folds the dataset has been spilt into for cross valiation.
bool useExternalRanges
A flag to show if the dataset should be scaled using the externalRanges values.
The UnlabelledData class is the main data container for supporting unsupervised learning.
UINT totalNumSamples
The total number of samples in the dataset.
Vector< ClassTracker > getClassTracker() const
WarningLog warningLog
Default warning log.
This class stores the timeseries data for a single labelled timeseries classification sample...
bool allowNullGestureClass
A flag that enables/disables a user from adding new samples with a class label matching the default n...
DebugLog debugLog
Default debugging log.
bool crossValidationSetup
A flag to show if the dataset is ready for cross validation.
std::string datasetName
The name of the dataset.
ErrorLog errorLog
Default error log.
Vector< ClassTracker > classTracker
A vector of ClassTracker, which keeps track of the number of samples of each class.
std::string infoText
Some infoText about the dataset.
Vector< TimeSeriesClassificationSample > getClassificationData() const
Vector< Vector< UINT > > crossValidationIndexs
A vector to hold the indexs of the dataset for the cross validation.