source: trunk/test/inputranker_test.cc @ 475

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

I dont know what happened, but everything is changed...

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