Changeset 453 for trunk/test/svm_test.cc
- Timestamp:
- Dec 15, 2005, 10:49:23 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/svm_test.cc
r442 r453 3 3 #include <c++_tools/gslapi/matrix.h> 4 4 #include <c++_tools/gslapi/vector.h> 5 #include <c++_tools/ svm/SVM.h>6 #include <c++_tools/ svm/Kernel.h>7 #include <c++_tools/ svm/Kernel_SEV.h>8 #include <c++_tools/ svm/Kernel_MEV.h>9 #include <c++_tools/ svm/PolynomialKernelFunction.h>5 #include <c++_tools/classifier/SVM.h> 6 #include <c++_tools/classifier/Kernel.h> 7 #include <c++_tools/classifier/Kernel_SEV.h> 8 #include <c++_tools/classifier/Kernel_MEV.h> 9 #include <c++_tools/classifier/PolynomialKernelFunction.h> 10 10 11 11 #include <cassert> … … 34 34 target2(1)=1; 35 35 target2(2)=1; 36 svm::KernelFunction* kf2 = new svm::PolynomialKernelFunction();37 svm::Kernel_MEV kernel2(data2,*kf2);36 classifier::KernelFunction* kf2 = new classifier::PolynomialKernelFunction(); 37 classifier::Kernel_MEV kernel2(data2,*kf2); 38 38 assert(kernel2.size()==3); 39 svm::SVM svm2(kernel2, target2);40 svm2.train();39 classifier::SVM classifier2(kernel2, target2); 40 classifier2.train(); 41 41 42 if ( svm2.alpha()*target2){42 if (classifier2.alpha()*target2){ 43 43 std::cerr << "condition not fullfilled" << std::endl; 44 44 return -1; 45 45 } 46 46 47 if ( svm2.alpha()(1)!=2 || svm2.alpha()(2)!=2){47 if (classifier2.alpha()(1)!=2 || classifier2.alpha()(2)!=2){ 48 48 std::cerr << "wrong alpha" << std::endl; 49 std::cerr << "alpha: " << svm2.alpha() << std::endl;49 std::cerr << "alpha: " << classifier2.alpha() << std::endl; 50 50 std::cerr << "expected: 4 2 2" << std::endl; 51 51 … … 61 61 gslapi::matrix data=transposed_data; 62 62 63 svm::KernelFunction* kf = new svm::PolynomialKernelFunction();64 svm::Kernel_SEV kernel(data,*kf);63 classifier::KernelFunction* kf = new classifier::PolynomialKernelFunction(); 64 classifier::Kernel_SEV kernel(data,*kf); 65 65 66 66 … … 73 73 is.close(); 74 74 75 theplu:: svm::SVM svm(kernel, target);76 if (! svm.train()){75 theplu::classifier::SVM classifier(kernel, target); 76 if (!classifier.train()){ 77 77 ok=false; 78 78 if (print) … … 80 80 } 81 81 82 theplu::gslapi::vector alpha = svm.alpha();82 theplu::gslapi::vector alpha = classifier.alpha(); 83 83 84 84 // Comparing alpha to alpha_matlab … … 92 92 93 93 // Comparing output to target 94 theplu::gslapi::vector output( svm.output());94 theplu::gslapi::vector output(classifier.output()); 95 95 double slack = 0; 96 96 for (unsigned int i=0; i<target.size(); i++){
Note: See TracChangeset
for help on using the changeset viewer.