1 | #ifndef _theplu_yat_statistics_score_ |
---|
2 | #define _theplu_yat_statistics_score_ |
---|
3 | |
---|
4 | // $Id: Score.h 1486 2008-09-09 21:17:19Z jari $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2004, 2005 Peter Johansson |
---|
8 | Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér |
---|
9 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson |
---|
10 | Copyright (C) 2008 Peter Johansson |
---|
11 | |
---|
12 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
13 | |
---|
14 | The yat library is free software; you can redistribute it and/or |
---|
15 | modify it under the terms of the GNU General Public License as |
---|
16 | published by the Free Software Foundation; either version 3 of the |
---|
17 | License, or (at your option) any later version. |
---|
18 | |
---|
19 | The yat library is distributed in the hope that it will be useful, |
---|
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
22 | General Public License for more details. |
---|
23 | |
---|
24 | You should have received a copy of the GNU General Public License |
---|
25 | along with this program; if not, write to the Free Software |
---|
26 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
27 | 02111-1307, USA. |
---|
28 | */ |
---|
29 | |
---|
30 | namespace theplu { |
---|
31 | namespace yat { |
---|
32 | namespace classifier { |
---|
33 | class Target; |
---|
34 | class DataLookup1D; |
---|
35 | class DataLookupWeighted1D; |
---|
36 | } |
---|
37 | namespace utility { |
---|
38 | class VectorBase; |
---|
39 | } |
---|
40 | namespace statistics { |
---|
41 | |
---|
42 | /// |
---|
43 | /// @brief Interface Class for score classes. |
---|
44 | /// |
---|
45 | class Score |
---|
46 | { |
---|
47 | |
---|
48 | public: |
---|
49 | /// |
---|
50 | /// @brief Constructor |
---|
51 | /// |
---|
52 | Score(bool) ; |
---|
53 | |
---|
54 | /// |
---|
55 | /// @brief Destructor |
---|
56 | /// |
---|
57 | virtual ~Score(void); |
---|
58 | |
---|
59 | /// |
---|
60 | /// @brief Function changing mode of Score |
---|
61 | /// |
---|
62 | void absolute(bool absolute); |
---|
63 | |
---|
64 | /// |
---|
65 | /// Function calculating the score. In absolute mode, also the |
---|
66 | /// score using negated class labels is calculated, and the |
---|
67 | /// largest of the two scores are returned. |
---|
68 | /// |
---|
69 | virtual double |
---|
70 | score(const classifier::Target& target, |
---|
71 | const utility::VectorBase& value) const = 0; |
---|
72 | |
---|
73 | /// |
---|
74 | /// Function calculating the score. In absolute mode, also the |
---|
75 | /// score using negated class labels is calculated, and the |
---|
76 | /// largest of the two scores are calculated. |
---|
77 | /// |
---|
78 | /// @a value is copied to a utility::vector and that operator is |
---|
79 | /// called. If speed is important this operator should be |
---|
80 | /// implemented in inherited class to avoid copying. |
---|
81 | /// |
---|
82 | /// @return score |
---|
83 | /// |
---|
84 | virtual double score(const classifier::Target& target, |
---|
85 | const classifier::DataLookup1D& value) const; |
---|
86 | |
---|
87 | /// |
---|
88 | /// Function calculating the score in a weighted fashion. In |
---|
89 | /// absolute mode, also the score using negated class labels is |
---|
90 | /// calculated, and the largest of the two scores are |
---|
91 | /// calculated. Absolute mode should be used when two-tailed test |
---|
92 | /// is wanted. |
---|
93 | /// |
---|
94 | /// @a value is copied to two utility::vector and that operator is |
---|
95 | /// called. If speed is important this operator should be |
---|
96 | /// implemented in inherited class to avoid copying. |
---|
97 | /// |
---|
98 | virtual double |
---|
99 | score(const classifier::Target& target, |
---|
100 | const classifier::DataLookupWeighted1D& value) const; |
---|
101 | |
---|
102 | /// |
---|
103 | /// Function calculating the weighted version of score. In |
---|
104 | /// absolute mode, also the score using negated class labels is |
---|
105 | /// calculated, and the largest of the two scores are |
---|
106 | /// calculated. Absolute mode should be used when two-tailed test |
---|
107 | /// is wanted. |
---|
108 | /// |
---|
109 | virtual double |
---|
110 | score(const classifier::Target& target, |
---|
111 | const utility::VectorBase& value, |
---|
112 | const utility::VectorBase& weight) const = 0; |
---|
113 | |
---|
114 | /// |
---|
115 | /// Function calculating the weighted version of score. In |
---|
116 | /// absolute mode, also the score using negated class labels is |
---|
117 | /// calculated, and the largest of the two scores are |
---|
118 | /// calculated. Absolute mode should be used when two-tailed test |
---|
119 | /// is wanted. |
---|
120 | /// |
---|
121 | /// \a value and \a weight are copied to utility::vector and the |
---|
122 | /// corresponding operator is called. If speed is important this |
---|
123 | /// operator should be implemented in inherited class to avoid |
---|
124 | /// copying. |
---|
125 | /// |
---|
126 | double score(const classifier::Target& target, |
---|
127 | const classifier::DataLookup1D& value, |
---|
128 | const classifier::DataLookup1D& weight) const; |
---|
129 | |
---|
130 | protected: |
---|
131 | /// true if method is absolute, which means if score is below |
---|
132 | /// expected value (by chance) E, score returns E-score+E instead. |
---|
133 | bool absolute_; |
---|
134 | |
---|
135 | }; // class Score |
---|
136 | |
---|
137 | }}} // of namespace statistics, yat, and theplu |
---|
138 | |
---|
139 | #endif |
---|