source: trunk/test/inputranker_test.cc @ 604

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

ref #96 Changed InputRanker? to return vector of index rather than element. Also added draft to FeatureSelection? class.

  • 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 604 2006-08-29 09:45:01Z 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  if (ir.rank()[0]!=1 || ir.rank()[1]!=2 || ir.rank()[2]!=0){
47    *error << "wrong rank" << std::endl;
48    ok=false;
49  }
50 
51  if (error!=&std::cerr)
52    delete error;
53
54  return (ok ? 0 : -1);
55
56}
Note: See TracBrowser for help on using the repository browser.