Changeset 116


Ignore:
Timestamp:
Jul 19, 2004, 4:40:11 PM (19 years ago)
Author:
Peter
Message:

test_crossvalidation and test_statistics added

Location:
trunk/test
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Makefile.am

    r93 r116  
    33## $Id$
    44
    5 check_PROGRAMS = test_kernel test_merge test_pca test_rnd test_roc \
    6      test_svd test_svm test_wead
     5check_PROGRAMS = test_crossvalidation test_kernel test_merge test_pca test_rnd test_roc \
     6     test_statistics test_svd test_svm test_wead
     7
     8test_crossvalidation_SOURCES = test_crossvalidation.cc
     9test_crossvalidation_LDADD = @top_srcdir@/$(CPP_TOOLS_LIB_LOCATION)/$(CPP_TOOLS_LIB) \
     10    $(GSL_LIB) $(CBLAS_LIB) $(MATH_LIB)
    711
    812test_kernel_SOURCES = test_kernel.cc
     
    2630    $(GSL_LIB) $(CBLAS_LIB) $(MATH_LIB)
    2731
     32test_statistics_SOURCES = test_statistics.cc
     33test_statistics_LDADD = @top_srcdir@/$(CPP_TOOLS_LIB_LOCATION)/$(CPP_TOOLS_LIB) \
     34    $(GSL_LIB) $(CBLAS_LIB) $(MATH_LIB)
     35
    2836test_svd_SOURCES = test_svd.cc
    2937test_svd_LDADD = @top_srcdir@/$(CPP_TOOLS_LIB_LOCATION)/$(CPP_TOOLS_LIB) \
  • trunk/test/test_svm.cc

    r73 r116  
    2020
    2121
    22   cout << "reading data/nm_kernel.txt" << endl;
    2322  ifstream is("data/nm_kernel.txt");
    2423  theplu::gslapi::matrix kernel(is);
    2524  is.close();
    26 
    2725  theplu::gslapi::matrix k(kernel);
    2826 
    29   cout << "reading data/nm_target_bin.txt" << endl;
    3027  is.open("data/nm_target_bin.txt");
    3128  theplu::gslapi::vector target(is);
    3229  is.close();
    3330
    34   cout << "reading data/nm_alpha_linear_matlab.txt" << endl;
    3531  is.open("data/nm_alpha_linear_matlab.txt");
    3632  theplu::gslapi::vector alpha_matlab(is);
     
    3834
    3935
    40   cout << "create svm" << endl;
    4136  theplu::cpptools::SVM svm(kernel, target);
    42   cout << "train" << endl;
    4337  svm.train();
    44   cout << "get alpha" << endl;
     38
    4539  theplu::gslapi::vector alpha = svm.get_alpha();
    4640     
    4741  // Comparing alpha to alpha_matlab
    4842  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  }
    5147  // Comparing output to target
    5248  theplu::gslapi::vector output = svm.get_output();
     
    5753    }
    5854  }
    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  }
    6159  return 0;
     60 
    6261}
Note: See TracChangeset for help on using the changeset viewer.