source: trunk/yat/statistics/AUC.h @ 2594

Last change on this file since 2594 was 2594, checked in by Peter, 11 years ago

improve docs for ROC and sister class AUC. closes #144

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1#ifndef _theplu_yat_statistics_auc_
2#define _theplu_yat_statistics_auc_
3
4// $Id: AUC.h 2594 2011-10-30 02:36:17Z peter $
5
6/*
7  Copyright (C) 2004 Peter Johansson
8  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
9
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26#include "Score.h"
27#include "yat/utility/stl_utility.h"
28
29#include <utility>
30#include <map>
31
32namespace theplu {
33namespace yat {
34namespace classifier {
35  class Target;
36}
37namespace utility {
38  class VectorBase;
39}
40namespace statistics { 
41
42  /**
43     \brief Area Under ROC Curve
44
45     Class calculates area under curve from values, Target, and
46     possibly weights. If weights are left out, unity weights are
47     assumed. The area under curve is defined as
48     \f[
49     \frac{\sum_{i,j} I(x_i^+-x_j^-) w_i^+w_j^-} {\sum_{i,j}
50     w_i^+w_j^-} \f]
51     where
52     \f{eqnarray*}{
53            &0; &x<0 \\
54     I(x) = &0.5; &x=0 \\
55            &1; &x>0
56     \f}
57
58     Complexity of calculating the AUC is \f$ N \log N \f$.
59  */ 
60  class AUC : public Score
61  {
62 
63  public:
64    ///
65    /// \brief Default Constructor
66    /// \param absolute if true max(AUC, 1-AUC) is used
67    ///
68    AUC(bool absolute=true);
69
70    /**
71       \return area under the ROC curve.
72    */
73    double score(const classifier::Target& target, 
74                 const utility::VectorBase& value) const; 
75   
76    /**
77       \return area under the ROC curve.
78    */
79    double score(const classifier::Target& target, 
80                 const classifier::DataLookupWeighted1D& value) const; 
81
82    /**
83       \return area under the ROC curve.
84    */
85    double score(const classifier::Target& target, 
86                 const utility::VectorBase& value, 
87                 const utility::VectorBase& weight) const; 
88
89  private:
90    friend class ROC;
91
92    typedef std::multimap<double, std::pair<bool, double> > MultiMap;
93    double score(const MultiMap&) const;
94  };
95
96}}} // of namespace statistics, yat, and theplu
97
98#endif
Note: See TracBrowser for help on using the repository browser.