Changeset 1143


Ignore:
Timestamp:
Feb 25, 2008, 3:43:50 PM (16 years ago)
Author:
Markus Ringnér
Message:

Additional test added for #335

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/ncc_test.cc

    r1142 r1143  
    200200  }
    201201
     202  ////////////////////////////////////////////////////////////////
     203  // A test of when a class has no training samples, should give nan
     204  // in predictions.
     205  ////////////////////////////////////////////////////////////////
     206  //Keep only the second class in the training samples
     207  std::vector<size_t> ind(2,2);
     208  ind[1]=3;
     209  classifier::Target target2(target1,utility::Index(ind));
     210  classifier::MatrixLookupWeighted mlw3(data1,weights2,utility::Index(ind),false);
     211  classifier::NCC<statistics::PearsonDistance> ncc5(mlw3,target2);
     212  ncc5.train();
     213  ncc5.predict(mlw1,prediction1);
     214  if (!(std::isnan(prediction1(0,0)) && std::isnan(prediction1(0,1)) &&
     215        std::isnan(prediction1(0,2)) && std::isnan(prediction1(0,3)) &&
     216        std::isnan(prediction1(1,0)) &&
     217        fabs(prediction1(1,1)-2.0)<slack_bound &&
     218        fabs(prediction1(1,2))<slack_bound &&
     219        fabs(prediction1(1,3))<slack_bound)) {
     220    *error << "Difference to expected prediction too large\n";
     221    ok = false;
     222  }
    202223
    203224  //////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.