1 | // $Id: Score.cc 1487 2008-09-10 08:41:36Z jari $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2004, 2005 Peter Johansson |
---|
5 | Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér |
---|
6 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson |
---|
7 | Copyright (C) 2008 Peter Johansson |
---|
8 | |
---|
9 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
10 | |
---|
11 | The yat library is free software; you can redistribute it and/or |
---|
12 | modify it under the terms of the GNU General Public License as |
---|
13 | published by the Free Software Foundation; either version 3 of the |
---|
14 | License, or (at your option) any later version. |
---|
15 | |
---|
16 | The yat library is distributed in the hope that it will be useful, |
---|
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
19 | General Public License for more details. |
---|
20 | |
---|
21 | You should have received a copy of the GNU General Public License |
---|
22 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
23 | */ |
---|
24 | |
---|
25 | #include "Score.h" |
---|
26 | |
---|
27 | #include "yat/classifier/DataLookup1D.h" |
---|
28 | #include "yat/classifier/DataLookupWeighted1D.h" |
---|
29 | #include "yat/classifier/Target.h" |
---|
30 | #include "yat/classifier/utility.h" |
---|
31 | #include "yat/utility/Vector.h" |
---|
32 | |
---|
33 | #include <cassert> |
---|
34 | |
---|
35 | namespace theplu { |
---|
36 | namespace yat { |
---|
37 | namespace statistics { |
---|
38 | |
---|
39 | Score::Score(bool absolute) |
---|
40 | : absolute_(absolute) |
---|
41 | { |
---|
42 | } |
---|
43 | |
---|
44 | Score::~Score(void) |
---|
45 | { |
---|
46 | } |
---|
47 | |
---|
48 | void Score::absolute(bool absolute) |
---|
49 | { |
---|
50 | absolute_=absolute; |
---|
51 | } |
---|
52 | |
---|
53 | double Score::score(const classifier::Target& target, |
---|
54 | const classifier::DataLookup1D& value) const |
---|
55 | { |
---|
56 | assert(target.size()==value.size()); |
---|
57 | utility::Vector a(value.size()); |
---|
58 | classifier::convert(value,a); |
---|
59 | return score(target,a); |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
63 | double Score::score(const classifier::Target& target, |
---|
64 | const classifier::DataLookupWeighted1D& value) const |
---|
65 | { |
---|
66 | assert(target.size()==value.size()); |
---|
67 | utility::Vector a(value.size()); |
---|
68 | utility::Vector b(value.size()); |
---|
69 | classifier::convert(value,a,b); |
---|
70 | return score(target,a,b); |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | double Score::score(const classifier::Target& target, |
---|
75 | const classifier::DataLookup1D& value, |
---|
76 | const classifier::DataLookup1D& weight) const |
---|
77 | { |
---|
78 | utility::Vector a(value.size()); |
---|
79 | classifier::convert(value,a); |
---|
80 | utility::Vector b(value.size()); |
---|
81 | classifier::convert(weight,a); |
---|
82 | return score(target,a,b); |
---|
83 | } |
---|
84 | |
---|
85 | }}} // of namespace statistics, yat, and theplu |
---|