Changeset 3006


Ignore:
Timestamp:
Apr 1, 2013, 10:15:11 AM (8 years ago)
Author:
Peter
Message:

deprecate ROC::p_value, first versions of p_left and p_right (refs #689), but code is terribly duplicated which is better to fix after ticket:754 (refs #754).

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r3005 r3006  
    66  - Fisher::one_sided_p(void) is now deprecated (ticket #689)
    77  - PearsonCorrelation::one_sided_p(void) is now deprecated (ticket #689)
     8  - PearsonCorrelation::one_sided_p(void) is now deprecated (ticket #689)
     9  - ROC::p_value_one_sided(void is now deprecated (ticket #689)
    810
    911  A complete list of closed tickets can be found here [[br]]
  • trunk/test/roc.cc

    r2881 r3006  
    9090  }
    9191
    92   double p = roc.p_value_one_sided();
     92  double p = roc.p_right();
    9393  double p2 = roc.p_value();
    9494  double p_matlab = 0.00000115;
     
    100100  if (!(p2==2*p)) {
    101101    suite.add(false);
    102     suite.err() << "Two-sided P-value should equal 2 * one-sided P-value.\n";
     102    suite.err() << "Two-sided P-value should equal 2 * p_right.\n";
    103103  }
    104104  roc.minimum_size() = 20;
    105   p = roc.p_value_one_sided();
     105  p = roc.p_right();
    106106  p2 = roc.p_value();
    107107  if (!( p < 1e-8 && p > 1e-9) ){
     
    111111  if (!( p2==2*p)) {
    112112    suite.add(false);
    113     suite.err() << "Two-sided P-value should equal 2 * one-sided P-value.\n";
     113    suite.err() << "Two-sided P-value should equal 2 * p_right.\n";
    114114  }
    115115
     
    150150  roc.add(-1, false);
    151151  roc.area();
    152   if (!suite.equal(roc.p_value_one_sided(), 3.0/10.0)) {
    153     suite.add(false);
    154     suite.out() << "  p_value_one_sided: expected 0.3\n";
     152  if (!suite.equal(roc.p_right(), 3.0/10.0)) {
     153    suite.add(false);
     154    suite.out() << "  p_right: expected 0.3\n";
    155155  }
    156156  else
     
    171171  roc.add(-1, true);
    172172  suite.add(suite.equal(roc.area(), 0.5/6));
    173   if (!suite.add(suite.equal(roc.p_value_one_sided(), 10.0/10.0)))
    174     suite.out() << "  p_value_one_sided: expected 0.3\n";
     173  if (!suite.add(suite.equal(roc.p_right(), 10.0/10.0)))
     174    suite.out() << "  p_right: expected 0.3\n";
    175175  if (!suite.add(suite.equal(roc.p_value(), 3.0/10.0)))
    176176    suite.out() << "  (two-sided) p_value: expected 0.5\n";
     
    212212  for (size_t i=0; i<9; ++i)
    213213    roc.add(i, i<5);
    214   if (roc.p_value_one_sided()<0.5) {
     214  if (roc.p_right()<0.5) {
    215215    suite.add(false);
    216216    suite.err() << "error: expected p-value>0.5\n  found: "
    217                 << roc.p_value_one_sided() << "\n";
     217                << roc.p_right() << "\n";
    218218  }
    219219}
     
    226226  for (size_t i=0; i<100; ++i)
    227227    roc.add(i, i<50);
    228   if (roc.p_value_one_sided()<0.5) {
     228  if (roc.p_right()<0.5) {
    229229    suite.add(false);
    230230    suite.err() << "error: expected p-value>0.5\n  found: "
    231                 << roc.p_value_one_sided() << "\n";
     231                << roc.p_right() << "\n";
    232232  }
    233233}
     
    267267    suite.out() << "roc area: " << roc.area() << "\n";
    268268  }
    269   double p = roc.p_value_one_sided();
     269  double p = roc.p_right();
    270270  if (!suite.equal(p, 8.0/24.0)) {
    271271    suite.add(false);
    272     suite.out() << "p_value_one_sided() failed\n";
     272    suite.out() << "p_right() failed\n";
    273273  }
    274274  p = roc.p_value();
     
    299299    suite.err() << "area failed\n";
    300300  }
    301   if (!suite.equal(roc.p_value_one_sided(), roc2.p_value_one_sided())) {
     301  if (!suite.equal(roc.p_right(), roc2.p_right())) {
    302302    suite.add(false);
    303303    suite.err() << "exact p failed\n";
     
    305305  roc.minimum_size() = 0;
    306306  roc2.minimum_size() = 0;
    307   if (!suite.equal(roc.p_value_one_sided(), roc2.p_value_one_sided())) {
     307  if (!suite.equal(roc.p_right(), roc2.p_right())) {
    308308    suite.add(false);
    309309    suite.err() << "approximative p failed\n";
     
    351351      break;
    352352  }
    353   double p_value = roc.p_value_one_sided();
     353  double p_value = roc.p_right();
    354354  if (!suite.add(suite.equal(p_value, static_cast<double>(k)/perm))) {
    355355    suite.out() << "area: " << roc.area() << "\n"
     
    357357                << k << " with larger (or equal) area "
    358358                << "corresponding to P=" << static_cast<double>(k)/perm << "\n"
    359                 << "p_value_one_sided() returned: " << p_value
     359                << "p_right() returned: " << p_value
    360360                << "\n";
    361361  }
     
    394394    roc.add(x[i], label[i], w[i]);
    395395  roc.minimum_size() = 0;
    396   double p = roc.p_value_one_sided();
     396  double p = roc.p_right();
    397397
    398398  std::set<size_t> checkpoints;
  • trunk/yat/statistics/ROC.cc

    r2881 r3006  
    44  Copyright (C) 2004, 2005 Peter Johansson
    55  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2011, 2012 Peter Johansson
     6  Copyright (C) 2011, 2012, 2013 Peter Johansson
    77
    88  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    121121  }
    122122
     123
    123124  unsigned int& ROC::minimum_size(void)
    124125  {
     
    188189    return count(utility::pair_first_iterator(multimap_.rbegin()),
    189190                 utility::pair_first_iterator(multimap_.rend()), area);
     191  }
     192
     193
     194  double ROC::p_left() const
     195  {
     196    double area(area_);
     197    if (std::isnan(area)){
     198      AUC auc(false);
     199      area = auc.score(multimap_);
     200    }
     201    if (std::isnan(area))
     202      return std::numeric_limits<double>::quiet_NaN();
     203    if (use_exact_method())
     204      return p_exact_left(area);
     205    return get_p_approx(1-area);
     206  }
     207
     208
     209  double ROC::p_right() const
     210  {
     211    double area(area_);
     212    if (std::isnan(area)){
     213      AUC auc(false);
     214      area = auc.score(multimap_);
     215    }
     216    if (std::isnan(area))
     217      return std::numeric_limits<double>::quiet_NaN();
     218    if (use_exact_method())
     219      return p_exact_right(area);
     220    return get_p_approx(area);
    190221  }
    191222
     
    218249  double ROC::p_value_one_sided() const
    219250  {
    220     double area(area_);
    221     if (std::isnan(area)){
    222       AUC auc(false);
    223       area = auc.score(multimap_);
    224     }
    225     if (std::isnan(area))
    226       return std::numeric_limits<double>::quiet_NaN();
    227     if (use_exact_method())
    228       return p_exact_right(area);
    229     return get_p_approx(area);
     251    return p_right();
    230252  }
    231253
  • trunk/yat/statistics/ROC.h

    r2736 r3006  
    77  Copyright (C) 2004 Peter Johansson
    88  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2011, 2012 Peter Johansson
     9  Copyright (C) 2011, 2012, 2013 Peter Johansson
    1010
    1111  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    127127    double n_pos(void) const;
    128128
     129
     130    /**
     131       Calculates the probability to get this area (or less).
     132
     133       \see p_right for more details
     134     */
     135    double p_left(void) const;
     136
    129137    /**
    130138       \brief One-sided P-value
     
    172180       \return \f$ P(a \ge \textrm{area}) \f$
    173181     */
     182    double p_right(void) const;
     183
     184    /**
     185       \deprecated Provided for backward compatibility with 0.10
     186       API. Use p_right instead.
     187     */
    174188    double p_value_one_sided(void) const;
    175189
     
    189203       \return two-sided p-value
    190204
    191        \see p_value_one_sided
     205       \see p_right
    192206    */
    193207    double p_value(void) const;
Note: See TracChangeset for help on using the changeset viewer.