template<class T>
Definition at line 19 of file AveragePrecisionSpeedup.h. References Impala::Core::Table::AnnotationTable::GetNrPositive(), ILOG_VAR, Impala::Core::Table::AnnotationTable::IsPositive(), and Impala::Application::DemoCamera2d::precision. 00020 { 00021 ILOG_VAR(Impala.Core.Table.AveragePrecisionSpeedup); 00022 Real64 ap = 0; 00023 00024 Real64 pos99 = 0.999; // status = 3 00025 Real64 pos90 = 0.9; // status = 2 00026 Real64 pos10 = 0.1; // status = 1 00027 00028 Real64 curPos = 0; 00029 00030 // setting default status = 1 00031 int status = 1; 00032 Real64 curRef = pos10; 00033 00034 int totalPositive = groundTruth->GetNrPositive(); 00035 if ( 0 == totalPositive) 00036 return -1; 00037 00038 int positiveCount = 0; 00039 if (topN == -1) 00040 topN = rank->Size(); 00041 00042 //std::vector<T*> rank_Rkf; 00043 //T* rank_tmp = new T(topN); 00044 //rank_tmp->SetColName(1, "id"); 00045 //rank_Rkf.push_back(rank_tmp); 00046 00047 for (int i=0 ; i<topN ; i++) 00048 { 00049 Quid q = rank->Get1(i); 00050 if (groundTruth->IsPositive(q)) 00051 { 00052 positiveCount++; 00053 double precision = ((double)positiveCount)/((double)(i+1)); 00054 ap += precision; 00055 00056 // added by Jun Wu 00057 // compute the measure: recall 00058 curPos = positiveCount*1.0/totalPositive; 00059 00060 switch (status) { 00061 case 1: 00062 00063 if (curPos > curRef) 00064 { 00065 // reaching the point of 10% 00066 Real64 ratio = (positiveCount-1)*1.0/topN; 00067 fprintf(stdout," [1]recall=10.0%s %d / %d N= %d ratio= %f speedup= %.3f pos= %d\n", "%", positiveCount-1, totalPositive,topN, ratio, 0.1/ratio,i); 00068 status = 2; 00069 curRef = pos90; 00070 00071 } 00072 00073 break; 00074 00075 case 2: 00076 00077 if (curPos > curRef) 00078 { 00079 // reaching the point of 90% 00080 Real64 ratio = (positiveCount-1)*1.0/topN; 00081 fprintf(stdout," [2]recall=90.0%s %d / %d N= %d ratio= %f speedup= %.3f pos= %d\n", "%", positiveCount-1, totalPositive,topN, ratio, 0.9/ratio,i); 00082 status = 3; 00083 curRef = pos99; 00084 00085 } 00086 break; 00087 00088 case 3: 00089 00090 if (curPos > curRef) 00091 { 00092 // reaching the point of 99.9% 00093 Real64 ratio = (positiveCount-1)*1.0/topN; 00094 fprintf(stdout," [3]recall=99.9%s %d / %d N= %d ratio= %f speedup= %.3f pos= %d\n", "%", positiveCount, totalPositive,topN, ratio, 0.999/ratio,i+1); 00095 status = -1; 00096 curRef = 1e5; 00097 00098 } 00099 break; 00100 00101 default: 00102 00103 break; 00104 } 00105 // end of adding, by Jun Wu 00106 00107 } 00108 } 00109 if (groundTruth->GetNrPositive() > 0) 00110 ap /= groundTruth->GetNrPositive(); 00111 return ap; 00112 }
Here is the call graph for this function:
|