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