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

Last change on this file since 2119 was 2119, checked in by Peter, 13 years ago

converted files to utf-8. fixes #577

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1#ifndef _theplu_yat_statistics_auc_
2#define _theplu_yat_statistics_auc_
3
4// $Id: AUC.h 2119 2009-12-12 23:11:43Z 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 Class calculating Area Under ROC Curve
44  ///   
45  class AUC : public Score
46  {
47 
48  public:
49    ///
50    /// \brief Defaul Constructor
51    /// \param absolute if true max(AUC, 1-AUC) is used
52    ///
53    AUC(bool absolute=true);
54
55    /// Function taking \a value, \a target (+1 or -1) and vector
56    /// defining what samples to use. The score is equivalent to
57    /// Mann-Whitney statistics.
58    /// @return the area under the ROC curve. If the area is less
59    /// than 0.5 and absolute=true, 1-area is returned. Complexity is
60    /// \f$ N\log N \f$ where \f$ N \f$ is number of samples.
61    ///
62    double score(const classifier::Target& target, 
63                 const utility::VectorBase& value) const; 
64   
65    /**
66        Function taking values, target, weight and a vector defining
67        what samples to use. The area is defines as \f$ \frac{\sum
68        w^+w^-}{\sum w^+w^-}\f$, where the sum in the numerator goes
69        over all pairs where value+ is larger than value-. The
70        denominator goes over all pairs. If target is equal to 1,
71        sample belonges to class + otherwise sample belongs to class
72        -. @return wheighted version of area under the ROC curve. If
73        the area is less than 0.5 and absolute=true, 1-area is
74        returned. Complexity is \f$ N^2 \f$ where \f$ N \f$ is number
75        of samples.
76    */
77    double score(const classifier::Target& target, 
78                 const classifier::DataLookupWeighted1D& value) const; 
79
80    /**
81        Function taking values, target, weight and a vector defining
82        what samples to use. The area is defines as \f$ \frac{\sum
83        w^+w^-}{\sum w^+w^-}\f$, where the sum in the numerator goes
84        over all pairs where value+ is larger than value-. The
85        denominator goes over all pairs. If target is equal to 1,
86        sample belonges to class + otherwise sample belongs to class
87        -. @return wheighted version of area under the ROC curve. If
88        the area is less than 0.5 and absolute=true, 1-area is
89        returned. Complexity is \f$ N^2 \f$ where \f$ N \f$ is number
90        of samples.
91    */
92    double score(const classifier::Target& target, 
93                 const utility::VectorBase& value, 
94                 const utility::VectorBase& weight) const; 
95
96  private:
97    friend class ROC;
98
99    typedef std::multimap<double, std::pair<bool, double> > MultiMap;
100    double score(const MultiMap&) const;
101   
102  };
103
104}}} // of namespace statistics, yat, and theplu
105
106#endif
Note: See TracBrowser for help on using the repository browser.