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.
TestInstanceResult.h
Go to the documentation of this file.
1 
9 /*
10  GRT MIT License
11  Copyright (c) <2012> <Nicholas Gillian, Media Lab, MIT>
12 
13  Permission is hereby granted, free of charge, to any person obtaining a copy of this software
14  and associated documentation files (the "Software"), to deal in the Software without restriction,
15  including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
17  subject to the following conditions:
18 
19  The above copyright notice and this permission notice shall be included in all copies or substantial
20  portions of the Software.
21 
22  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
23  LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  */
28 
29 #ifndef GRT_TEST_INSTANCE_RESULT_HEADER
30 #define GRT_TEST_INSTANCE_RESULT_HEADER
31 
32 #include "GRTTypedefs.h"
33 
34 GRT_BEGIN_NAMESPACE
35 
37 public:
44  testMode = CLASSIFICATION_MODE;
45  testIteration = 0;
46  classLabel = 0;
47  predictedClassLabel = 0;
48  unProcessedPredictedClassLabel = 0;
49  }
50 
59  *this = rhs;
60  }
61 
66 
67  }
68 
77  if( this != &rhs ){
78  this->testMode = rhs.testMode;
79  this->testIteration = rhs.testIteration;
80  this->classLabel = rhs.classLabel;
81  this->predictedClassLabel = rhs.predictedClassLabel;
82  this->unProcessedPredictedClassLabel = rhs.unProcessedPredictedClassLabel;
83  this->classLikelihoods = rhs.classLikelihoods;
84  this->classDistances = rhs.classDistances;
85  this->regressionData = rhs.regressionData;
86  this->targetData = rhs.targetData;
87  }
88  return *this;
89  }
90 
98  bool setClassificationResult(const unsigned int testIteration,const unsigned int classLabel,const unsigned int predictedClassLabel,const unsigned int unProcessedPredictedClassLabel,const VectorFloat &classLikelihoods,const VectorFloat &classDistances){
99  this->testMode = CLASSIFICATION_MODE;
100  this->testIteration = testIteration;
101  this->classLabel = classLabel;
102  this->predictedClassLabel = predictedClassLabel;
103  this->unProcessedPredictedClassLabel = unProcessedPredictedClassLabel;
104  this->classLikelihoods = classLikelihoods;
105  this->classDistances = classDistances;
106  return true;
107  }
108 
117  bool setRegressionResult(const unsigned int testIteration,const VectorFloat &regressionData,const VectorFloat &targetData){
118  this->testMode = REGRESSION_MODE;
119  this->testIteration = testIteration;
120  this->regressionData = regressionData;
121  this->targetData = targetData;
122  return true;
123  }
124 
130  unsigned int getTestMode() const{
131  return testMode;
132  }
133 
139  unsigned int getTestIteration() const{
140  return testIteration;
141  }
142 
148  unsigned int getClassLabel() const{
149  return classLabel;
150  }
151 
157  unsigned int getPredictedClassLabel() const{
158  return predictedClassLabel;
159  }
160 
166  Float getMaximumLikelihood() const{
167  Float maxLikelihood = 0;
168  for(size_t i=0; i<classLikelihoods.size(); i++){
169  if( classLikelihoods[i] > maxLikelihood ){
170  maxLikelihood = classLikelihoods[i];
171  }
172  }
173  return maxLikelihood;
174  }
175 
181  Float getSquaredError() const{
182  Float sum = 0;
183  if( regressionData.size() != targetData.size() ) return 0;
184  for(size_t i=0; i<regressionData.size(); i++){
185  sum += (regressionData[i]-targetData[i])*(regressionData[i]-targetData[i]);
186  }
187  return sum;
188  }
189 
196  return classLikelihoods;
197  }
198 
205  return classDistances;
206  }
207 
208 protected:
209  unsigned int testMode;
210  unsigned int testIteration;
211  unsigned int classLabel;
212  unsigned int predictedClassLabel;
213  unsigned int unProcessedPredictedClassLabel;
214  VectorFloat classLikelihoods;
215  VectorFloat classDistances;
216  VectorFloat regressionData;
217  VectorFloat targetData;
218 
219 public:
220 
221  enum TestMode{CLASSIFICATION_MODE=0,REGRESSION_MODE};
222 
223 };
224 
225 GRT_END_NAMESPACE
226 
227 #endif //GRT_TEST_INSTANCE_RESULT_HEADER
unsigned int getTestIteration() const
TestInstanceResult(const TestInstanceResult &rhs)
unsigned int getClassLabel() const
bool setClassificationResult(const unsigned int testIteration, const unsigned int classLabel, const unsigned int predictedClassLabel, const unsigned int unProcessedPredictedClassLabel, const VectorFloat &classLikelihoods, const VectorFloat &classDistances)
VectorFloat getDistances() const
unsigned int getTestMode() const
unsigned int getPredictedClassLabel() const
Float getMaximumLikelihood() const
VectorFloat getClassLikelihoods() const
bool setRegressionResult(const unsigned int testIteration, const VectorFloat &regressionData, const VectorFloat &targetData)
Float getSquaredError() const
TestInstanceResult & operator=(const TestInstanceResult &rhs)