Changeset 98


Ignore:
Timestamp:
Jun 10, 2004, 5:24:05 PM (18 years ago)
Author:
Peter
Message:

tScore added

Location:
trunk/src
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r94 r98  
    99  InputRanker.cc Kernel.cc matrix.cc Merge.cc PCA.cc    \
    1010  PolynomialKernelFunction.cc random_singleton.cc ROC.cc    \
    11   stl_utility SVD.cc SVM.cc vector.cc Wead.cc WeightedAverager.cc
     11  stl_utility SVD.cc SVM.cc tScore.cc vector.cc Wead.cc WeightedAverager.cc
    1212
    1313INCLUDES = -I/home/max/jari/local/include
  • trunk/src/ROC.cc

    r78 r98  
    22
    33// System includes
    4 #include <algorithm>
    5 #include <utility>
    6 #include <vector>
     4//#include <algorithm>
     5//#include <utility>
     6//#include <vector>
    77
    88// Thep C++ Tools
     
    1616  ROC::ROC(const gslapi::vector& target, const gslapi::vector& value)
    1717 
    18     : value_(), nof_pos_(0), minimum_size_(10)
     18    : Score(), value_(), nof_pos_(0), minimum_size_(10), area_(-1)
    1919
    2020       
     
    3333
    3434
    35   double ROC::area()
     35  double ROC::score()
    3636  {
    3737    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_;
    4647  }
    4748
    4849
    49   double ROC::get_p(const double area)
     50  double ROC::p_value(void)
    5051  {
     52    if (area_==-1)
     53      area_ = score();
    5154    double p;
    5255    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_),
    5457                          nof_pos_, value_.size()-nof_pos_);
    5558    else
    56     p = get_p_approx(area);
     59    p = get_p_approx(area_);
    5760    return p;
    5861  }
  • trunk/src/ROC.h

    r78 r98  
    66// C++ tools include
    77/////////////////////
     8#include "Score.h"
    89#include "vector.h"
    9 
    1010#include <gsl/gsl_cdf.h>
    1111
     
    1818namespace cpptools { 
    1919  ///
    20   /// Class for ROC (Reciever Operating Characteristic).
     20  /// Class for ROC (Reciever Operating Characteristic). 
    2121  ///   
    22   class ROC
     22 
     23  class ROC : public Score
    2324  {
    2425 
     
    2930    ROC(const gslapi::vector&, const gslapi::vector&);
    3031         
     32    ///
     33    /// Destructor
     34    ///
     35    virtual ~ROC(void) {};
     36         
    3137    /// Equivalent to the Mann-Whitney score, but normalized to be
    3238    /// between zero and one.  @return the area under the ROC curve
    3339    ///
    34     double ROC::area(void);
     40    double score();
    3541       
    36 
    37 
    3842    ///
    3943    ///Calculates the p-value, i.e. the probability of observing an area
     
    4751    /// @return the one-sided p-value
    4852    ///
    49     double ROC::get_p(const double);
     53    double p_value();
    5054         
    5155    ///
     
    5963    double nof_pos_;
    6064    u_int minimum_size_;
     65    double area_;
    6166    ///
    6267    ///
Note: See TracChangeset for help on using the changeset viewer.