Changeset 821 for trunk/test


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

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

Location:
trunk/test
Files:
2 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 
  • trunk/test/score_test.cc

    r820 r821  
    6060  for (size_t i=0; i<value.size(); i++)
    6161    value(i)=i;
    62   statistics::AUC auc;
     62  statistics::AUC auc(false);
    6363  double area = auc.score(target, value);
    64   if (area!=1.0){
    65     *error << "test_auc: area is " << area << " should be 1.0"
     64  if (area!=0.0){
     65    *error << "test_auc: area is " << area << " should be 0.0"
    6666           << std::endl;
    6767    ok = false;
     
    8585 
    8686  utility::vector correct_area(3);
    87   correct_area(0)=8.0/9.0;
    88   correct_area(1)=6.0/9.0;
    89   correct_area(2)=1.0;
     87  correct_area(0)=1.0/9.0;
     88  correct_area(1)=3.0/9.0;
     89  correct_area(2)=0.0;
    9090
    9191  const double tol = 0.001;
Note: See TracChangeset for help on using the changeset viewer.