Changeset 98
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Makefile.am
r94 r98 9 9 InputRanker.cc Kernel.cc matrix.cc Merge.cc PCA.cc \ 10 10 PolynomialKernelFunction.cc random_singleton.cc ROC.cc \ 11 stl_utility SVD.cc SVM.cc vector.cc Wead.cc WeightedAverager.cc11 stl_utility SVD.cc SVM.cc tScore.cc vector.cc Wead.cc WeightedAverager.cc 12 12 13 13 INCLUDES = -I/home/max/jari/local/include -
trunk/src/ROC.cc
r78 r98 2 2 3 3 // System includes 4 #include <algorithm>5 #include <utility>6 #include <vector>4 //#include <algorithm> 5 //#include <utility> 6 //#include <vector> 7 7 8 8 // Thep C++ Tools … … 16 16 ROC::ROC(const gslapi::vector& target, const gslapi::vector& value) 17 17 18 : value_(), nof_pos_(0), minimum_size_(10)18 : Score(), value_(), nof_pos_(0), minimum_size_(10), area_(-1) 19 19 20 20 … … 33 33 34 34 35 double ROC:: area()35 double ROC::score() 36 36 { 37 37 using namespace std; 38 double area=0; 39 for (unsigned int i=0; i<value_.size(); i++) 40 if (value_[i].first==1) 41 area+=i; 42 // Normalizing the area to 0-1 43 area = (area/nof_pos_ - (nof_pos_ - 1)/2 )/(value_.size() - nof_pos_); 44 45 return area; 38 if (area_==-1){ 39 double area_=0; 40 for (unsigned int i=0; i<value_.size(); i++) 41 if (value_[i].first==1) 42 area_+=i; 43 // Normalizing the area to 0-1 44 area_ = (area_/nof_pos_ - (nof_pos_ - 1)/2 )/(value_.size() - nof_pos_); 45 } 46 return area_; 46 47 } 47 48 48 49 49 double ROC:: get_p(const double area)50 double ROC::p_value(void) 50 51 { 52 if (area_==-1) 53 area_ = score(); 51 54 double p; 52 55 if (nof_pos_ < minimum_size_ & value_.size()-nof_pos_ < minimum_size_) 53 p = get_p_exact(area *nof_pos_*(value_.size()-nof_pos_),56 p = get_p_exact(area_*nof_pos_*(value_.size()-nof_pos_), 54 57 nof_pos_, value_.size()-nof_pos_); 55 58 else 56 p = get_p_approx(area );59 p = get_p_approx(area_); 57 60 return p; 58 61 } -
trunk/src/ROC.h
r78 r98 6 6 // C++ tools include 7 7 ///////////////////// 8 #include "Score.h" 8 9 #include "vector.h" 9 10 10 #include <gsl/gsl_cdf.h> 11 11 … … 18 18 namespace cpptools { 19 19 /// 20 /// Class for ROC (Reciever Operating Characteristic). 20 /// Class for ROC (Reciever Operating Characteristic). 21 21 /// 22 class ROC 22 23 class ROC : public Score 23 24 { 24 25 … … 29 30 ROC(const gslapi::vector&, const gslapi::vector&); 30 31 32 /// 33 /// Destructor 34 /// 35 virtual ~ROC(void) {}; 36 31 37 /// Equivalent to the Mann-Whitney score, but normalized to be 32 38 /// between zero and one. @return the area under the ROC curve 33 39 /// 34 double ROC::area(void);40 double score(); 35 41 36 37 38 42 /// 39 43 ///Calculates the p-value, i.e. the probability of observing an area … … 47 51 /// @return the one-sided p-value 48 52 /// 49 double ROC::get_p(const double);53 double p_value(); 50 54 51 55 /// … … 59 63 double nof_pos_; 60 64 u_int minimum_size_; 65 double area_; 61 66 /// 62 67 ///
Note: See TracChangeset
for help on using the changeset viewer.