Changeset 2720
- Timestamp:
- Apr 12, 2012, 5:40:00 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/roc.cc
r2718 r2720 54 54 void test_p_with_weights(test::Suite& suite); 55 55 void test_p_with_weights_and_ties(test::Suite& suite); 56 void test_remove(test::Suite& suite); 56 57 void test_ties(test::Suite& suite); 57 58 … … 120 121 test_empty(suite); 121 122 test_p_with_weights(suite); 123 test_remove(suite); 122 124 return suite.return_value(); 123 125 } … … 426 428 } 427 429 } 430 431 void test_remove(test::Suite& suite) 432 { 433 using statistics::ROC; 434 ROC roc; 435 roc.add(1, true); 436 roc.add(2, false); 437 ROC roc2(roc); 438 if (!suite.add(suite.equal(roc.area(), roc2.area()))) 439 suite.out() << "test_remove failed: copy failed\n"; 440 roc.add(2.3, true, 1.2); 441 try { 442 roc.remove(2.3, true, 1.2); 443 } 444 catch (std::runtime_error& e) { 445 suite.add(false); 446 suite.out() << "exception what(): " << e.what() << "\n"; 447 } 448 if (!suite.add(suite.equal(roc.area(), roc2.area()))) 449 suite.out() << "test remove failed\n"; 450 try { 451 roc.remove(2, true); 452 suite.out() << "no exception thrown\n"; 453 suite.add(false); 454 } 455 catch (std::runtime_error& e) { 456 suite.add(true); 457 } 458 } -
trunk/yat/statistics/ROC.cc
r2718 r2720 25 25 #include "AUC.h" 26 26 27 #include "yat/utility/Exception.h" 28 27 29 #include <gsl/gsl_cdf.h> 28 30 … … 31 33 #include <cmath> 32 34 #include <limits> 35 #include <sstream> 33 36 #include <utility> 34 37 … … 226 229 227 230 231 void ROC::remove(double value, bool target, double weight) 232 { 233 std::pair<Map::iterator, Map::iterator> iter = multimap_.equal_range(value); 234 while (iter.first!=iter.second) { 235 if (iter.first->second.first==target && iter.first->second.first==target){ 236 multimap_.erase(iter.first); 237 return; 238 } 239 ++iter.first; 240 } 241 std::stringstream ss; 242 ss << "ROC::remove(" << value << "," << target << "," << weight << "): " 243 << "no such element"; 244 throw utility::runtime_error(ss.str()); 245 } 246 247 228 248 void ROC::reset(void) 229 249 { -
trunk/yat/statistics/ROC.h
r2719 r2720 190 190 */ 191 191 double p_value(void) const; 192 193 /** 194 \brief remove a data value 195 196 A data point with identical \a value, \a target, and \a weight 197 must have beed added prior calling this function; else an 198 exception is thrown. 199 200 \since New in yat 0.9 201 */ 202 void remove(double value, bool target, double weight=1.0); 192 203 193 204 /**
Note: See TracChangeset
for help on using the changeset viewer.