Changeset 2551
 Timestamp:
 Aug 12, 2011, 4:14:01 AM (10 years ago)
 Location:
 trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/roc.cc
r2549 r2551 106 106 for (size_t i=0; i<20; ++i) 107 107 roc.add(10.0, i<10); 108 if (!suite. xadd(suite.equal(roc.area(), 0.5))) {108 if (!suite.add(suite.equal(roc.area(), 0.5))) { 109 109 suite.err() << "error: roc with ties: area: " << roc.area() << "\n"; 110 110 } 
trunk/yat/statistics/AUC.cc
r2119 r2551 20 20 along with yat. If not, see <http://www.gnu.org/licenses/>. 21 21 */ 22 23 #include <iostream> 22 24 23 25 #include "AUC.h" … … 94 96 double cumsum_pos_w=0; 95 97 double cumsum_neg_w=0; 96 double cache_cumsum_pos_w=0;97 double cache_cumsum_neg_w=0;98 98 typedef MultiMap::const_iterator iter; 99 99 100 for (iter i=m.begin(); i!=m.end(); ++i) { 101 if (i>second.first){ 102 cache_cumsum_pos_w += i>second.second; 103 } 104 else 105 cache_cumsum_neg_w += i>second.second; 106 107 iter n(i); 108 ++n; 109 // last entry OR entry is smaller than next one 110 if ( n==m.end()  i>first < n>first) { 111 if (i>second.first) 112 area += cache_cumsum_pos_w * ( cumsum_neg_w + cache_cumsum_neg_w/2 ); 113 cumsum_pos_w += cache_cumsum_pos_w; 114 cache_cumsum_pos_w = 0; 115 cumsum_neg_w += cache_cumsum_neg_w; 116 cache_cumsum_neg_w = 0; 117 } 100 iter first = m.begin(); 101 while (first!=m.end()) { 102 double local_cumsum_pos_w=0; 103 double local_cumsum_neg_w=0; 104 iter last = first; 105 while (last!=m.end() && first>first==last>first) { 106 if (last>second.first) 107 local_cumsum_pos_w += last>second.second; 108 else 109 local_cumsum_neg_w += last>second.second; 110 ++last; 111 } 112 area += local_cumsum_pos_w * ( cumsum_neg_w + 0.5*local_cumsum_neg_w ); 113 cumsum_pos_w += local_cumsum_pos_w; 114 cumsum_neg_w += local_cumsum_neg_w; 115 first = last; 118 116 } 119 117 // max area is cumsum_neg_w * cumsum_pos_w
Note: See TracChangeset
for help on using the changeset viewer.