source: trunk/test/inputranker_test.cc @ 820

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

Changed name again. ROCScore is now called AUC. Also fixed several bugs and added test for these.

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