Changeset 821 for trunk/test/roc_test.cc


Ignore:
Timestamp:
Mar 18, 2007, 5:00:05 PM (15 years ago)
Author:
Peter
Message:

Modified ROC class to use AUC class in calculation of ROC area. Refs #101

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/roc_test.cc

    r779 r821  
    5555    value(i)=i;
    5656  statistics::ROC roc;
    57   double area = roc.score(target, value);
     57  for (size_t i=0; i<value.size(); ++i){
     58    roc.add(value(i), target.binary(i));
     59  }
     60  double area = roc.area();
    5861  if (area!=0.0){
    5962    *error << "test_roc: area is " << area << " should be 0.0"
     
    6366  target.set_binary(0,false);
    6467  target.set_binary(1,true);
    65   area = roc.score(target, value);
     68  roc.reset();
     69  for (size_t i=0; i<value.size(); ++i)
     70    roc.add(value(i), target.binary(i));
     71  area = roc.area();
    6672  if (area!=1.0){
    6773    *error << "test_roc: area is " << area << " should be 1.0"
     
    7076  }
    7177 
    72   double p = roc.p_value();
     78  double p = roc.p_value_one_sided();
     79  double p2 = roc.p_value();
    7380  double p_matlab = 0.00000115;
    7481  if (p/p_matlab > 1.01 | p/p_matlab < 0.99){
    7582    *error << "get_p_approx: p-value not correct" << std::endl;
     83    *error << p << " expected " << p_matlab << std::endl;
    7684    ok = false;
    7785  }
     86  if (p2 != 2*p) {
     87    ok = false;
     88    *error << "Two-sided P-value should equal 2 * one-sided P-value.\n";
     89  }
    7890  roc.minimum_size() = 20;
    79   p = roc.p_value();
     91  p = roc.p_value_one_sided();
     92  p2 = roc.p_value();
    8093  if (p > pow(10, -8.0) | p < pow(10, -9.0)){
    8194    *error << "get_p_exact: p-value not correct" << std::endl;
    8295    ok = false;
     96  }
     97  if (p2 != 2*p) {
     98    ok = false;
     99    *error << "Two-sided P-value should equal 2 * one-sided P-value.\n";
    83100  }
    84101 
Note: See TracChangeset for help on using the changeset viewer.