Changeset 1246
 Timestamp:
 Mar 17, 2008, 1:58:43 PM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/roc_test.cc
r1145 r1246 22 22 */ 23 23 24 #include "Suite.h" 25 24 26 #include "yat/classifier/DataLookupWeighted1D.h" 25 27 #include "yat/classifier/Target.h" … … 35 37 using namespace theplu::yat; 36 38 37 int main( const int argc,constchar* argv[])39 int main(int argc, char* argv[]) 38 40 { 39 std::ostream* error; 40 if (argc>1 && argv[1]==std::string("v")) 41 error = &std::cerr; 42 else { 43 error = new std::ofstream("/dev/null"); 44 if (argc>1) 45 std::cout << "roc_test v : for printing extra information\n"; 46 } 47 bool ok = true; 41 test::Suite suite(argc, argv); 48 42 49 *error<< "testing ROC" << std::endl;43 suite.err() << "testing ROC" << std::endl; 50 44 utility::Vector value(31); 51 45 std::vector<std::string> label(31,"negative"); … … 58 52 add(roc, value.begin(), value.end(), target); 59 53 double area = roc.area(); 60 if ( area!=0.0){61 *error<< "test_roc: area is " << area << " should be 0.0"54 if (!suite.equal(area,0.0)){ 55 suite.err() << "test_roc: area is " << area << " should be 0.0" 62 56 << std::endl; 63 ok = false;57 suite.add(false); 64 58 } 65 59 target.set_binary(0,false); … … 68 62 add(roc, value.begin(), value.end(), target); 69 63 area = roc.area(); 70 if ( area!=1.0){71 *error<< "test_roc: area is " << area << " should be 1.0"64 if (!suite.equal(area,1.0)){ 65 suite.err() << "test_roc: area is " << area << " should be 1.0" 72 66 << std::endl; 73 ok = false;67 suite.add(false); 74 68 } 75 69 … … 77 71 double p2 = roc.p_value(); 78 72 double p_matlab = 0.00000115; 79 if ( p/p_matlab > 1.01  p/p_matlab < 0.99){80 *error<< "get_p_approx: pvalue not correct" << std::endl;81 *error<< p << " expected " << p_matlab << std::endl;82 ok = false;73 if (!(p/p_matlab < 1.01 && p/p_matlab > 0.99)){ 74 suite.err() << "get_p_approx: pvalue not correct" << std::endl; 75 suite.err() << p << " expected " << p_matlab << std::endl; 76 suite.add(false); 83 77 } 84 if ( p2 != 2*p) {85 ok = false;86 *error<< "Twosided Pvalue should equal 2 * onesided Pvalue.\n";78 if (!(p2==2*p)) { 79 suite.add(false); 80 suite.err() << "Twosided Pvalue should equal 2 * onesided Pvalue.\n"; 87 81 } 88 82 roc.minimum_size() = 20; 89 83 p = roc.p_value_one_sided(); 90 84 p2 = roc.p_value(); 91 if ( p > pow(10, 8.0)  p < pow(10, 9.0)){92 *error<< "get_p_exact: pvalue not correct" << std::endl;93 ok = false;85 if (!( p < 1e8 && p > 1e9) ){ 86 suite.err() << "get_p_exact: pvalue not correct" << std::endl; 87 suite.add(false); 94 88 } 95 if ( p2 != 2*p) {96 ok = false;97 *error<< "Twosided Pvalue should equal 2 * onesided Pvalue.\n";89 if (!( p2==2*p)) { 90 suite.add(false); 91 suite.err() << "Twosided Pvalue should equal 2 * onesided Pvalue.\n"; 98 92 } 99 93 … … 101 95 add(roc, dlw.begin(), dlw.end(), target); 102 96 103 if (ok) 104 return 0; 105 return 1; 97 return suite.return_value(); 106 98 }
Note: See TracChangeset
for help on using the changeset viewer.