source: trunk/src/ROC.h @ 103

Last change on this file since 103 was 103, checked in by Peter, 18 years ago

output operator added

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1// $Id: ROC.h 103 2004-06-15 14:29:15Z peter $
2
3#ifndef _theplu_cpptools_roc_
4#define _theplu_cpptools_roc_
5
6// C++ tools include
7/////////////////////
8#include "Score.h"
9#include "vector.h"
10#include <gsl/gsl_cdf.h>
11
12// Standard C++ includes
13////////////////////////
14#include <utility>
15#include <vector>
16
17namespace theplu {
18namespace cpptools { 
19  ///
20  /// Class for ROC (Reciever Operating Characteristic).
21  ///   
22 
23  class ROC : public Score
24  {
25 
26  public:
27    ///
28    /// Default constructor
29    ///
30    ROC(void);
31         
32    ///
33    /// Constructor taking a value vector and a target vector (+1 or -1).
34    ///
35    ROC(const gslapi::vector&, const gslapi::vector&);
36         
37    ///
38    /// Destructor
39    ///
40    virtual ~ROC(void) {};
41         
42    /// Equivalent to the Mann-Whitney score, but normalized to be
43    /// between zero and one.  @return the area under the ROC curve
44    ///
45    double score() ;
46   
47    /// Function taking a vector of values and a vector of target (+1
48    /// or -1). The score is equivalent to the Mann-Whitney score but
49    /// normalized to be between zero and one. @return the area under
50    /// the ROC curve
51    ///
52    double score(const gslapi::vector&, const gslapi::vector&);
53       
54    ///
55    ///Calculates the p-value, i.e. the probability of observing an area
56    ///equally or larger if the null hypothesis is true. If P is near zero,
57    ///this casts doubt on this hypothesis. The null hypothesis is that the
58    ///values from the 2 classes are generated from 2 identical
59    ///distributions. The alternative is that the median of the first
60    ///distribution is shifted from the median of the second distribution by a
61    ///non-zero amount. If the smallest group size is larger than minimum_size
62    ///(default = 10), then P is calculated using a normal approximation.
63    /// @return the one-sided p-value
64    ///
65    double p_value() ;
66         
67    ///
68    /// @ return a vector of outputs that is sorted with respect to
69    /// the corresponding score value
70    ///
71    gslapi::vector ROC::target(void) const;
72
73    ///
74    /// Changes minimum_size , i.e. the threshold when a normal
75    /// approximation is used for the p-value calculation.
76    ///
77    inline void minimum_size(const u_int minimum_size) {minimum_size_ = minimum_size; } 
78
79  private:
80    std::vector<std::pair<int, double> > value_; //sorted pair of id and value
81    double nof_pos_;
82    u_int minimum_size_;
83    double area_;
84    ///
85    ///
86    /// Implemented as in MatLab 13.1
87    /// @return the p-value
88    ///
89    double ROC::get_p_approx(const double) const;
90   
91    ///
92    /// @return the p-value
93    ///
94    double ROC::get_p_exact(const double, const double, 
95                            const double);
96 
97    ///
98    /// sorting
99    ///
100    void ROC::sort(const gslapi::vector&, const gslapi::vector&);
101       
102  };
103
104  ///
105  /// The output operator for the ROC class. The output is an Nx2
106  /// matrix, where the first column is the sensitivity and second
107  /// is the specificity.
108  ///
109  std::ostream& operator<< (std::ostream& s, const ROC&);
110
111
112}} // of namespace cpptools and namespace theplu
113
114#endif
115
Note: See TracBrowser for help on using the repository browser.