1 | #ifndef _theplu_yat_statistics_roc_score_ |
---|
2 | #define _theplu_yat_statistics_roc_score_ |
---|
3 | |
---|
4 | // $Id: ROCscore.h 778 2007-03-04 13:20:01Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) The authors contributing to this file. |
---|
8 | |
---|
9 | This file is part of the yat library, http://lev.thep.lu.se/trac/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 2 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 <cctype> |
---|
30 | |
---|
31 | namespace theplu { |
---|
32 | namespace yat { |
---|
33 | namespace classifier { |
---|
34 | class Target; |
---|
35 | } |
---|
36 | namespace utility { |
---|
37 | class vector; |
---|
38 | } |
---|
39 | namespace statistics { |
---|
40 | |
---|
41 | /// |
---|
42 | /// @brief Class for Reciever Operating Characteristic. |
---|
43 | /// |
---|
44 | class ROCscore : public Score |
---|
45 | { |
---|
46 | |
---|
47 | public: |
---|
48 | /// |
---|
49 | /// @return number of samples |
---|
50 | /// |
---|
51 | size_t n(void) const; |
---|
52 | |
---|
53 | /// |
---|
54 | /// @return number of positive samples (Target.binary()==true) |
---|
55 | /// |
---|
56 | size_t n_pos(void) const; |
---|
57 | |
---|
58 | /// Function taking \a value, \a target (+1 or -1) and vector |
---|
59 | /// defining what samples to use. The score is equivalent to |
---|
60 | /// Mann-Whitney statistics. |
---|
61 | /// @return the area under the ROC curve. If the area is less |
---|
62 | /// than 0.5 and absolute=true, 1-area is returned. Complexity is |
---|
63 | /// \f$ N\log N \f$ where \f$ N \f$ is number of samples. |
---|
64 | /// |
---|
65 | double score(const classifier::Target& target, |
---|
66 | const utility::vector& value); |
---|
67 | |
---|
68 | /** |
---|
69 | Function taking values, target, weight and a vector defining |
---|
70 | what samples to use. The area is defines as \f$ \frac{\sum |
---|
71 | w^+w^-}{\sum w^+w^-}\f$, where the sum in the numerator goes |
---|
72 | over all pairs where value+ is larger than value-. The |
---|
73 | denominator goes over all pairs. If target is equal to 1, |
---|
74 | sample belonges to class + otherwise sample belongs to class |
---|
75 | -. @return wheighted version of area under the ROC curve. If |
---|
76 | the area is less than 0.5 and absolute=true, 1-area is |
---|
77 | returned. Complexity is \f$ N^2 \f$ where \f$ N \f$ is number |
---|
78 | of samples. |
---|
79 | */ |
---|
80 | double score(const classifier::Target& target, |
---|
81 | const classifier::DataLookupWeighted1D& value); |
---|
82 | |
---|
83 | /** |
---|
84 | Function taking values, target, weight and a vector defining |
---|
85 | what samples to use. The area is defines as \f$ \frac{\sum |
---|
86 | w^+w^-}{\sum w^+w^-}\f$, where the sum in the numerator goes |
---|
87 | over all pairs where value+ is larger than value-. The |
---|
88 | denominator goes over all pairs. If target is equal to 1, |
---|
89 | sample belonges to class + otherwise sample belongs to class |
---|
90 | -. @return wheighted version of area under the ROC curve. If |
---|
91 | the area is less than 0.5 and absolute=true, 1-area is |
---|
92 | returned. Complexity is \f$ N^2 \f$ where \f$ N \f$ is number |
---|
93 | of samples. |
---|
94 | */ |
---|
95 | double score(const classifier::Target& target, |
---|
96 | const utility::vector& value, |
---|
97 | const utility::vector& weight); |
---|
98 | |
---|
99 | private: |
---|
100 | |
---|
101 | }; |
---|
102 | |
---|
103 | }}} // of namespace statistics, yat, and theplu |
---|
104 | |
---|
105 | #endif |
---|