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.
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 "../Util/GRTCommon.h"
36 #include "UnlabelledData.h"
37 
38 namespace GRT{
39 
41 public:
42 
51  TimeSeriesClassificationData(UINT numDimensions = 0,string datasetName = "NOT_SET",string infoText = "");
52 
59 
64 
72 
81  return data[i];
82  }
83 
91  inline const TimeSeriesClassificationSample& operator[] (const UINT &i) const{
92  return data[i];
93  }
94 
98  void clear();
99 
110  bool setNumDimensions(const UINT numDimensions);
111 
120  bool setDatasetName(const string datasetName);
121 
129  bool setInfoText(const string infoText);
130 
140  bool setClassNameForCorrespondingClassLabel(const string className,const UINT classLabel);
141 
152 
162  bool addSample(const UINT classLabel,const MatrixDouble &trainingSample);
163 
169  bool removeLastSample();
170 
177  UINT eraseAllSamplesWithClassLabel(const UINT classLabel);
178 
186  bool relabelAllSamplesWithClassLabel(const UINT oldClassLabel,const UINT newClassLabel);
187 
196  bool setExternalRanges(const vector< MinMax > &externalRanges,const bool useExternalRanges = false);
197 
206 
214  bool scale(const double minTarget,const double maxTarget);
215 
224  bool scale(const vector<MinMax> &ranges,const double minTarget,const double maxTarget);
225 
234  bool save(const string &filename) const;
235 
244  bool load(const string &filename);
245 
252  bool saveDatasetToFile(const string filename) const;
253 
260  bool loadDatasetFromFile(const string filename);
261 
269  bool saveDatasetToCSVFile(const string &filename) const;
270 
280  bool loadDatasetFromCSVFile(const string &filename);
281 
288  bool printStats() const;
289 
296  std::string getStatsAsString() const;
297 
306  TimeSeriesClassificationData partition(const UINT partitionPercentage,const bool useStratifiedSampling = false);
307 
316  bool merge(const TimeSeriesClassificationData &labelledData);
317 
325  bool spiltDataIntoKFolds(const UINT K, const bool useStratifiedSampling = false);
326 
334  TimeSeriesClassificationData getTrainingFoldData(const UINT foldIndex) const;
335 
343  TimeSeriesClassificationData getTestFoldData(const UINT foldIndex) const;
344 
352  TimeSeriesClassificationData getClassData(const UINT classLabel) const;
353 
360 
366  string getDatasetName() const { return datasetName; }
367 
373  string getInfoText() const { return infoText; }
374 
380  UINT inline getNumDimensions() const { return numDimensions; }
381 
387  UINT inline getNumSamples() const { return totalNumSamples; }
388 
394  UINT inline getNumClasses() const { return (UINT)classTracker.size(); }
395 
401  UINT getMinimumClassLabel() const;
402 
408  UINT getMaximumClassLabel() const;
409 
415  UINT getClassLabelIndexValue(const UINT classLabel) const;
416 
422  string getClassNameForCorrespondingClassLabel(const UINT classLabel) const;
423 
429  vector<MinMax> getRanges() const;
430 
436  vector< ClassTracker > getClassTracker() const { return classTracker; }
437 
443  vector< TimeSeriesClassificationSample > getClassificationData() const { return data; }
444 
452 
453 protected:
454 
455  string datasetName;
456  string infoText;
459  UINT kFoldValue;
463  vector< MinMax > externalRanges;
464  vector< ClassTracker > classTracker;
465  vector< TimeSeriesClassificationSample > data;
466  vector< vector< UINT > > crossValidationIndexs;
467 
471 
472 };
473 
474 } //End of namespace GRT
475 
476 #endif //GRT_LABELLED_TIME_SERIES_CLASSIFICATION_DATA_HEADER
477 
bool enableExternalRangeScaling(const bool useExternalRanges)
bool save(const string &filename) const
vector< ClassTracker > classTracker
A vector of ClassTracker, which keeps track of the number of samples of each class.
Definition: AdaBoost.cpp:25
vector< TimeSeriesClassificationSample > getClassificationData() const
TimeSeriesClassificationSample & operator[](const UINT &i)
WarningLog warningLog
Default warning log.
UINT eraseAllSamplesWithClassLabel(const UINT classLabel)
TimeSeriesClassificationData partition(const UINT partitionPercentage, const bool useStratifiedSampling=false)
bool setNumDimensions(const UINT numDimensions)
bool addSample(const UINT classLabel, const MatrixDouble &trainingSample)
string infoText
Some infoText about the dataset.
string datasetName
The name of the dataset.
UINT getClassLabelIndexValue(const UINT classLabel) const
UINT totalNumSamples
The total number of samples in the dataset.
The UnlabelledData class is the main data container for supporting unsupervised learning.
TimeSeriesClassificationData(UINT numDimensions=0, string datasetName="NOT_SET", string infoText="")
vector< TimeSeriesClassificationSample > data
The labelled time series classification data.
bool loadDatasetFromCSVFile(const string &filename)
bool relabelAllSamplesWithClassLabel(const UINT oldClassLabel, const UINT newClassLabel)
bool saveDatasetToFile(const string filename) const
bool saveDatasetToCSVFile(const string &filename) const
UINT kFoldValue
The number of folds the dataset has been spilt into for cross valiation.
bool crossValidationSetup
A flag to show if the dataset is ready for cross validation.
This class stores the timeseries data for a single labelled timeseries classification sample...
bool setClassNameForCorrespondingClassLabel(const string className, const UINT classLabel)
bool allowNullGestureClass
A flag that enables/disables a user from adding new samples with a class label matching the default n...
bool scale(const double minTarget, const double maxTarget)
string getClassNameForCorrespondingClassLabel(const UINT classLabel) const
vector< ClassTracker > getClassTracker() const
TimeSeriesClassificationData & operator=(const TimeSeriesClassificationData &rhs)
DebugLog debugLog
Default debugging log.
bool merge(const TimeSeriesClassificationData &labelledData)
TimeSeriesClassificationData getClassData(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.
bool setDatasetName(const string datasetName)
bool setExternalRanges(const vector< MinMax > &externalRanges, const bool useExternalRanges=false)
vector< MinMax > externalRanges
A vector containing a set of externalRanges set by the user.
TimeSeriesClassificationData getTrainingFoldData(const UINT foldIndex) const
vector< vector< UINT > > crossValidationIndexs
A vector to hold the indexs of the dataset for the cross validation.
bool spiltDataIntoKFolds(const UINT K, const bool useStratifiedSampling=false)
bool setAllowNullGestureClass(const bool allowNullGestureClass)
TimeSeriesClassificationData getTestFoldData(const UINT foldIndex) const