source: trunk/src/ROC.h @ 102

Last change on this file since 102 was 102, checked in by Peter, 19 years ago

Fixed bug in interface between InputRanker? & ROC

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1// $Id: ROC.h 102 2004-06-15 09:40:52Z 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    /// Changes minimum_size , i.e. the threshold when a normal
69    /// approximation is used for the p-value calculation.
70    ///
71    inline void minimum_size(const u_int minimum_size) {minimum_size_ = minimum_size; } 
72
73  private:
74    std::vector<std::pair<int, double> > value_; //sorted pair of id and value
75    double nof_pos_;
76    u_int minimum_size_;
77    double area_;
78    ///
79    ///
80    /// Implemented as in MatLab 13.1
81    /// @return the p-value
82    ///
83    double ROC::get_p_approx(const double) const;
84   
85    ///
86    /// @return the p-value
87    ///
88    double ROC::get_p_exact(const double, const double, 
89                            const double);
90       
91  };
92
93}} // of namespace cpptools and namespace theplu
94
95#endif
96
Note: See TracBrowser for help on using the repository browser.