1 | #ifndef _theplu_yat_statistics_score_ |
---|
2 | #define _theplu_yat_statistics_score_ |
---|
3 | |
---|
4 | // $Id: Score.h 1487 2008-09-10 08:41:36Z 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 yat. If not, see <http://www.gnu.org/licenses/>. |
---|
26 | */ |
---|
27 | |
---|
28 | namespace theplu { |
---|
29 | namespace yat { |
---|
30 | namespace classifier { |
---|
31 | class Target; |
---|
32 | class DataLookup1D; |
---|
33 | class DataLookupWeighted1D; |
---|
34 | } |
---|
35 | namespace utility { |
---|
36 | class VectorBase; |
---|
37 | } |
---|
38 | namespace statistics { |
---|
39 | |
---|
40 | /// |
---|
41 | /// @brief Interface Class for score classes. |
---|
42 | /// |
---|
43 | class Score |
---|
44 | { |
---|
45 | |
---|
46 | public: |
---|
47 | /// |
---|
48 | /// @brief Constructor |
---|
49 | /// |
---|
50 | Score(bool) ; |
---|
51 | |
---|
52 | /// |
---|
53 | /// @brief Destructor |
---|
54 | /// |
---|
55 | virtual ~Score(void); |
---|
56 | |
---|
57 | /// |
---|
58 | /// @brief Function changing mode of Score |
---|
59 | /// |
---|
60 | void absolute(bool absolute); |
---|
61 | |
---|
62 | /// |
---|
63 | /// Function calculating the score. In absolute mode, also the |
---|
64 | /// score using negated class labels is calculated, and the |
---|
65 | /// largest of the two scores are returned. |
---|
66 | /// |
---|
67 | virtual double |
---|
68 | score(const classifier::Target& target, |
---|
69 | const utility::VectorBase& value) const = 0; |
---|
70 | |
---|
71 | /// |
---|
72 | /// Function calculating the score. In absolute mode, also the |
---|
73 | /// score using negated class labels is calculated, and the |
---|
74 | /// largest of the two scores are calculated. |
---|
75 | /// |
---|
76 | /// @a value is copied to a utility::vector and that operator is |
---|
77 | /// called. If speed is important this operator should be |
---|
78 | /// implemented in inherited class to avoid copying. |
---|
79 | /// |
---|
80 | /// @return score |
---|
81 | /// |
---|
82 | virtual double score(const classifier::Target& target, |
---|
83 | const classifier::DataLookup1D& value) const; |
---|
84 | |
---|
85 | /// |
---|
86 | /// Function calculating the score in a weighted fashion. In |
---|
87 | /// absolute mode, also the score using negated class labels is |
---|
88 | /// calculated, and the largest of the two scores are |
---|
89 | /// calculated. Absolute mode should be used when two-tailed test |
---|
90 | /// is wanted. |
---|
91 | /// |
---|
92 | /// @a value is copied to two utility::vector and that operator is |
---|
93 | /// called. If speed is important this operator should be |
---|
94 | /// implemented in inherited class to avoid copying. |
---|
95 | /// |
---|
96 | virtual double |
---|
97 | score(const classifier::Target& target, |
---|
98 | const classifier::DataLookupWeighted1D& value) const; |
---|
99 | |
---|
100 | /// |
---|
101 | /// Function calculating the weighted version of score. In |
---|
102 | /// absolute mode, also the score using negated class labels is |
---|
103 | /// calculated, and the largest of the two scores are |
---|
104 | /// calculated. Absolute mode should be used when two-tailed test |
---|
105 | /// is wanted. |
---|
106 | /// |
---|
107 | virtual double |
---|
108 | score(const classifier::Target& target, |
---|
109 | const utility::VectorBase& value, |
---|
110 | const utility::VectorBase& weight) const = 0; |
---|
111 | |
---|
112 | /// |
---|
113 | /// Function calculating the weighted version of score. In |
---|
114 | /// absolute mode, also the score using negated class labels is |
---|
115 | /// calculated, and the largest of the two scores are |
---|
116 | /// calculated. Absolute mode should be used when two-tailed test |
---|
117 | /// is wanted. |
---|
118 | /// |
---|
119 | /// \a value and \a weight are copied to utility::vector and the |
---|
120 | /// corresponding operator is called. If speed is important this |
---|
121 | /// operator should be implemented in inherited class to avoid |
---|
122 | /// copying. |
---|
123 | /// |
---|
124 | double score(const classifier::Target& target, |
---|
125 | const classifier::DataLookup1D& value, |
---|
126 | const classifier::DataLookup1D& weight) const; |
---|
127 | |
---|
128 | protected: |
---|
129 | /// true if method is absolute, which means if score is below |
---|
130 | /// expected value (by chance) E, score returns E-score+E instead. |
---|
131 | bool absolute_; |
---|
132 | |
---|
133 | }; // class Score |
---|
134 | |
---|
135 | }}} // of namespace statistics, yat, and theplu |
---|
136 | |
---|
137 | #endif |
---|