1 /*M///////////////////////////////////////////////////////////////////////////////////////
\r
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
\r
5 // By downloading, copying, installing or using the software you agree to this license.
\r
6 // If you do not agree to this license, do not download, install,
\r
7 // copy or use the software.
\r
10 // Intel License Agreement
\r
11 // For Open Source Computer Vision Library
\r
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
\r
14 // Third party copyrights are property of their respective owners.
\r
16 // Redistribution and use in source and binary forms, with or without modification,
\r
17 // are permitted provided that the following conditions are met:
\r
19 // * Redistribution's of source code must retain the above copyright notice,
\r
20 // this list of conditions and the following disclaimer.
\r
22 // * Redistribution's in binary form must reproduce the above copyright notice,
\r
23 // this list of conditions and the following disclaimer in the documentation
\r
24 // and/or other materials provided with the distribution.
\r
26 // * The name of Intel Corporation may not be used to endorse or promote products
\r
27 // derived from this software without specific prior written permission.
\r
29 // This software is provided by the copyright holders and contributors "as is" and
\r
30 // any express or implied warranties, including, but not limited to, the implied
\r
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
\r
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
\r
33 // indirect, incidental, special, exemplary, or consequential damages
\r
34 // (including, but not limited to, procurement of substitute goods or services;
\r
35 // loss of use, data, or profits; or business interruption) however caused
\r
36 // and on any theory of liability, whether in contract, strict liability,
\r
37 // or tort (including negligence or otherwise) arising in any way out of
\r
38 // the use of this software, even if advised of the possibility of such damage.
\r
44 CV_AMLTest::CV_AMLTest( const char* _modelName, const char* _testName ) :
\r
45 CV_MLBaseTest( _modelName, _testName, "train-predict" )
\r
47 validationFN = "avalidation.xml";
\r
50 int CV_AMLTest::run_test_case( int testCaseIdx )
\r
52 int code = CvTS::OK;
\r
53 code = prepare_test_case( testCaseIdx );
\r
55 if (code == CvTS::OK)
\r
59 const char* data_name = ((CvFileNode*)cvGetSeqElem( dataSetNames, testCaseIdx ))->data.str.ptr;
\r
60 printf("%s, %s ", name, data_name);
\r
61 const int icount = 100;
\r
63 for (int k = 0; k < icount; k++)
\r
66 data.mix_train_and_test_idx();
\r
67 code = train( testCaseIdx );
\r
69 float case_result = get_error();
\r
71 res[k] = case_result;
\r
73 float mean = 0, sigma = 0;
\r
74 for (int k = 0; k < icount; k++)
\r
78 mean = mean /icount;
\r
79 for (int k = 0; k < icount; k++)
\r
81 sigma += (res[k] - mean)*(res[k] - mean);
\r
83 sigma = sqrt(sigma/icount);
\r
84 printf("%f, %f\n", mean, sigma);
\r
90 int CV_AMLTest::validate_test_results( int testCaseIdx )
\r
94 // read validation params
\r
95 FileNode resultNode =
\r
96 validationFS.getFirstTopLevelNode()["validation"][modelName][dataSetNames[testCaseIdx]]["result"];
\r
97 resultNode["iter_count"] >> iters;
\r
100 resultNode["mean"] >> mean;
\r
101 resultNode["sigma"] >> sigma;
\r
102 float curErr = get_error( testCaseIdx, CV_TEST_ERROR );
\r
103 if ( abs( curErr - mean) > 6*sigma )
\r
105 ts->printf( CvTS::LOG, "in test case %d test error is out of range:\n"
\r
106 "abs(%f/*curEr*/ - %f/*mean*/ > %f/*6*sigma*/", testCaseIdx, curErr, mean, 6*sigma );
\r
107 return CvTS::FAIL_BAD_ACCURACY;
\r
112 ts->printf( CvTS::LOG, "validation info is not suitable" );
\r
113 return CvTS::FAIL_INVALID_TEST_DATA;
\r
118 CV_AMLTest amldtree( CV_DTREE, "adtree" );
\r
119 CV_AMLTest amlboost( CV_BOOST, "aboost" );
\r
120 CV_AMLTest amlrtrees( CV_RTREES, "artrees" );
\r
121 CV_AMLTest amlertrees( CV_ERTREES, "aertrees" );
\r