source: trunk/test/inputranker_test.cc @ 831

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

Refs #185.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
RevLine 
[151]1// $Id: inputranker_test.cc 831 2007-03-27 13:22:09Z peter $
2
[675]3/*
[831]4  Copyright (C) 2004, 2005 Peter Johansson
5  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
6  Copyright (C) 2007 Peter Johansson
[151]7
[675]8  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
9
10  The yat library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License as
12  published by the Free Software Foundation; either version 2 of the
13  License, or (at your option) any later version.
14
15  The yat library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23  02111-1307, USA.
24*/
25
26#include "yat/classifier/InputRanker.h"
[820]27#include "yat/statistics/AUC.h"
[675]28#include "yat/utility/matrix.h"
29#include "yat/classifier/MatrixLookup.h"
30#include "yat/classifier/Target.h"
31
[151]32#include <cstdlib>
33#include <fstream>
34#include <iostream>
35
36
[475]37
38int main(const int argc,const char* argv[])
39{
[680]40  using namespace theplu::yat;
[475]41  std::ostream* error;
42  if (argc>1 && argv[1]==std::string("-v"))
43    error = &std::cerr;
44  else {
45    error = new std::ofstream("/dev/null");
46    if (argc>1)
47      std::cout << "inputranker_test -v : for printing extra information\n";
48  }
49  *error << "testing inputranker" << std::endl;
50  bool ok = true;
51
[301]52  std::ifstream is("data/rank_data.txt");
[680]53  theplu::yat::utility::matrix data_tmp(is);
54  theplu::yat::classifier::MatrixLookup data(data_tmp);
[151]55  is.close();
56
57  is.open("data/rank_target.txt");
[475]58  classifier::Target target(is);
[151]59  is.close();
60
[820]61  statistics::AUC roc;
[453]62  classifier::InputRanker ir(data,target,roc);
[604]63  if (ir.id()[0]!=2 || ir.id()[1]!=0 || ir.id()[2]!=1){
[475]64    *error << "wrong id" << std::endl;
65    ok=false;
[151]66  }
67 
[604]68  if (ir.rank()[0]!=1 || ir.rank()[1]!=2 || ir.rank()[2]!=0){
[475]69    *error << "wrong rank" << std::endl;
70    ok=false;
[151]71  }
72 
[475]73  if (error!=&std::cerr)
74    delete error;
75
76  return (ok ? 0 : -1);
77
[151]78}
Note: See TracBrowser for help on using the repository browser.