GestureRecognitionToolkit  Version: 0.2.0
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 namespace GRT {
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 
190 protected:
191  unsigned int testMode;
192  unsigned int testIteration;
193  unsigned int classLabel;
194  unsigned int predictedClassLabel;
195  unsigned int unProcessedPredictedClassLabel;
196  VectorFloat classLikelihoods;
197  VectorFloat classDistances;
198  VectorFloat regressionData;
199  VectorFloat targetData;
200 
201 public:
202 
203  enum TestMode{CLASSIFICATION_MODE=0,REGRESSION_MODE};
204 
205 };
206 
207 }//End of namespace GRT
208 
209 #endif //GRT_TEST_INSTANCE_RESULT_HEADER
Definition: DebugLog.cpp:24
bool setRegressionResult(const unsigned int testIteration, const VectorFloat &regressionData, const VectorFloat &targetData)
unsigned int getTestIteration() const
unsigned int getTestMode() const
TestInstanceResult & operator=(const TestInstanceResult &rhs)
bool setClassificationResult(const unsigned int testIteration, const unsigned int classLabel, const unsigned int predictedClassLabel, const unsigned int unProcessedPredictedClassLabel, const VectorFloat &classLikelihoods, const VectorFloat &classDistances)
TestInstanceResult(const TestInstanceResult &rhs)
unsigned int getClassLabel() const
Float getMaximumLikelihood() const
unsigned int getPredictedClassLabel() const