source: trunk/test/inputranker_test.cc @ 616

Last change on this file since 616 was 616, checked in by Jari Häkkinen, 15 years ago

Removed gslapi namespace and put the code into utility namespace.
Move #ifndef _header_ idiom to top of touched header files.
Removed unneccesary #includes, and added needed #includes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.2 KB
Line 
1// $Id: inputranker_test.cc 616 2006-08-31 08:52:02Z jari $
2
3#include <c++_tools/classifier/InputRanker.h>
4#include <c++_tools/statistics/ROC.h>
5#include <c++_tools/utility/matrix.h>
6#include <c++_tools/classifier/MatrixLookup.h>
7#include <c++_tools/classifier/Target.h>
8
9#include <cstdlib>
10#include <fstream>
11#include <iostream>
12
13
14
15int main(const int argc,const char* argv[])
16{
17  using namespace theplu;
18  std::ostream* error;
19  if (argc>1 && argv[1]==std::string("-v"))
20    error = &std::cerr;
21  else {
22    error = new std::ofstream("/dev/null");
23    if (argc>1)
24      std::cout << "inputranker_test -v : for printing extra information\n";
25  }
26  *error << "testing inputranker" << std::endl;
27  bool ok = true;
28
29  std::ifstream is("data/rank_data.txt");
30  theplu::utility::matrix data_tmp(is);
31  theplu::classifier::MatrixLookup data(data_tmp);
32  is.close();
33
34  is.open("data/rank_target.txt");
35  classifier::Target target(is);
36  is.close();
37
38  statistics::ROC roc;
39  classifier::InputRanker ir(data,target,roc);
40  if (ir.id()[0]!=2 || ir.id()[1]!=0 || ir.id()[2]!=1){
41    *error << "wrong id" << std::endl;
42    ok=false;
43  }
44 
45  if (ir.rank()[0]!=1 || ir.rank()[1]!=2 || ir.rank()[2]!=0){
46    *error << "wrong rank" << std::endl;
47    ok=false;
48  }
49 
50  if (error!=&std::cerr)
51    delete error;
52
53  return (ok ? 0 : -1);
54
55}
Note: See TracBrowser for help on using the repository browser.