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.
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 
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 
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 
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 
308  TimeSeriesClassificationData partition(const UINT partitionPercentage,const bool useStratifiedSampling = false);
309 
318  bool merge(const TimeSeriesClassificationData &labelledData);
319 
327  bool spiltDataIntoKFolds(const UINT K, const bool useStratifiedSampling = false);
328 
336  TimeSeriesClassificationData getTrainingFoldData(const UINT foldIndex) const;
337 
345  TimeSeriesClassificationData getTestFoldData(const UINT foldIndex) const;
346 
354  TimeSeriesClassificationData getClassData(const UINT classLabel) const;
355 
362 
368  std::string getDatasetName() const { return datasetName; }
369 
375  std::string getInfoText() const { return infoText; }
376 
382  UINT inline getNumDimensions() const { return numDimensions; }
383 
389  UINT inline getNumSamples() const { return totalNumSamples; }
390 
396  UINT inline getNumClasses() const { return classTracker.getSize(); }
397 
403  UINT getMinimumClassLabel() const;
404 
410  UINT getMaximumClassLabel() const;
411 
417  UINT getClassLabelIndexValue(const UINT classLabel) const;
418 
424  std::string getClassNameForCorrespondingClassLabel(const UINT classLabel) const;
425 
431  Vector<MinMax> getRanges() const;
432 
439 
446 
454 
455 protected:
456 
457  std::string datasetName;
458  std::string infoText;
461  UINT kFoldValue;
469 
473 
474 };
475 
476 GRT_END_NAMESPACE
477 
478 #endif //GRT_LABELLED_TIME_SERIES_CLASSIFICATION_DATA_HEADER
479 
bool spiltDataIntoKFolds(const UINT K, const bool useStratifiedSampling=false)
bool loadDatasetFromCSVFile(const std::string &filename)
UINT numDimensions
The number of dimensions in the dataset.
TimeSeriesClassificationSample & operator[](const UINT &i)
bool setInfoText(const std::string infoText)
Vector< MinMax > externalRanges
A vector containing a set of externalRanges set by the user.
bool merge(const TimeSeriesClassificationData &labelledData)
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 setNumDimensions(const UINT numDimensions)
TimeSeriesClassificationData & operator=(const TimeSeriesClassificationData &rhs)
bool saveDatasetToFile(const std::string filename) const
unsigned int getSize() const
Definition: Vector.h:193
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
bool setExternalRanges(const Vector< MinMax > &externalRanges, const bool useExternalRanges=false)
WarningLog warningLog
Default warning log.
This class stores the timeseries data for a single labelled timeseries classification sample...
bool relabelAllSamplesWithClassLabel(const UINT oldClassLabel, const UINT newClassLabel)
UINT eraseAllSamplesWithClassLabel(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 enableExternalRangeScaling(const bool useExternalRanges)
std::string getClassNameForCorrespondingClassLabel(const UINT classLabel) const
DebugLog debugLog
Default debugging log.
UINT getClassLabelIndexValue(const UINT classLabel) const
bool crossValidationSetup
A flag to show if the dataset is ready for cross validation.
bool addSample(const UINT classLabel, const MatrixFloat &trainingSample)
std::string datasetName
The name of the dataset.
bool scale(const Float minTarget, const Float maxTarget)
TimeSeriesClassificationData getClassData(const UINT classLabel) const
bool setClassNameForCorrespondingClassLabel(const std::string className, const UINT classLabel)
bool saveDatasetToCSVFile(const std::string &filename) const
ErrorLog errorLog
Default error log.
Vector< ClassTracker > classTracker
A vector of ClassTracker, which keeps track of the number of samples of each class.
UnlabelledData reformatAsUnlabelledData() const
TimeSeriesClassificationData(UINT numDimensions=0, std::string datasetName="NOT_SET", std::string infoText="")
std::string infoText
Some infoText about the dataset.
bool setDatasetName(const std::string datasetName)
TimeSeriesClassificationData partition(const UINT partitionPercentage, const bool useStratifiedSampling=false)
Vector< TimeSeriesClassificationSample > getClassificationData() const
Vector< Vector< UINT > > crossValidationIndexs
A vector to hold the indexs of the dataset for the cross validation.
bool setAllowNullGestureClass(const bool allowNullGestureClass)
TimeSeriesClassificationData getTrainingFoldData(const UINT foldIndex) const
bool load(const std::string &filename)
bool save(const std::string &filename) const
bool loadDatasetFromFile(const std::string filename)
TimeSeriesClassificationData getTestFoldData(const UINT foldIndex) const