Definition at line 49 of file BalancedAveragePrecision.h. References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::Core::Table::AnnotationTable::IsPositive(), Impala::Core::Training::Evaluation::mAnnotation, Impala::Application::DemoCamera2d::precision, and Impala::Core::Table::Table::Size(). Referenced by Compute(), and ComputeReversed(). 00050 { 00051 // first compute AP 00052 double ap=0; 00053 int positiveCount=0; 00054 for(int i=0 ; i<table->Size() ; i++) 00055 { 00056 Quid q = table->Get1(i); 00057 if(mAnnotation->IsPositive(q)) 00058 { 00059 positiveCount++; 00060 double precision = ((double)positiveCount)/((double)(i+1)); 00061 ap += precision; 00062 } 00063 } 00064 if(positiveCount > 0) 00065 ap /= (double)positiveCount; 00066 00067 // then compute WAP (worst case AP, ie: assume all perfectly-wrong) 00068 double wap = 0; 00069 double WminusR = table->Size() - positiveCount; 00070 for(int i=1 ; i<=positiveCount ; i++) 00071 { 00072 wap = wap + ((double)i)/(WminusR + (double)i); 00073 } 00074 wap /= (double)positiveCount; 00075 00076 // finally, compute BAP 00077 double bap = 1.0; 00078 if(wap!=1.0) 00079 bap = (ap - wap)/(1-wap); 00080 00081 return bap; 00082 }
Here is the call graph for this function:
|