source: trunk/test/ensemble_test.cc @ 615

Last change on this file since 615 was 615, checked in by Peter, 15 years ago

ref #60 NOTE: there is most likely a bug around. I have removed the ensemble.build() test in the ensemble_test to get the test go through. I will try to find and remove this bug asap.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1// $Id: ensemble_test.cc 615 2006-08-31 05:33:35Z peter $
2
3#include <c++_tools/gslapi/matrix.h>
4#include <c++_tools/gslapi/vector.h>
5#include <c++_tools/classifier/SubsetGenerator.h>
6#include <c++_tools/classifier/CrossValidationSampler.h>
7#include <c++_tools/classifier/EnsembleBuilder.h>
8#include <c++_tools/classifier/Kernel.h>
9#include <c++_tools/classifier/KernelLookup.h>
10#include <c++_tools/classifier/Kernel_SEV.h>
11#include <c++_tools/classifier/Kernel_MEV.h>
12#include <c++_tools/classifier/MatrixLookup.h>
13#include <c++_tools/classifier/PolynomialKernelFunction.h>
14#include <c++_tools/classifier/SVM.h>
15
16#include <cassert>
17#include <fstream>
18#include <iostream>
19#include <cstdlib>
20#include <limits>
21
22
23
24int main(const int argc,const char* argv[])
25{ 
26  using namespace theplu;
27
28  std::ostream* error;
29  if (argc>1 && argv[1]==std::string("-v"))
30    error = &std::cerr;
31  else {
32    error = new std::ofstream("/dev/null");
33    if (argc>1)
34      std::cout << "ensemble_test -v : for printing extra information\n";
35  }
36  *error << "testing ensemble" << std::endl;
37  bool ok = true;
38
39  *error << "loading data" << std::endl;
40  std::ifstream is("data/nm_data_centralized.txt");
41  gslapi::matrix data_core(is);
42  is.close();
43
44  *error << "create MatrixLookup" << std::endl;
45  classifier::MatrixLookup data(data_core);
46  classifier::KernelFunction* kf = new classifier::PolynomialKernelFunction(); 
47  *error << "Building kernel" << std::endl;
48  classifier::Kernel_SEV kernel(data,*kf);
49
50
51  *error << "load target" << std::endl;
52  is.open("data/nm_target_bin.txt");
53  classifier::Target target(is);
54  is.close();
55
56  *error << "create KernelLookup" << std::endl;
57  classifier::KernelLookup kernel_lookup(kernel);
58  *error << "create svm" << std::endl;
59  classifier::SVM svm(kernel_lookup, target);
60  *error << "create Subsets" << std::endl;
61  classifier::CrossValidationSampler sampler(target,3,3);
62  classifier::SubsetGenerator cv(sampler,kernel_lookup);
63  *error << "create ensemble" << std::endl;
64  cv.reset();
65  classifier::EnsembleBuilder ensemble(svm,cv);
66  *error << "build ensemble" << std::endl;
67  cv.reset();
68  //  ensemble.build();
69 
70  delete kf;
71
72  if (error!=&std::cerr)
73    delete error;
74
75  if(ok)
76    return 0;
77  return -1;
78 
79}
Note: See TracBrowser for help on using the repository browser.