Changeset 46


Ignore:
Timestamp:
Mar 2, 2004, 11:22:53 AM (18 years ago)
Author:
Peter
Message:

get_output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/test_svm.cc

    r42 r46  
    2323  theplu::gslapi::matrix kernel(is);
    2424  is.close();
     25
     26  theplu::gslapi::matrix k(kernel);
    2527 
    2628  cout << "reading nm_target_bin.txt" << endl;   
    2729  is.open("nm_target_bin.txt");
    28   //is.open("t.txt");
     30 
    2931  theplu::gslapi::vector target(is);
    3032  is.close();
     
    3739  //training the SVM
    3840  cout << "Training the SVM" << endl;   
    39   theplu::cpptools::SVM svm(kernel,target);
     41  theplu::cpptools::SVM svm(kernel, target);
     42  cout << "Training the SVM" << endl;   
    4043  svm.train();
    4144 
     
    5053  cout << diff_alpha*diff_alpha << endl;
    5154 
    52   //ofstream myout("alpha.tst");
    53   //myout << a[1] << endl;
    54   //cout << a[0] << endl;
    55   //myout.close();
     55  // Comparing output to target
     56  theplu::gslapi::vector output = svm.get_output();
     57  double slack = 0;
     58  for (unsigned int i=0; i<target.size(); i++){
     59   if (output[i]*target[i] < 1){
     60    slack += 1 - output[i]*target[i];
     61   }
     62  }
     63  cout << "slack:" << slack << endl;
     64 
    5665  return 0;
    5766}
Note: See TracChangeset for help on using the changeset viewer.