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.
GRT::UnlabelledData Class Reference

Public Member Functions

 UnlabelledData (const UINT numDimensions=0, const string datasetName="NOT_SET", const string infoText="")
 
 UnlabelledData (const UnlabelledData &rhs)
 
 ~UnlabelledData ()
 
UnlabelledDataoperator= (const UnlabelledData &rhs)
 
VectorDouble & operator[] (const UINT &i)
 
const VectorDouble & operator[] (const UINT &i) const
 
void clear ()
 
bool setNumDimensions (const UINT numDimensions)
 
bool setDatasetName (const string datasetName)
 
bool setInfoText (const string infoText)
 
bool addSample (const VectorDouble &sample)
 
bool removeLastSample ()
 
bool reserve (const UINT N)
 
bool setExternalRanges (const vector< MinMax > &externalRanges, const bool useExternalRanges=false)
 
bool enableExternalRangeScaling (const bool useExternalRanges)
 
bool scale (const double minTarget, const double maxTarget)
 
bool scale (const vector< MinMax > &ranges, const double minTarget, const double maxTarget)
 
bool save (const string &filename) const
 
bool load (const string &filename)
 
bool saveDatasetToFile (const string &filename) const
 
bool loadDatasetFromFile (const string &filename)
 
bool saveDatasetToCSVFile (const string &filename) const
 
bool loadDatasetFromCSVFile (const string &filename)
 
UnlabelledData partition (const UINT partitionPercentage)
 
bool merge (const UnlabelledData &unlabelledData)
 
bool spiltDataIntoKFolds (const UINT K)
 
UnlabelledData getTrainingFoldData (const UINT foldIndex) const
 
UnlabelledData getTestFoldData (const UINT foldIndex) const
 
string getDatasetName () const
 
string getInfoText () const
 
string getStatsAsString () const
 
UINT getNumDimensions () const
 
UINT getNumSamples () const
 
vector< MinMaxgetRanges () const
 
vector< VectorDouble > getData () const
 
MatrixDouble getDataAsMatrixDouble () const
 

Detailed Description

Definition at line 38 of file UnlabelledData.h.

Constructor & Destructor Documentation

GRT::UnlabelledData::UnlabelledData ( const UINT  numDimensions = 0,
const string  datasetName = "NOT_SET",
const string  infoText = "" 
)

Constructor, sets the name of the dataset and the number of dimensions of the training data. The name of the dataset should not contain any spaces.

Parameters
UINTnumDimensions: the number of dimensions of the training data, should be an unsigned integer greater than 0
stringdatasetName: the name of the dataset, should not contain any spaces
stringinfoText: some info about the data in this dataset, this can contain spaces

Definition at line 25 of file UnlabelledData.cpp.

GRT::UnlabelledData::UnlabelledData ( const UnlabelledData rhs)

Copy Constructor, copies the UnlabelledData from the rhs instance to this instance

Parameters
constUnlabelledData &rhs: another instance of the UnlabelledData class from which the data will be copied to this instance

Definition at line 35 of file UnlabelledData.cpp.

GRT::UnlabelledData::~UnlabelledData ( )

Default Destructor

Definition at line 39 of file UnlabelledData.cpp.

Member Function Documentation

bool GRT::UnlabelledData::addSample ( const VectorDouble &  sample)

Adds a new unlabelled sample to the dataset. The dimensionality of the sample should match the number of dimensions in the UnlabelledData.

Parameters
constVectorDouble &sample: the new sample you want to add to the dataset. The dimensionality of this sample should match the number of dimensions in the UnlabelledData
Returns
true if the sample was correctly added to the dataset, false otherwise

Definition at line 101 of file UnlabelledData.cpp.

void GRT::UnlabelledData::clear ( )

Clears any previous training data and counters

Definition at line 60 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::enableExternalRangeScaling ( const bool  useExternalRanges)

Sets if the dataset should be scaled using an external range (if useExternalRanges == true) or the ranges of the dataset (if false). The external ranges need to be set FIRST before calling this function, otherwise it will return false.

Parameters
booluseExternalRanges: sets if these ranges should be used to scale the dataset
Returns
returns true if the useExternalRanges variable was set, false otherwise

Definition at line 156 of file UnlabelledData.cpp.

vector< VectorDouble > GRT::UnlabelledData::getData ( ) const

Gets the unlabeled classification data as a vector of VectorDoubles.

Returns
a vector< VectorDouble > containing the UnlabeledClassificationSamples

Definition at line 639 of file UnlabelledData.cpp.

MatrixDouble GRT::UnlabelledData::getDataAsMatrixDouble ( ) const

Gets the unlabeled classification data as a MatrixDouble.

Returns
a MatrixDouble containing the UnlabeledClassificationSamples

Definition at line 643 of file UnlabelledData.cpp.

string GRT::UnlabelledData::getDatasetName ( ) const
inline

Gets the name of the dataset.

Returns
returns the name of the dataset

Definition at line 293 of file UnlabelledData.h.

string GRT::UnlabelledData::getInfoText ( ) const
inline

Gets the infotext for the dataset

Returns
returns the infotext of the dataset

Definition at line 300 of file UnlabelledData.h.

UINT GRT::UnlabelledData::getNumDimensions ( ) const
inline

Gets the number of dimensions of the labelled classification data.

Returns
an unsigned int representing the number of dimensions in the classification data

Definition at line 314 of file UnlabelledData.h.

UINT GRT::UnlabelledData::getNumSamples ( ) const
inline

Gets the number of samples in the classification data across all the classes.

Returns
an unsigned int representing the total number of samples in the classification data

Definition at line 321 of file UnlabelledData.h.

vector< MinMax > GRT::UnlabelledData::getRanges ( ) const

Gets the ranges of the classification data.

Returns
a vector of minimum and maximum values for each dimension of the data

Definition at line 618 of file UnlabelledData.cpp.

string GRT::UnlabelledData::getStatsAsString ( ) const

Gets the stats of the dataset as a string

Returns
returns the stats of this dataset as a string

Definition at line 601 of file UnlabelledData.cpp.

UnlabelledData GRT::UnlabelledData::getTestFoldData ( const UINT  foldIndex) const

Returns the test dataset for the k-th fold for cross validation. The spiltDataIntoKFolds(UINT K) function should have been called once before using this function. The foldIndex should be in the range [0 K-1], where K is the number of folds the data was spilt into.

Parameters
constUINT foldIndex: the index of the fold you want the test data for, this should be in the range [0 K-1], where K is the number of folds the data was spilt into
Returns
returns a test dataset

Definition at line 576 of file UnlabelledData.cpp.

UnlabelledData GRT::UnlabelledData::getTrainingFoldData ( const UINT  foldIndex) const

Returns the training dataset for the k-th fold for cross validation. The spiltDataIntoKFolds(UINT K) function should have been called once before using this function. The foldIndex should be in the range [0 K-1], where K is the number of folds the data was spilt into.

Parameters
constUINT foldIndex: the index of the fold you want the training data for, this should be in the range [0 K-1], where K is the number of folds the data was spilt into
Returns
returns a training dataset

Definition at line 540 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::load ( const string &  filename)

Load the data from a file. If the file format ends in '.csv' then the function will try and load the data from a csv format. If this fails then it will try and load the data as a custom GRT file.

Parameters
conststring &filename: the name of the file the data will be loaded from
Returns
true if the data was loaded successfully, false otherwise

Definition at line 193 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::loadDatasetFromCSVFile ( const string &  filename)

Loads the unlabelled classification data from a CSV file. This assumes the data is formatted with each row representing a sample. The sample data should be formatted as N columns, where N is the number of dimensions in the data. Each row should represent a sample

Parameters
conststring &filename: the name of the file the data will be loaded from
Returns
true if the data was loaded successfully, false otherwise

Definition at line 366 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::loadDatasetFromFile ( const string &  filename)

Loads the unlabeled classification data from a custom file format.

Parameters
conststring &filename: the name of the file the data will be loaded from
Returns
true if the data was loaded successfully, false otherwise

Definition at line 242 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::merge ( const UnlabelledData unlabelledData)

Adds the data in the unlabelledData set to the current instance of the UnlabelledData. The number of dimensions in both datasets must match.

Parameters
UnlabelledData&unlabelledData: the dataset to add to this dataset
Returns
returns true if the datasets were merged, false otherwise

Definition at line 460 of file UnlabelledData.cpp.

UnlabelledData & GRT::UnlabelledData::operator= ( const UnlabelledData rhs)

Sets the equals operator, copies the data from the rhs instance to this instance

Parameters
constUnlabelledData &rhs: another instance of the UnlabelledData class from which the data will be copied to this instance
Returns
a reference to this instance of UnlabelledData

Definition at line 41 of file UnlabelledData.cpp.

VectorDouble& GRT::UnlabelledData::operator[] ( const UINT &  i)
inline

Array Subscript Operator, returns the UnlabelledData at index i. It is up to the user to ensure that i is within the range of [0 totalNumSamples-1]

Parameters
constUINT &i: the index of the training sample you want to access. Must be within the range of [0 totalNumSamples-1]
Returns
the i'th row vector

Definition at line 78 of file UnlabelledData.h.

const VectorDouble& GRT::UnlabelledData::operator[] ( const UINT &  i) const
inline

Array Subscript Operator, returns the const UnlabelledData at index i. It is up to the user to ensure that i is within the range of [0 totalNumSamples-1]

Parameters
constUINT &i: the index of the training sample you want to access. Must be within the range of [0 totalNumSamples-1]
Returns
the i'th row vector

Definition at line 89 of file UnlabelledData.h.

UnlabelledData GRT::UnlabelledData::partition ( const UINT  partitionPercentage)

Partitions the dataset into a training dataset (which is kept by this instance of the UnlabelledData) and a testing/validation dataset (which is returned as a new instance of a UnlabelledData).

Parameters
UINTpartitionPercentage: sets the percentage of data which remains in this instance, the remaining percentage of data is then returned as the testing/validation dataset
Returns
a new UnlabelledData instance, containing the remaining data not kept but this instance

Definition at line 414 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::removeLastSample ( )

Removes the last training sample added to the dataset.

Returns
true if the last sample was removed, false otherwise

Definition at line 115 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::reserve ( const UINT  N)

Reserves that the vector capacity be at least enough to contain N elements.

If N is greater than the current vector capacity, the function causes the container to reallocate its storage increasing its capacity to N (or greater).

Parameters
constUINT N: the new memory size
Returns
true if the memory was reserved successfully, false otherwise

Definition at line 137 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::save ( const string &  filename) const

Saves the data to a file. If the file format ends in '.csv' then the data will be saved as comma-seperated-values, otherwise it will be saved to a custom GRT file (which contains the csv data with an additional header).

Parameters
conststring &filename: the name of the file the data will be saved to
Returns
true if the data was saved successfully, false otherwise

Definition at line 182 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::saveDatasetToCSVFile ( const string &  filename) const

Saves the unlabeled classification data to a CSV file. This will save the sample data as N columns, where N is the number of dimensions in the data. Each row will represent a sample.

Parameters
conststring &filename: the name of the file the data will be saved to
Returns
true if the data was saved successfully, false otherwise

Definition at line 342 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::saveDatasetToFile ( const string &  filename) const

Saves the unlabeled classification data to a custom file format.

Parameters
conststring &filenamee: the name of the file the data will be saved to
Returns
true if the data was saved successfully, false otherwise

Definition at line 204 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::scale ( const double  minTarget,
const double  maxTarget 
)

Scales the dataset to the new target range.

Returns
true if the data was scaled correctly, false otherwise

Definition at line 164 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::scale ( const vector< MinMax > &  ranges,
const double  minTarget,
const double  maxTarget 
)

Scales the dataset to the new target range, using the vector of ranges as the min and max source ranges.

Returns
true if the data was scaled correctly, false otherwise

Definition at line 169 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::setDatasetName ( const string  datasetName)

Sets the name of the dataset. There should not be any spaces in the name. Will return true if the name is set, or false otherwise.

Returns
returns true if the name is set, or false otherwise

Definition at line 85 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::setExternalRanges ( const vector< MinMax > &  externalRanges,
const bool  useExternalRanges = false 
)

Sets the external ranges of the dataset, also sets if the dataset should be scaled using these values. The dimensionality of the externalRanges vector should match the number of dimensions of this dataset.

Parameters
vector<MinMax > externalRanges: an N dimensional vector containing the min and max values of the expected ranges of the dataset.
booluseExternalRanges: sets if these ranges should be used to scale the dataset, default value is false.
Returns
returns true if the external ranges were set, false otherwise

Definition at line 146 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::setInfoText ( const string  infoText)

Sets the info string. This can be any string with information about how the training data was recorded for example.

Parameters
stringinfoText: the infoText
Returns
true if the infoText was correctly updated, false otherwise

Definition at line 96 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::setNumDimensions ( const UINT  numDimensions)

Sets the number of dimensions in the training data. This should be an unsigned integer greater than zero. This will clear any previous training data and counters. This function needs to be called before any new samples can be added to the dataset, unless the numDimensions variable was set in the constructor or some data was already loaded from a file

Parameters
UINTnumDimensions: the number of dimensions of the training data. Must be an unsigned integer greater than zero
Returns
true if the number of dimensions was correctly updated, false otherwise

Definition at line 67 of file UnlabelledData.cpp.

bool GRT::UnlabelledData::spiltDataIntoKFolds ( const UINT  K)

This function prepares the dataset for k-fold cross validation and should be called prior to calling the getTrainingFold(UINT foldIndex) or getTestingFold(UINT foldIndex) functions. It will spilt the dataset into K-folds, as long as K < M, where M is the number of samples in the dataset.

Parameters
constUINT K: the number of folds the dataset will be split into, K should be less than the number of samples in the dataset
Returns
returns true if the dataset was split correctly, false otherwise

Definition at line 481 of file UnlabelledData.cpp.


The documentation for this class was generated from the following files: