--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// Intel License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of Intel Corporation may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "mltest.h"\r
+\r
+CV_AMLTest::CV_AMLTest( const char* _modelName, const char* _testName ) :\r
+ CV_MLBaseTest( _modelName, _testName, "train-predict" )\r
+{\r
+ validationFN = "avalidation.xml";\r
+}\r
+\r
+int CV_AMLTest::run_test_case( int testCaseIdx )\r
+{\r
+ int code = CvTS::OK;
+ code = prepare_test_case( testCaseIdx );\r
+\r
+ if (code == CvTS::OK)\r
+ {\r
+ //#define GET_STAT\r
+#ifdef GET_STAT\r
+ const char* data_name = ((CvFileNode*)cvGetSeqElem( dataSetNames, testCaseIdx ))->data.str.ptr; \r
+ printf("%s, %s ", name, data_name);\r
+ const int icount = 100;\r
+ float res[icount];\r
+ for (int k = 0; k < icount; k++)\r
+ {\r
+#endif\r
+ data.mix_train_and_test_idx();\r
+ code = train( testCaseIdx ); \r
+#ifdef GET_STAT\r
+ float case_result = get_error();\r
+\r
+ res[k] = case_result;\r
+ }\r
+ float mean = 0, sigma = 0;\r
+ for (int k = 0; k < icount; k++)\r
+ {\r
+ mean += res[k];\r
+ }\r
+ mean = mean /icount;\r
+ for (int k = 0; k < icount; k++)\r
+ {\r
+ sigma += (res[k] - mean)*(res[k] - mean);\r
+ }\r
+ sigma = sqrt(sigma/icount);\r
+ printf("%f, %f\n", mean, sigma);\r
+#endif\r
+ }\r
+ return code;\r
+}\r
+\r
+int CV_AMLTest::validate_test_results( int testCaseIdx )\r
+{\r
+ int iters;
+ float mean, sigma;
+ // read validation params
+ FileNode resultNode =
+ validationFS.getFirstTopLevelNode()["validation"][modelName][dataSetNames[testCaseIdx]]["result"];
+ resultNode["iter_count"] >> iters;
+ if ( iters > 0)
+ {
+ resultNode["mean"] >> mean;
+ resultNode["sigma"] >> sigma;
+ if ( abs(get_error( testCaseIdx, CV_TEST_ERROR ) - mean) > 6*sigma )
+ {
+ ts->printf( CvTS::LOG, "in test case %d test error is out of range", testCaseIdx );
+ return CvTS::FAIL_BAD_ACCURACY;
+ }
+ }
+ else\r
+ {\r
+ ts->printf( CvTS::LOG, "validation info is not suitable" );
+ return CvTS::FAIL_INVALID_TEST_DATA;\r
+ }
+ return CvTS::OK;\r
+}\r
+\r
+CV_AMLTest amldtree( CV_DTREE, "adtree" );\r
+CV_AMLTest amlboost( CV_BOOST, "aboost" );\r
+CV_AMLTest amlrtrees( CV_RTREES, "artrees" );\r
+CV_AMLTest amlertrees( CV_ERTREES, "aertrees" );\r
+\r
+/* End of file. */\r