Ignore:
Timestamp:
Feb 26, 2008, 2:25:19 PM (14 years ago)
Author:
Markus Ringnér
Message:

Refs #318

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/knn_test.cc

    r1155 r1157  
    8484  classifier::Target target1(vec1);
    8585 
    86   classifier::KNN<statistics::EuclideanDistance> knn1(ml1,target1);
     86  classifier::KNN<statistics::EuclideanDistance> knn1;
    8787  knn1.k(3);
    88   knn1.train();
     88  knn1.train(ml1,target1);
    8989  utility::Matrix prediction1;
    9090  knn1.predict(ml1,prediction1);
     
    129129  weights2(2,3)=0;
    130130  classifier::MatrixLookupWeighted mlw2(data1,weights2);
    131   classifier::KNN<statistics::EuclideanDistance> knn2(mlw2,target1);
     131  classifier::KNN<statistics::EuclideanDistance> knn2;
    132132  knn2.k(3);
    133   knn2.train();
     133  knn2.train(mlw2,target1);
    134134  knn2.predict(mlw1,prediction1);
    135135  result1(0,1)=1.0;
     
    151151  data2(1,3)=7;
    152152  classifier::MatrixLookupWeighted mlw3(data2,weights2);
    153   classifier::KNN<statistics::EuclideanDistance,classifier::KNN_ReciprocalRank>
    154     knn3(mlw2,target1);
     153  classifier::KNN<statistics::EuclideanDistance,classifier::KNN_ReciprocalRank> knn3;
    155154  knn3.k(3);
    156   knn3.train();
     155  knn3.train(mlw2,target1);
    157156  knn3.predict(mlw3,prediction1);
    158157  result1(0,0)=result1(1,3)=1.0;
     
    174173  *error << "... reciprokal distance neighbor weighting" << std::endl;
    175174  classifier::KNN<statistics::EuclideanDistance,classifier::KNN_ReciprocalDistance>
    176     knn4(mlw2,target1);
     175    knn4;
    177176  knn4.k(3);
    178   knn4.train();
     177  knn4.train(mlw2,target1);
    179178  knn4.predict(mlw3,prediction1);
    180179  if (!(std::isinf(prediction1(0,0)) && std::isinf(prediction1(0,1)) &&
     
    197196  classifier::Target target2(target1,utility::Index(ind));
    198197  classifier::MatrixLookupWeighted mlw4(data1,weights2,utility::Index(ind),false);
    199   classifier::KNN<statistics::EuclideanDistance> knn5(mlw4,target2);
     198  classifier::KNN<statistics::EuclideanDistance> knn5;
    200199  knn5.k(3);
    201   knn5.train();
     200  knn5.train(mlw4,target2);
    202201  knn5.predict(mlw3,prediction1);
    203202  if (!(std::isnan(prediction1(0,0)) && std::isnan(prediction1(0,1)) &&
     
    220219  weights2.all(1);
    221220  weights2(0,0)=0.0;
    222   classifier::KNN<statistics::EuclideanDistance> knn6(mlw1,target1);
     221  classifier::KNN<statistics::EuclideanDistance> knn6;
    223222  knn6.k(3);
    224   knn6.train();
     223  knn6.train(mlw1,target1);
    225224  knn6.predict(mlw3,prediction1);
    226225  result1(0,0)=0;
Note: See TracChangeset for help on using the changeset viewer.