158 |
16 Sep 04 |
peter |
// $Id$ |
158 |
16 Sep 04 |
peter |
2 |
|
675 |
10 Oct 06 |
jari |
3 |
/* |
831 |
27 Mar 07 |
peter |
Copyright (C) 2004, 2005 Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2006 Jari Häkkinen, Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2007 Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2012 Peter Johansson |
158 |
16 Sep 04 |
peter |
9 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
675 |
10 Oct 06 |
jari |
11 |
|
675 |
10 Oct 06 |
jari |
The yat library is free software; you can redistribute it and/or |
675 |
10 Oct 06 |
jari |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
675 |
10 Oct 06 |
jari |
License, or (at your option) any later version. |
675 |
10 Oct 06 |
jari |
16 |
|
675 |
10 Oct 06 |
jari |
The yat library is distributed in the hope that it will be useful, |
675 |
10 Oct 06 |
jari |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
675 |
10 Oct 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
675 |
10 Oct 06 |
jari |
General Public License for more details. |
675 |
10 Oct 06 |
jari |
21 |
|
675 |
10 Oct 06 |
jari |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
675 |
10 Oct 06 |
jari |
24 |
*/ |
675 |
10 Oct 06 |
jari |
25 |
|
2881 |
18 Nov 12 |
peter |
26 |
#include <config.h> |
2881 |
18 Nov 12 |
peter |
27 |
|
1232 |
15 Mar 08 |
peter |
28 |
#include "Suite.h" |
1232 |
15 Mar 08 |
peter |
29 |
|
675 |
10 Oct 06 |
jari |
30 |
#include "yat/classifier/ConsensusInputRanker.h" |
820 |
17 Mar 07 |
peter |
31 |
#include "yat/statistics/AUC.h" |
1121 |
22 Feb 08 |
peter |
32 |
#include "yat/utility/Matrix.h" |
675 |
10 Oct 06 |
jari |
33 |
#include "yat/classifier/MatrixLookup.h" |
675 |
10 Oct 06 |
jari |
34 |
#include "yat/classifier/CrossValidationSampler.h" |
675 |
10 Oct 06 |
jari |
35 |
#include "yat/classifier/IRRank.h" |
828 |
19 Mar 07 |
peter |
36 |
#include "yat/statistics/VectorFunction.h" |
675 |
10 Oct 06 |
jari |
37 |
|
158 |
16 Sep 04 |
peter |
38 |
#include <cstdlib> |
158 |
16 Sep 04 |
peter |
39 |
#include <fstream> |
158 |
16 Sep 04 |
peter |
40 |
#include <iostream> |
158 |
16 Sep 04 |
peter |
41 |
|
158 |
16 Sep 04 |
peter |
42 |
using namespace std; |
158 |
16 Sep 04 |
peter |
43 |
|
1232 |
15 Mar 08 |
peter |
44 |
int main(int argc, char* argv[]) |
4200 |
19 Aug 22 |
peter |
45 |
{ |
1251 |
03 Apr 08 |
peter |
46 |
using namespace theplu::yat; |
1232 |
15 Mar 08 |
peter |
47 |
theplu::yat::test::Suite suite(argc, argv); |
1232 |
15 Mar 08 |
peter |
48 |
suite.err() << "testing consensus_inputranker" << std::endl; |
475 |
22 Dec 05 |
peter |
49 |
|
1251 |
03 Apr 08 |
peter |
50 |
ifstream is(test::filename("data/rank_data.txt").c_str()); |
1121 |
22 Feb 08 |
peter |
51 |
theplu::yat::utility::Matrix data_tmp(is); |
680 |
11 Oct 06 |
jari |
52 |
theplu::yat::classifier::MatrixLookup data(data_tmp); |
158 |
16 Sep 04 |
peter |
53 |
is.close(); |
158 |
16 Sep 04 |
peter |
54 |
|
1251 |
03 Apr 08 |
peter |
55 |
is.open(test::filename("data/rank_target.txt").c_str()); |
680 |
11 Oct 06 |
jari |
56 |
theplu::yat::classifier::Target target(is); |
158 |
16 Sep 04 |
peter |
57 |
is.close(); |
158 |
16 Sep 04 |
peter |
58 |
|
4200 |
19 Aug 22 |
peter |
59 |
|
820 |
17 Mar 07 |
peter |
60 |
theplu::yat::statistics::AUC roc; |
680 |
11 Oct 06 |
jari |
61 |
theplu::yat::classifier::CrossValidationSampler sampler(target,30,3); |
1232 |
15 Mar 08 |
peter |
62 |
suite.err() << "Building Consensus_Inputranker" << std::endl; |
680 |
11 Oct 06 |
jari |
63 |
theplu::yat::classifier::IRRank retrieve; |
828 |
19 Mar 07 |
peter |
64 |
theplu::yat::statistics::Median median; |
828 |
19 Mar 07 |
peter |
65 |
theplu::yat::classifier::ConsensusInputRanker cir(retrieve,median); |
828 |
19 Mar 07 |
peter |
66 |
cir.add(sampler,data,roc); |
158 |
16 Sep 04 |
peter |
67 |
|
1232 |
15 Mar 08 |
peter |
68 |
suite.err() << "test ids... "; |
158 |
16 Sep 04 |
peter |
69 |
if (cir.id(0)!=2 || cir.id(1)!=0 || cir.id(2)!=1){ |
1232 |
15 Mar 08 |
peter |
70 |
suite.err() << "\nincorrect id for weighted" << endl; |
1232 |
15 Mar 08 |
peter |
71 |
suite.add(false); |
158 |
16 Sep 04 |
peter |
72 |
} |
4200 |
19 Aug 22 |
peter |
73 |
else |
1232 |
15 Mar 08 |
peter |
74 |
suite.err() << "ok." << std::endl; |
828 |
19 Mar 07 |
peter |
75 |
|
1232 |
15 Mar 08 |
peter |
76 |
suite.err() << "test ranks... "; |
158 |
16 Sep 04 |
peter |
77 |
if (cir.rank(0)!=1 || cir.rank(1)!=2 || cir.rank(2)!=0){ |
1232 |
15 Mar 08 |
peter |
78 |
suite.err() << "\nincorrect rank for weighted" << endl; |
1232 |
15 Mar 08 |
peter |
79 |
suite.add(false); |
158 |
16 Sep 04 |
peter |
80 |
} |
4200 |
19 Aug 22 |
peter |
81 |
else |
1232 |
15 Mar 08 |
peter |
82 |
suite.err() << "ok." << std::endl; |
158 |
16 Sep 04 |
peter |
83 |
|
1121 |
22 Feb 08 |
peter |
84 |
theplu::yat::utility::Matrix flag(data.rows(),data.columns(),1); |
615 |
31 Aug 06 |
peter |
// Peter, fix weighted version instead |
828 |
19 Mar 07 |
peter |
86 |
theplu::yat::classifier::ConsensusInputRanker cir2(retrieve,median); |
828 |
19 Mar 07 |
peter |
87 |
cir2.add(sampler,data,roc); |
161 |
21 Sep 04 |
peter |
88 |
|
1232 |
15 Mar 08 |
peter |
89 |
suite.err() << "test ids... "; |
161 |
21 Sep 04 |
peter |
90 |
if (cir2.id(0)!=2 || cir2.id(1)!=0 || cir2.id(2)!=1){ |
1232 |
15 Mar 08 |
peter |
91 |
suite.err() << "\nincorrect id for weighted" << endl; |
1232 |
15 Mar 08 |
peter |
92 |
suite.add(false); |
161 |
21 Sep 04 |
peter |
93 |
} |
4200 |
19 Aug 22 |
peter |
94 |
else |
1232 |
15 Mar 08 |
peter |
95 |
suite.err() << "ok." << std::endl; |
4200 |
19 Aug 22 |
peter |
96 |
|
1232 |
15 Mar 08 |
peter |
97 |
suite.err() << "test ranks... "; |
161 |
21 Sep 04 |
peter |
98 |
if (cir2.rank(0)!=1 || cir2.rank(1)!=2 || cir2.rank(2)!=0){ |
1232 |
15 Mar 08 |
peter |
99 |
suite.err() << "\nincorrect rank for weighted" << endl; |
1232 |
15 Mar 08 |
peter |
100 |
suite.add(false); |
161 |
21 Sep 04 |
peter |
101 |
} |
4200 |
19 Aug 22 |
peter |
102 |
else |
1232 |
15 Mar 08 |
peter |
103 |
suite.err() << "ok." << std::endl; |
680 |
11 Oct 06 |
jari |
104 |
|
1232 |
15 Mar 08 |
peter |
105 |
return suite.return_value(); |
158 |
16 Sep 04 |
peter |
106 |
} |