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

#include <UnlabelledData.h>

Public Member Functions

 UnlabelledData (const UINT numDimensions=0, const std::string datasetName="NOT_SET", const std::string infoText="")
 
 UnlabelledData (const UnlabelledData &rhs)
 
 ~UnlabelledData ()
 
UnlabelledDataoperator= (const UnlabelledData &rhs)
 
VectorFloatoperator[] (const UINT &i)
 
const VectorFloatoperator[] (const UINT &i) const
 
void clear ()
 
bool setNumDimensions (const UINT numDimensions)
 
bool setDatasetName (const std::string datasetName)
 
bool setInfoText (const std::string infoText)
 
bool addSample (const VectorFloat &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 Float minTarget, const Float maxTarget)
 
bool scale (const Vector< MinMax > &ranges, const Float minTarget, const Float maxTarget)
 
bool save (const std::string &filename) const
 
bool load (const std::string &filename)
 
bool saveDatasetToFile (const std::string &filename) const
 
bool loadDatasetFromFile (const std::string &filename)
 
bool saveDatasetToCSVFile (const std::string &filename) const
 
bool loadDatasetFromCSVFile (const std::string &filename)
 
 GRT_DEPRECATED_MSG ("partition(...) is deprecated, use split(...) instead", UnlabelledData partition(const UINT partitionPercentage))
 
UnlabelledData split (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
 
std::string getDatasetName () const
 
std::string getInfoText () const
 
std::string getStatsAsString () const
 
UINT getNumDimensions () const
 
UINT getNumSamples () const
 
Vector< MinMaxgetRanges () const
 
Vector< VectorFloatgetData () const
 
MatrixDouble getDataAsMatrixDouble () const
 
MatrixFloat getDataAsMatrixFloat () const
 

Detailed Description

GRT MIT License Copyright (c) <2012> <Nicholas Gillian, Media Lab, MIT>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition at line 38 of file UnlabelledData.h.

Constructor & Destructor Documentation

GRT_BEGIN_NAMESPACE UnlabelledData::UnlabelledData ( const UINT  numDimensions = 0,
const std::string  datasetName = "NOT_SET",
const std::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
numDimensionsthe number of dimensions of the training data, should be an unsigned integer greater than 0
datasetNamethe name of the dataset, should not contain any spaces
infoTextsome info about the data in this dataset, this can contain spaces

Definition at line 26 of file UnlabelledData.cpp.

UnlabelledData::UnlabelledData ( const UnlabelledData rhs)

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

Parameters
rhsanother instance of the UnlabelledData class from which the data will be copied to this instance

Definition at line 36 of file UnlabelledData.cpp.

UnlabelledData::~UnlabelledData ( )

Default Destructor

Definition at line 40 of file UnlabelledData.cpp.

Member Function Documentation

bool UnlabelledData::addSample ( const VectorFloat sample)

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

Parameters
samplethe 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 102 of file UnlabelledData.cpp.

void UnlabelledData::clear ( )

Clears any previous training data and counters

Definition at line 61 of file UnlabelledData.cpp.

bool 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
useExternalRangessets if these ranges should be used to scale the dataset
Returns
returns true if the useExternalRanges variable was set, false otherwise

Definition at line 157 of file UnlabelledData.cpp.

Vector< VectorFloat > UnlabelledData::getData ( ) const

Gets the unlabeled classification data as a vector of VectorFloats.

Returns
a vector< VectorFloat > containing the UnlabeledClassificationSamples

Definition at line 644 of file UnlabelledData.cpp.

MatrixDouble UnlabelledData::getDataAsMatrixDouble ( ) const

Gets the unlabeled classification data as a MatrixDouble.

Returns
a MatrixDouble containing the UnlabeledClassificationSamples

Definition at line 648 of file UnlabelledData.cpp.

MatrixFloat UnlabelledData::getDataAsMatrixFloat ( ) const

Gets the data as a MatrixFloat. This will be an M by N MatrixFloat, where M is the number of samples and N is the number of dimensions.

Returns
a MatrixFloat containing the data from the current dataset.

Definition at line 662 of file UnlabelledData.cpp.

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

Gets the name of the dataset.

Returns
returns the name of the dataset

Definition at line 306 of file UnlabelledData.h.

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

Gets the infotext for the dataset

Returns
returns the infotext of the dataset

Definition at line 313 of file UnlabelledData.h.

UINT 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 327 of file UnlabelledData.h.

UINT 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 334 of file UnlabelledData.h.

Vector< MinMax > 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 623 of file UnlabelledData.cpp.

std::string 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 606 of file UnlabelledData.cpp.

UnlabelledData 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
foldIndexthe 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 581 of file UnlabelledData.cpp.

UnlabelledData 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
foldIndexthe 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 545 of file UnlabelledData.cpp.

UnlabelledData::GRT_DEPRECATED_MSG ( "partition(...) is  deprecated,
use split(...) instead"  ,
UnlabelledData   partitionconst UINT partitionPercentage 
)
Deprecated:
use split(...) instead
Parameters
partitionPercentagesets 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
bool UnlabelledData::load ( const std::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
filenamethe name of the file the data will be loaded from
Returns
true if the data was loaded successfully, false otherwise

Definition at line 194 of file UnlabelledData.cpp.

bool UnlabelledData::loadDatasetFromCSVFile ( const std::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
filenamethe name of the file the data will be loaded from
Returns
true if the data was loaded successfully, false otherwise

Definition at line 367 of file UnlabelledData.cpp.

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

Loads the unlabeled classification data from a custom file format.

Parameters
filenamethe name of the file the data will be loaded from
Returns
true if the data was loaded successfully, false otherwise

Definition at line 243 of file UnlabelledData.cpp.

bool 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
unlabelledDatathe dataset to add to this dataset
Returns
returns true if the datasets were merged, false otherwise

Definition at line 465 of file UnlabelledData.cpp.

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

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

Parameters
rhsanother 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 42 of file UnlabelledData.cpp.

VectorFloat& 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
ithe 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 VectorFloat& 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
ithe 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.

bool UnlabelledData::removeLastSample ( )

Removes the last training sample added to the dataset.

Returns
true if the last sample was removed, false otherwise

Definition at line 116 of file UnlabelledData.cpp.

bool 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
Nthe new memory size
Returns
true if the memory was reserved successfully, false otherwise

Definition at line 138 of file UnlabelledData.cpp.

bool UnlabelledData::save ( const std::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
filenamethe name of the file the data will be saved to
Returns
true if the data was saved successfully, false otherwise

Definition at line 183 of file UnlabelledData.cpp.

bool UnlabelledData::saveDatasetToCSVFile ( const std::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
filenamethe name of the file the data will be saved to
Returns
true if the data was saved successfully, false otherwise

Definition at line 343 of file UnlabelledData.cpp.

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

Saves the unlabeled classification data to a custom file format.

Parameters
filenameethe name of the file the data will be saved to
Returns
true if the data was saved successfully, false otherwise

Definition at line 205 of file UnlabelledData.cpp.

bool UnlabelledData::scale ( const Float  minTarget,
const Float  maxTarget 
)

Scales the dataset to the new target range.

Parameters
minTargetthe minimum target range for scaling
maxTargetthe maximum target range for scaling
Returns
true if the data was scaled correctly, false otherwise

Definition at line 165 of file UnlabelledData.cpp.

bool UnlabelledData::scale ( const Vector< MinMax > &  ranges,
const Float  minTarget,
const Float  maxTarget 
)

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

Parameters
rangethe ranges to be used for scaling, the size of the vector should match the number of dimensions in the dataset
minTargetthe minimum target range for scaling
maxTargetthe maximum target range for scaling
Returns
true if the data was scaled correctly, false otherwise

Definition at line 170 of file UnlabelledData.cpp.

bool UnlabelledData::setDatasetName ( const std::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.

Parameters
datasetNamethe new name for the dataset
Returns
returns true if the name is set, or false otherwise

Definition at line 86 of file UnlabelledData.cpp.

bool 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
externalRangesan N dimensional vector containing the min and max values of the expected ranges of the dataset.
useExternalRangessets 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 147 of file UnlabelledData.cpp.

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

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

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

Definition at line 97 of file UnlabelledData.cpp.

bool 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
numDimensionsthe 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 68 of file UnlabelledData.cpp.

bool 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
Kthe 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 486 of file UnlabelledData.cpp.

UnlabelledData UnlabelledData::split ( 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
partitionPercentagesets 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 419 of file UnlabelledData.cpp.


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