Changeset 102 for trunk/src/ROC.cc


Ignore:
Timestamp:
Jun 15, 2004, 11:40:52 AM (19 years ago)
Author:
Peter
Message:

Fixed bug in interface between InputRanker? & ROC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ROC.cc

    r98 r102  
    1717 
    1818    : Score(), value_(), nof_pos_(0), minimum_size_(10), area_(-1)
    19 
    20        
     19   
    2120  {
    2221    for (unsigned int i=0; i<target.size(); i++){
     
    3231  }
    3332
     33  ROC::ROC()
     34    : Score(), value_(), nof_pos_(0), minimum_size_(10), area_(-1)
     35       
     36  {
     37  }
     38
     39
     40  double ROC::score(const gslapi::vector& target, const gslapi::vector& value)
     41  {
     42    for (unsigned int i=0; i<target.size(); i++){
     43      int targ=static_cast<int>(target(i));
     44      std::pair<int, double> tmp(targ, value(i));
     45      value_.push_back(tmp);
     46      if (targ==1)
     47        nof_pos_++;
     48    }
     49    sort(value_.begin(),value_.end(),
     50         pair_value_compare<int,double>());
     51    double area_=0;
     52    for (unsigned int i=0; i<value_.size(); i++)
     53      if (value_[i].first==1)
     54        area_+=i;
     55    // Normalizing the area to 0-1
     56    area_ = (area_/nof_pos_ - (nof_pos_ - 1)/2 )/(value_.size() - nof_pos_);
     57
     58    return area_;
     59  }
    3460
    3561  double ROC::score()
    3662  {
    37     using namespace std;
    3863    if (area_==-1){
    3964      double area_=0;
     
    6287
    6388
    64   double ROC::get_p_approx(const double area)
     89  double ROC::get_p_approx(const double area) const
    6590  {
    6691    double x = area - 0.5;
Note: See TracChangeset for help on using the changeset viewer.