Changeset 2548


Ignore:
Timestamp:
Aug 7, 2011, 6:36:44 PM (10 years ago)
Author:
Peter
Message:

avoid crash. return nan when area is nan. fixes #669

Location:
branches/0.7-stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/0.7-stable/test/roc.cc

    r2370 r2548  
    33/*
    44  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2011 Peter Johansson
    56
    67  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3435
    3536using namespace theplu::yat;
     37
     38void test_empty(test::Suite&);
    3639
    3740int main(int argc, char* argv[])
     
    9295  classifier::DataLookupWeighted1D dlw(target.size(),1.3);
    9396  add(roc, dlw.begin(), dlw.end(), target);
     97  test_empty(suite);
    9498
    9599  return suite.return_value();
    96100}
     101
     102void test_empty(test::Suite& suite)
     103{
     104  suite.out() << "test empty\n";
     105  // testing buf #669
     106  statistics::ROC roc;
     107  roc.p_value();
     108  roc.area();
     109}
  • branches/0.7-stable/yat/statistics/ROC.cc

    r2119 r2548  
    44  Copyright (C) 2004, 2005 Peter Johansson
    55  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2011 Peter Johansson
    67
    78  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3031#include <gsl/gsl_cdf.h>
    3132
     33#include <cassert>
    3234#include <cmath>
     35#include <limits>
    3336#include <utility>
    3437#include <vector>
     
    9497    if (block > nof_neg*nof_pos)
    9598      return 0.0;
     99    assert(nof_pos>0);
     100    assert(nof_neg>0);
    96101    double p1 = get_p_exact(block-nof_neg, nof_pos-1, nof_neg);
    97102    double p2 = get_p_exact(block, nof_pos, nof_neg-1);
     
    143148      area = auc.score(multimap_);
    144149    }
     150    if (std::isnan(area))
     151      return std::numeric_limits<double>::quiet_NaN();
    145152    if (n_pos() < minimum_size_ && n_neg() < minimum_size_) {
    146153      // for small areas we calculate probabilitu to get larger area -
Note: See TracChangeset for help on using the changeset viewer.