1 | // $Id: Score.cc 1486 2008-09-09 21:17:19Z 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 this program; if not, write to the Free Software |
---|
23 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
24 | 02111-1307, USA. |
---|
25 | */ |
---|
26 | |
---|
27 | #include "Score.h" |
---|
28 | |
---|
29 | #include "yat/classifier/DataLookup1D.h" |
---|
30 | #include "yat/classifier/DataLookupWeighted1D.h" |
---|
31 | #include "yat/classifier/Target.h" |
---|
32 | #include "yat/classifier/utility.h" |
---|
33 | #include "yat/utility/Vector.h" |
---|
34 | |
---|
35 | #include <cassert> |
---|
36 | |
---|
37 | namespace theplu { |
---|
38 | namespace yat { |
---|
39 | namespace statistics { |
---|
40 | |
---|
41 | Score::Score(bool absolute) |
---|
42 | : absolute_(absolute) |
---|
43 | { |
---|
44 | } |
---|
45 | |
---|
46 | Score::~Score(void) |
---|
47 | { |
---|
48 | } |
---|
49 | |
---|
50 | void Score::absolute(bool absolute) |
---|
51 | { |
---|
52 | absolute_=absolute; |
---|
53 | } |
---|
54 | |
---|
55 | double Score::score(const classifier::Target& target, |
---|
56 | const classifier::DataLookup1D& value) const |
---|
57 | { |
---|
58 | assert(target.size()==value.size()); |
---|
59 | utility::Vector a(value.size()); |
---|
60 | classifier::convert(value,a); |
---|
61 | return score(target,a); |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | double Score::score(const classifier::Target& target, |
---|
66 | const classifier::DataLookupWeighted1D& value) const |
---|
67 | { |
---|
68 | assert(target.size()==value.size()); |
---|
69 | utility::Vector a(value.size()); |
---|
70 | utility::Vector b(value.size()); |
---|
71 | classifier::convert(value,a,b); |
---|
72 | return score(target,a,b); |
---|
73 | } |
---|
74 | |
---|
75 | |
---|
76 | double Score::score(const classifier::Target& target, |
---|
77 | const classifier::DataLookup1D& value, |
---|
78 | const classifier::DataLookup1D& weight) const |
---|
79 | { |
---|
80 | utility::Vector a(value.size()); |
---|
81 | classifier::convert(value,a); |
---|
82 | utility::Vector b(value.size()); |
---|
83 | classifier::convert(weight,a); |
---|
84 | return score(target,a,b); |
---|
85 | } |
---|
86 | |
---|
87 | }}} // of namespace statistics, yat, and theplu |
---|