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.
|
#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 () | |
UnlabelledData & | operator= (const UnlabelledData &rhs) |
VectorFloat & | operator[] (const UINT &i) |
const VectorFloat & | operator[] (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< MinMax > | getRanges () const |
Vector< VectorFloat > | getData () const |
MatrixDouble | getDataAsMatrixDouble () const |
MatrixFloat | getDataAsMatrixFloat () const |
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.
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.
numDimensions | the number of dimensions of the training data, should be an unsigned integer greater than 0 |
datasetName | the name of the dataset, should not contain any spaces |
infoText | some 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
rhs | another 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.
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.
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 |
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.
useExternalRanges | sets if these ranges should be used to scale the dataset |
Definition at line 157 of file UnlabelledData.cpp.
Vector< VectorFloat > UnlabelledData::getData | ( | ) | const |
Gets the unlabeled classification data as a vector of VectorFloats.
Definition at line 644 of file UnlabelledData.cpp.
MatrixDouble UnlabelledData::getDataAsMatrixDouble | ( | ) | const |
Gets the unlabeled classification data as a MatrixDouble.
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.
Definition at line 662 of file UnlabelledData.cpp.
|
inline |
Gets the name of the dataset.
Definition at line 306 of file UnlabelledData.h.
|
inline |
Gets the infotext for the dataset
Definition at line 313 of file UnlabelledData.h.
|
inline |
Gets the number of dimensions of the labelled classification data.
Definition at line 327 of file UnlabelledData.h.
|
inline |
Gets the number of samples in the classification data across all the classes.
Definition at line 334 of file UnlabelledData.h.
Gets the ranges of the classification data.
Definition at line 623 of file UnlabelledData.cpp.
std::string UnlabelledData::getStatsAsString | ( | ) | const |
Gets the stats of the 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.
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 |
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.
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 |
Definition at line 545 of file UnlabelledData.cpp.
UnlabelledData::GRT_DEPRECATED_MSG | ( | "partition(...) is | deprecated, |
use split(...) instead" | , | ||
UnlabelledData | partitionconst UINT partitionPercentage | ||
) |
partitionPercentage | sets the percentage of data which remains in this instance, the remaining percentage of data is then returned as the testing/validation dataset |
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.
filename | the name of the file the data will be loaded from |
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
filename | the name of the file the data will be loaded from |
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.
filename | the name of the file the data will be loaded from |
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.
unlabelledData | the dataset to add to this dataset |
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
rhs | another instance of the UnlabelledData class from which the data will be copied to this instance |
Definition at line 42 of file UnlabelledData.cpp.
|
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]
i | the index of the training sample you want to access. Must be within the range of [0 totalNumSamples-1] |
Definition at line 78 of file UnlabelledData.h.
|
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]
i | the index of the training sample you want to access. Must be within the range of [0 totalNumSamples-1] |
Definition at line 89 of file UnlabelledData.h.
bool UnlabelledData::removeLastSample | ( | ) |
Removes the last training sample added to the dataset.
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).
N | the new memory size |
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).
filename | the name of the file the data will be saved to |
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.
filename | the name of the file the data will be saved to |
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.
filenamee | the name of the file the data will be saved to |
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.
minTarget | the minimum target range for scaling |
maxTarget | the maximum target range for scaling |
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.
range | the ranges to be used for scaling, the size of the vector should match the number of dimensions in the dataset |
minTarget | the minimum target range for scaling |
maxTarget | the maximum target range for scaling |
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.
datasetName | the new name for the dataset |
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.
externalRanges | an N dimensional vector containing the min and max values of the expected ranges of the dataset. |
useExternalRanges | sets if these ranges should be used to scale the dataset, default value is false. |
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.
infoText | the infoText |
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
numDimensions | the number of dimensions of the training data. Must be an unsigned integer greater than zero |
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.
K | the number of folds the dataset will be split into, K should be less than the number of samples in the dataset |
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).
partitionPercentage | sets the percentage of data which remains in this instance, the remaining percentage of data is then returned as the testing/validation dataset |
Definition at line 419 of file UnlabelledData.cpp.