Changeset 116 for trunk/test/test_svm.cc
- Timestamp:
- Jul 19, 2004, 4:40:11 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/test_svm.cc
r73 r116 20 20 21 21 { 22 cout << "reading data/nm_kernel.txt" << endl;23 22 ifstream is("data/nm_kernel.txt"); 24 23 theplu::gslapi::matrix kernel(is); 25 24 is.close(); 26 27 25 theplu::gslapi::matrix k(kernel); 28 26 29 cout << "reading data/nm_target_bin.txt" << endl;30 27 is.open("data/nm_target_bin.txt"); 31 28 theplu::gslapi::vector target(is); 32 29 is.close(); 33 30 34 cout << "reading data/nm_alpha_linear_matlab.txt" << endl;35 31 is.open("data/nm_alpha_linear_matlab.txt"); 36 32 theplu::gslapi::vector alpha_matlab(is); … … 38 34 39 35 40 cout << "create svm" << endl;41 36 theplu::cpptools::SVM svm(kernel, target); 42 cout << "train" << endl;43 37 svm.train(); 44 cout << "get alpha" << endl; 38 45 39 theplu::gslapi::vector alpha = svm.get_alpha(); 46 40 47 41 // Comparing alpha to alpha_matlab 48 42 theplu::gslapi::vector diff_alpha = alpha - alpha_matlab; 49 cout << diff_alpha*diff_alpha << endl; 50 43 if (diff_alpha*diff_alpha> pow(10.0,-10)){ 44 cerr << "Difference to matlab alphas too large/n"; 45 return -1; 46 } 51 47 // Comparing output to target 52 48 theplu::gslapi::vector output = svm.get_output(); … … 57 53 } 58 54 } 59 cout << "slack:" << slack << endl; 60 55 if (slack > pow(10.0,-10)){ 56 cerr << "Difference to matlab alphas too large/n"; 57 return -1; 58 } 61 59 return 0; 60 62 61 }
Note: See TracChangeset
for help on using the changeset viewer.