1 | // $Id: Score.cc 789 2007-03-10 20:07:13Z jari $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) The authors contributing to this file. |
---|
5 | |
---|
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 "Score.h" |
---|
25 | |
---|
26 | #include "yat/classifier/DataLookup1D.h" |
---|
27 | #include "yat/classifier/DataLookupWeighted1D.h" |
---|
28 | #include "yat/classifier/Target.h" |
---|
29 | #include "yat/classifier/utility.h" |
---|
30 | #include "yat/utility/vector.h" |
---|
31 | |
---|
32 | #include <cassert> |
---|
33 | |
---|
34 | namespace theplu { |
---|
35 | namespace yat { |
---|
36 | namespace statistics { |
---|
37 | |
---|
38 | Score::Score(bool absolute) |
---|
39 | : absolute_(absolute) |
---|
40 | { |
---|
41 | } |
---|
42 | |
---|
43 | Score::~Score(void) |
---|
44 | { |
---|
45 | } |
---|
46 | |
---|
47 | void Score::absolute(bool absolute) |
---|
48 | { |
---|
49 | absolute_=absolute; |
---|
50 | } |
---|
51 | |
---|
52 | double Score::score(const classifier::Target& target, |
---|
53 | const classifier::DataLookup1D& value) const |
---|
54 | { |
---|
55 | assert(target.size()==value.size()); |
---|
56 | utility::vector a(value.size()); |
---|
57 | classifier::convert(value,a); |
---|
58 | return score(target,a); |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | double Score::score(const classifier::Target& target, |
---|
63 | const classifier::DataLookupWeighted1D& value) const |
---|
64 | { |
---|
65 | assert(target.size()==value.size()); |
---|
66 | utility::vector a(value.size()); |
---|
67 | utility::vector b(value.size()); |
---|
68 | classifier::convert(value,a,b); |
---|
69 | return score(target,a,b); |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | double Score::score(const classifier::Target& target, |
---|
74 | const classifier::DataLookup1D& value, |
---|
75 | const classifier::DataLookup1D& weight) const |
---|
76 | { |
---|
77 | utility::vector a(value.size()); |
---|
78 | classifier::convert(value,a); |
---|
79 | utility::vector b(value.size()); |
---|
80 | classifier::convert(weight,a); |
---|
81 | return score(target,a,b); |
---|
82 | } |
---|
83 | |
---|
84 | }}} // of namespace statistics, yat, and theplu |
---|