Changeset 1155


Ignore:
Timestamp:
Feb 26, 2008, 9:46:43 AM (13 years ago)
Author:
Markus Ringnér
Message:

Refs. #335, fixed for KNN

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/knn_test.cc

    r1142 r1155  
    213213  ////////////////////////////////////////////////////////////////
    214214  // A test of when a test sample has no variables with non-zero
    215   // weights in common with training samples: should give nan distance
    216   ////////////////////////////////////////////////////////////////
    217   *error << "test of predictions with nan distances\n";
     215  // weights in common with training samples: should not vote
     216  ////////////////////////////////////////////////////////////////
     217  *error << "test of predictions with nan distances (set to infinity in KNN)\n";
    218218  weights1.all(1);
    219219  weights1(1,0)=weights1(1,1)=weights1(2,0)=weights1(2,1)=0.0;
     
    224224  knn6.train();
    225225  knn6.predict(mlw3,prediction1);
    226   // std::cout << "train:\n" << mlw1 << std::endl;
    227   // std::cout << "test:\n" << mlw3 << std::endl;
    228   // std::cout << "pred:\n" << prediction1 << std::endl;
     226  result1(0,0)=0;
     227  result1(0,2)=result1(1,1)=result1(1,3)=1.0;
     228  result1(0,1)=result1(0,3)=result1(1,0)=result1(1,2)=2.0;
     229  slack = deviation(prediction1,result1);
     230  if (slack > slack_bound || std::isnan(slack)){
     231    *error << "Difference to expected prediction too large\n";
     232    *error << "slack: " << slack << std::endl;
     233    *error << "expected less than " << slack_bound << std::endl;
     234    ok = false;
     235  }
     236 
    229237
    230238
Note: See TracChangeset for help on using the changeset viewer.