1 | // $Id: Score.cc 1120 2008-02-21 23:18:41Z peter $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2004, 2005 Peter Johansson |
---|
5 | Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson |
---|
6 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson |
---|
7 | |
---|
8 | This file is part of the yat library, http://trac.thep.lu.se/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 "Score.h" |
---|
27 | |
---|
28 | #include "yat/classifier/DataLookup1D.h" |
---|
29 | #include "yat/classifier/DataLookupWeighted1D.h" |
---|
30 | #include "yat/classifier/Target.h" |
---|
31 | #include "yat/classifier/utility.h" |
---|
32 | #include "yat/utility/Vector.h" |
---|
33 | |
---|
34 | #include <cassert> |
---|
35 | |
---|
36 | namespace theplu { |
---|
37 | namespace yat { |
---|
38 | namespace statistics { |
---|
39 | |
---|
40 | Score::Score(bool absolute) |
---|
41 | : absolute_(absolute) |
---|
42 | { |
---|
43 | } |
---|
44 | |
---|
45 | Score::~Score(void) |
---|
46 | { |
---|
47 | } |
---|
48 | |
---|
49 | void Score::absolute(bool absolute) |
---|
50 | { |
---|
51 | absolute_=absolute; |
---|
52 | } |
---|
53 | |
---|
54 | double Score::score(const classifier::Target& target, |
---|
55 | const classifier::DataLookup1D& value) const |
---|
56 | { |
---|
57 | assert(target.size()==value.size()); |
---|
58 | utility::Vector a(value.size()); |
---|
59 | classifier::convert(value,a); |
---|
60 | return score(target,a); |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | double Score::score(const classifier::Target& target, |
---|
65 | const classifier::DataLookupWeighted1D& value) const |
---|
66 | { |
---|
67 | assert(target.size()==value.size()); |
---|
68 | utility::Vector a(value.size()); |
---|
69 | utility::Vector b(value.size()); |
---|
70 | classifier::convert(value,a,b); |
---|
71 | return score(target,a,b); |
---|
72 | } |
---|
73 | |
---|
74 | |
---|
75 | double Score::score(const classifier::Target& target, |
---|
76 | const classifier::DataLookup1D& value, |
---|
77 | const classifier::DataLookup1D& weight) const |
---|
78 | { |
---|
79 | utility::Vector a(value.size()); |
---|
80 | classifier::convert(value,a); |
---|
81 | utility::Vector b(value.size()); |
---|
82 | classifier::convert(weight,a); |
---|
83 | return score(target,a,b); |
---|
84 | } |
---|
85 | |
---|
86 | }}} // of namespace statistics, yat, and theplu |
---|