source: trunk/test/consensus_inputranker_test.cc @ 668

Last change on this file since 668 was 668, checked in by Peter, 17 years ago

removing debug code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1// $Id: consensus_inputranker_test.cc 668 2006-10-06 07:05:50Z peter $
2
3// C++ tools include
4////////////////////
5#include <c++_tools/classifier/ConsensusInputRanker.h>
6#include <c++_tools/statistics/ROC.h>
7#include <c++_tools/utility/matrix.h>
8#include <c++_tools/classifier/MatrixLookup.h>
9#include <c++_tools/classifier/CrossValidationSampler.h>
10#include <c++_tools/classifier/IRRank.h>
11
12#include <cstdlib>
13#include <fstream>
14#include <iostream>
15//#include <vector>
16
17using namespace std;
18
19int main(const int argc,const char* argv[])
20{ 
21  std::ostream* error;
22  if (argc>1 && argv[1]==std::string("-v"))
23    error = &std::cerr;
24  else {
25    error = new std::ofstream("/dev/null");
26    if (argc>1)
27      std::cout << "consensus_inputranker_test -v : for printing extra " 
28                << "information\n";
29  }
30  *error << "testing consensus_inputranker" << std::endl;
31  bool ok = true;
32
33  ifstream is("data/rank_data.txt");
34  theplu::utility::matrix data_tmp(is);
35  theplu::classifier::MatrixLookup data(data_tmp);
36  is.close();
37
38  is.open("data/rank_target.txt");
39  theplu::classifier::Target target(is);
40  is.close();
41
42 
43  theplu::statistics::ROC roc;
44  theplu::classifier::CrossValidationSampler sampler(target,30,3);
45  *error << "Building Consensus_Inputranker" << std::endl;
46  theplu::classifier::IRRank retrieve;
47  theplu::classifier::ConsensusInputRanker cir(sampler,data,roc,retrieve);
48  *error << "Done" << std::endl;
49
50  if (cir.id(0)!=2 || cir.id(1)!=0 || cir.id(2)!=1){
51    *error << "incorrect id" << endl;
52    ok = false;
53  }
54 
55  if (cir.rank(0)!=1 || cir.rank(1)!=2 || cir.rank(2)!=0){
56    *error << "incorrect rank" << endl;
57    ok=false;
58  }
59
60  theplu::utility::matrix flag(data.rows(),data.columns(),1);
61  // Peter, fix weighted version instead
62  theplu::classifier::ConsensusInputRanker cir2(sampler,data,roc,retrieve);
63
64  if (cir2.id(0)!=2 || cir2.id(1)!=0 || cir2.id(2)!=1){
65    *error << "incorrect id for weighted" << endl;
66    ok=false;
67  }
68 
69  if (cir2.rank(0)!=1 || cir2.rank(1)!=2 || cir2.rank(2)!=0){
70    *error << "incorrect rank for weighted" << endl;
71    ok=false;
72  }
73 
74 
75  if (error!=&std::cerr)
76    delete error;
77
78  if(ok)
79    return 0;
80  return -1;
81}
Note: See TracBrowser for help on using the repository browser.