Changeset 1727


Ignore:
Timestamp:
Jan 15, 2009, 10:49:39 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Fixes #464. Final tests.

Location:
trunk/test
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/data/knni_matrix.data

    r1725 r1727  
    1111.2234 .77639  .38783  .28953  .62376  .5445 .32489  .22388  .238746 .23468   .1234 
    1212.2388 .234688 .43687  .86456  .65654  .6864 .879645 .98454  .98731  .164897  .1234
    13 .1968 .153987 .13684  .14685  .316135 .5286 .69435  .13634  .18351  .1984531 .1234
     13.1968 .153987 .13684  .14685  .316135 .5286 .69435  .13634  .18351  .1984531 Inf
    1414.6865 .213687 .12368  .18564  .897654 .4945 .789654 .45547  .98466  .66136   .1234
    1515.9835 .963154 .964664 .132369     .983316 .3276 .376513 .34941  .387433 .31685   .1234
  • trunk/test/data/knni_result.data

    r1554 r1727  
    990.2234 0.77639 0.38783 0.28953 0.62376 0.5445 0.32489 0.22388 0.238746 0.23468 0.1234
    10100.2388 0.234688 0.43687 0.86456 0.65654 0.6864 0.879645 0.98454 0.98731 0.164897 0.1234
    11 0.1968 0.153987 0.13684 0.14685 0.316135 0.5286 0.69435 0.13634 0.18351 0.577643004747 0.1234
     110.1968 0.153987 0.13684 0.14685 0.316135 0.5286 0.69435 0.13634 0.18351 0.577643004747 Inf
    12120.6865 0.213687 0.12368 0.18564 0.897654 0.4945 0.789654 0.45547 0.98466 0.66136 0.1234
    13130.9835 0.963154 0.964664 0.132369 0.983316 0.3276 0.376513 0.34941 0.387433 0.31685 0.1234
  • trunk/test/data/wenni_result.data

    r1554 r1727  
    990.2234 0.77639 0.38783 0.28953 0.62376 0.5445 0.32489 0.22388 0.238746 0.23468 0.1234
    10100.2388 0.234688 0.43687 0.86456 0.65654 0.6864 0.879645 0.98454 0.98731 0.164897 0.1234
    11 0.1968 0.153987 0.13684 0.14685 0.316135 0.5286 0.69435 0.13634 0.18351 0.577488912729 0.1234
     110.1968 0.153987 0.13684 0.14685 0.316135 0.5286 0.69435 0.13634 0.18351 0.577488912729 Inf
    12120.6865 0.213687 0.12368 0.18564 0.897654 0.4945 0.789654 0.45547 0.98466 0.66136 0.1234
    13130.9835 0.963154 0.964664 0.132369 0.983316 0.3276 0.376513 0.34941 0.387433 0.31685 0.1234
  • trunk/test/nni_test.cc

    r1726 r1727  
    4848{
    4949  test::Suite suite(argc, argv);
     50  suite.err() << "Testing NNI algorithms" << std::endl;
    5051
     52  suite.err() << "Reading data" << std::endl;
    5153  unsigned int neighbours=3;
    5254  std::string knni_data(test::filename("data/knni_matrix.data"));
     
    6466
    6567  // test kNNI
     68  suite.err() << "Testing kNNI" << std::endl;
    6669  std::ifstream data_stream(knni_data.c_str());
    6770  std::ifstream weight_stream(knni_weight.c_str());
     
    7982  for (unsigned int i=0; i<control.rows(); i++)
    8083    for (unsigned int j=0; j<control.columns(); j++)
    81       if (!suite.equal_fix(knni.imputed_data()(i,j),control(i,j),error_bound)) {
     84      if ((i==10) && (j==10)) {
     85        if (!std::isnan(knni.imputed_data()(i,j)-control(i,j))) {
     86          suite.err() << "kNNI FAILED, error on row " << i << " and "
     87                      << "column " << j << " expected NaN" << std::endl;
     88          suite.add(false);
     89        }
     90      }
     91      else if (!suite.equal_fix(knni.imputed_data()(i,j),control(i,j),error_bound)) {
    8292        suite.err() << "kNNI FAILED, error on row " << i << " and "
    83                     << "column " << j << " is" << std::endl;
     93                    << "column " << j << std::endl;
    8494        suite.add(false); // calculation result out of accepted error bounds
    8595      }
     
    8999
    90100  // test WeNNI
     101  suite.err() << "Testing WeNNI" << std::endl;
    91102  data_stream.open(wenni_data.c_str());
    92103  data=utility::Matrix(data_stream);
     
    103114  for (unsigned int i=0; i<control.rows(); i++)
    104115    for (unsigned int j=0; j<control.columns(); j++)
    105       if (!suite.equal_fix(wenni.imputed_data()(i,j),control(i,j),error_bound)){
     116      if ((i==10) && (j==10)) {
     117        if (!std::isnan(knni.imputed_data()(i,j)-control(i,j))) {
     118          suite.err() << "WeNNI FAILED, error on row " << i << " and "
     119                      << "column " << j << " expected NaN" << std::endl;
     120          suite.add(false);
     121        }
     122      }
     123      else if (!suite.equal_fix(wenni.imputed_data()(i,j),control(i,j),error_bound)){
    106124        suite.err() << "WeNNI FAILED, error on row " << i << " and "
    107125                    << "column " << j << std::endl;
     
    113131
    114132  // test WeNNI with binary weights
     133  suite.err() << "Testing WeNNI with binary weights" << std::endl;
    115134  data_stream.open(knni_data.c_str());
    116135  data=utility::Matrix(data_stream);
     
    128147  for (unsigned int i=0; i<control.rows(); i++)
    129148    for (unsigned int j=0; j<control.columns(); j++)
    130       if (!suite.equal_fix(wenni2.imputed_data()(i,j),control(i,j),error_bound)){
     149      if ((i==10) && (j==10)) {
     150        if (!std::isnan(knni.imputed_data()(i,j)-control(i,j))) {
     151          suite.err() << "binary WeNNI FAILED, error on row " << i << " and "
     152                      << "column " << j << " expected NaN" << std::endl;
     153          suite.add(false);
     154        }
     155      }
     156      else if (!suite.equal_fix(wenni2.imputed_data()(i,j),control(i,j),error_bound)){
    131157        suite.err() << "WeNNI binary weight test FAILED.\nError on row " << i
    132158                    << " and column " << j << std::endl;
Note: See TracChangeset for help on using the changeset viewer.