source: trunk/test/ensemble_test.cc @ 527

Last change on this file since 527 was 527, checked in by Peter, 16 years ago

Modified Kernel to be built from MatrixLookup? rather than
gslapi::matrix. Also changed interface to create DataLookup1D from
DataLookup2D - is now coherent with gslapi.

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