Changeset 151


Ignore:
Timestamp:
Sep 9, 2004, 6:24:23 PM (17 years ago)
Author:
Peter
Message:

.

Location:
trunk/test
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Makefile.am

    r145 r151  
    44
    55check_PROGRAMS = \
    6   test_crossvalidation test_kernel test_merge test_nni test_pca \
    7   test_rnd test_roc test_statistics test_svd test_svm test_vector
     6  test_consensus_inputranker test_crossvalidation test_inputranker \
     7  test_kernel test_merge test_nni test_pca test_rnd test_roc \
     8  test_statistics test_svd test_svm test_vector
     9
     10test_consensus_inputranker_SOURCES = test_consensus_inputranker.cc
     11test_consensus_inputranker_LDADD = @top_srcdir@/$(CPP_TOOLS_LIB_LOCATION)/$(CPP_TOOLS_LIB) \
     12    $(GSL_LIB) $(CBLAS_LIB) $(MATH_LIB)
    813
    914test_crossvalidation_SOURCES = test_crossvalidation.cc
    1015test_crossvalidation_LDADD = @top_srcdir@/$(CPP_TOOLS_LIB_LOCATION)/$(CPP_TOOLS_LIB) \
     16    $(GSL_LIB) $(CBLAS_LIB) $(MATH_LIB)
     17
     18test_inputranker_SOURCES = test_inputranker.cc
     19test_inputranker_LDADD = @top_srcdir@/$(CPP_TOOLS_LIB_LOCATION)/$(CPP_TOOLS_LIB) \
    1120    $(GSL_LIB) $(CBLAS_LIB) $(MATH_LIB)
    1221
  • trunk/test/data/rank_data.txt

    r147 r151  
    1 1 2 3 4
    2 1 2 4 3
    3 1 3 2 4
    4 1 4 2 3
     15 1 0 2 4 6
     21 3 5 6 4 2
     30 1 2 3 4 5
  • trunk/test/data/rank_target.txt

    r147 r151  
     11
    121
    231
    34-1
    45-1
     6-1
  • trunk/test/test_roc.cc

    r121 r151  
    33// C++ tools include
    44////////////////////
     5#include "matrix.h"
     6#include "ROC.h"
    57#include "vector.h"
    6 #include "ROC.h"
     8
    79
    810// Standard includes
    911////////////////////
    1012#include <gsl/gsl_cdf.h>
     13#include <fstream>
     14#include <iostream>
    1115
    1216
     
    1822  bool ok = true;
    1923  theplu::gslapi::vector value(31);
    20   theplu::gslapi::vector target(31,1);
     24  theplu::gslapi::vector target(31,-1);
    2125  for (unsigned int i=0; i<16; i++)
    22     target(i) = -1;
     26    target(i) = 1;
    2327  for (unsigned int i=0; i<value.size(); i++)
    2428    value(i)=i;
     
    2630  double area = roc.score(target, value);
    2731  if (area!=1.0){
    28     cerr << "test_roc: area should be 1.0" << endl;
     32    cerr << "test_roc a: area is " << area << " should be 1.0" << endl;
    2933    ok = false;
    30   }
     34  }
     35  area = roc.score(-target, value);
     36  if (area!=1.0){
     37    cerr << "test_roc: area is " << area << " should be 1.0" << endl;
     38    ok = false;
     39  }
     40 
    3141  double p = roc.p_value();
    3242  double p_matlab = 0.00000115;
     
    4252  }
    4353 
     54  ifstream is("data/rank_data.txt");
     55  theplu::gslapi::matrix data(is);
     56  is.close();
     57
     58  is.open("data/rank_target.txt");
     59  theplu::gslapi::vector target2(is);
     60  is.close();
     61 
     62  theplu::gslapi::vector correct_area(3);
     63  correct_area(0)=1.0;
     64  correct_area(1)=0.75;
     65  correct_area(2)=0.50;
     66
     67  for (size_t i=0; i<data.rows(); i++){
     68    theplu::gslapi::vector vec = data[i];
     69    area = roc.score(target2,vec);
     70    if (area!=correct_area(i)){
     71      cerr << "test_roc: area is " << area << " should be "
     72           << correct_area(i) << endl;
     73      return -1;
     74    }
     75  }
     76
    4477  if (ok)
    4578    return 0;
Note: See TracChangeset for help on using the changeset viewer.