本文整理汇总了C++中GestureRecognitionPipeline::getTestRMSError方法的典型用法代码示例。如果您正苦于以下问题:C++ GestureRecognitionPipeline::getTestRMSError方法的具体用法?C++ GestureRecognitionPipeline::getTestRMSError怎么用?C++ GestureRecognitionPipeline::getTestRMSError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GestureRecognitionPipeline
的用法示例。
在下文中一共展示了GestureRecognitionPipeline::getTestRMSError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, const char * argv[])
{
//Turn on the training log so we can print the training status of the LinearRegression to the screen
TrainingLog::enableLogging( true );
//Load the training data
RegressionData trainingData;
RegressionData testData;
if( !trainingData.loadDatasetFromFile("LinearRegressionTrainingData.txt") ){
cout << "ERROR: Failed to load training data!\n";
return EXIT_FAILURE;
}
if( !testData.loadDatasetFromFile("LinearRegressionTestData.txt") ){
cout << "ERROR: Failed to load test data!\n";
return EXIT_FAILURE;
}
//Make sure the dimensionality of the training and test data matches
if( trainingData.getNumInputDimensions() != testData.getNumInputDimensions() ){
cout << "ERROR: The number of input dimensions in the training data (" << trainingData.getNumInputDimensions() << ")";
cout << " does not match the number of input dimensions in the test data (" << testData.getNumInputDimensions() << ")\n";
return EXIT_FAILURE;
}
if( testData.getNumTargetDimensions() != testData.getNumTargetDimensions() ){
cout << "ERROR: The number of target dimensions in the training data (" << testData.getNumTargetDimensions() << ")";
cout << " does not match the number of target dimensions in the test data (" << testData.getNumTargetDimensions() << ")\n";
return EXIT_FAILURE;
}
cout << "Training and Test datasets loaded\n";
//Print the stats of the datasets
cout << "Training data stats:\n";
trainingData.printStats();
cout << "Test data stats:\n";
testData.printStats();
//Create a new gesture recognition pipeline
GestureRecognitionPipeline pipeline;
//Add a LinearRegression instance to the pipeline
pipeline.setRegressifier( LinearRegression() );
//Train the LinearRegression model
cout << "Training LogisticRegression model...\n";
if( !pipeline.train( trainingData ) ){
cout << "ERROR: Failed to train LinearRegression model!\n";
return EXIT_FAILURE;
}
cout << "Model trained.\n";
//Test the model
cout << "Testing LinearRegression model...\n";
if( !pipeline.test( testData ) ){
cout << "ERROR: Failed to test LinearRegression model!\n";
return EXIT_FAILURE;
}
cout << "Test complete. Test RMS error: " << pipeline.getTestRMSError() << endl;
//Run back over the test data again and output the results to a file
fstream file;
file.open("LinearRegressionResultsData.txt", fstream::out);
for(UINT i=0; i<testData.getNumSamples(); i++){
vector< double > inputVector = testData[i].getInputVector();
vector< double > targetVector = testData[i].getTargetVector();
//Map the input vector using the trained regression model
if( !pipeline.predict( inputVector ) ){
cout << "ERROR: Failed to map test sample " << i << endl;
return EXIT_FAILURE;
}
//Get the mapped regression data
vector< double > outputVector = pipeline.getRegressionData();
//Write the mapped value and also the target value to the file
for(UINT j=0; j<outputVector.size(); j++){
file << outputVector[j] << "\t";
}
for(UINT j=0; j<targetVector.size(); j++){
file << targetVector[j] << "\t";
}
file << endl;
}
//Close the file
file.close();
return EXIT_SUCCESS;
}