本文整理汇总了C++中GestureRecognitionPipeline::getTestResults方法的典型用法代码示例。如果您正苦于以下问题:C++ GestureRecognitionPipeline::getTestResults方法的具体用法?C++ GestureRecognitionPipeline::getTestResults怎么用?C++ GestureRecognitionPipeline::getTestResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GestureRecognitionPipeline
的用法示例。
在下文中一共展示了GestureRecognitionPipeline::getTestResults方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: metrics_subset_data
void metrics_subset_data(){
ANBC anbc;
anbc.enableScaling(true);
anbc.enableNullRejection(true);
MinDist minDist;
minDist.setNumClusters(4);
minDist.enableScaling(true);
minDist.enableNullRejection(true);
// ofstream opRecall("anbc-recall-nr-0-10.csv");
// opRecall <<"nrCoeff,class0,class1,class2,class3,class4,class5\n";
//
// ofstream opInstanceRes("anbc-prediction-nr-2.csv");
// opInstanceRes <<"actualClass,predictedClass,maximumLikelihood,lZ,lY,lZ,rZ,rY,rZ\n";
//
// ofstream opMetrics("anbc-precision-recall-fmeasure-nr-2.csv");
// opMetrics <<"class1,class2,class3,class4,class5\n";
//
// ofstream opConfusion("anbc-confusion-nr-2.csv");
// opConfusion <<"class0,class1,class2,class3,class4,class5\n";
ofstream opRecall("mindist-recall-nr-0-10.csv");
opRecall <<"nrCoeff,class0,class1,class2,class3,class4,class5\n";
ofstream opInstanceRes("mindist-prediction-nr-2.csv");
opInstanceRes <<"actualClass,predictedClass,maximumLikelihood,lZ,lY,lZ,rZ,rY,rZ\n";
ofstream opMetrics("mindist-precision-recall-fmeasure-nr-2.csv");
opMetrics <<"class1,class2,class3,class4,class5\n";
ofstream opConfusion("mindist-confusion-nr-2.csv");
opConfusion <<"class0,class1,class2,class3,class4,class5\n";
// Training and test data
ClassificationData trainingData;
ClassificationData testData;
ClassificationData nullGestureData;
string file_path = "../../../data/";
if( !trainingData.loadDatasetFromFile(file_path + "train/grt/hri-training-dataset.txt") ){
std::cout <<"Failed to load training data!\n";
}
if( !nullGestureData.loadDatasetFromFile(file_path + "test/grt/0.txt") ){
std::cout <<"Failed to load null gesture data!\n";
}
testData = trainingData.partition(90);
testData.sortClassLabels();
// testData.saveDatasetToFile("anbc-validation-subset.txt");
testData.saveDatasetToFile("mindist-validation-subset.txt");
for(double nullRejectionCoeff = 0; nullRejectionCoeff <= 10; nullRejectionCoeff=nullRejectionCoeff+0.2){
// anbc.setNullRejectionCoeff(nullRejectionCoeff);
// GestureRecognitionPipeline pipeline;
// pipeline.setClassifier(anbc);
minDist.setNullRejectionCoeff(nullRejectionCoeff);
GestureRecognitionPipeline pipeline;
pipeline.setClassifier(minDist);
pipeline.train(trainingData);
pipeline.test(testData);
TestResult testRes = pipeline.getTestResults();
opRecall << nullRejectionCoeff << ",";
//null rejection prediction
double accuracy = 0;
for(UINT i=0; i<nullGestureData.getNumSamples(); i++){
vector< double > inputVector = nullGestureData[i].getSample();
if( !pipeline.predict( inputVector )){
std::cout << "Failed to perform prediction for test sampel: " << i <<"\n";
}
UINT predictedClassLabel = pipeline.getPredictedClassLabel();
if(predictedClassLabel == 0 ) accuracy++;
}
opRecall << accuracy/double(nullGestureData.getNumSamples()) << ",";
// other classes prediction
for(int cl = 0; cl < testRes.recall.size(); cl++ ){
opRecall << testRes.recall[cl];
if(cl < testRes.recall.size() - 1){
opRecall << ",";
}
//.........这里部分代码省略.........