00001 #ifndef Impala_Core_Training_RecallAtN_h 00002 #define Impala_Core_Training_RecallAtN_h 00003 00004 #include "Core/Training/Evaluation.h" 00005 #include "Core/Table/Sort.h" 00006 #include "Core/Table/Reverse.h" 00007 00008 namespace Impala 00009 { 00010 namespace Core 00011 { 00012 namespace Training 00013 { 00014 00015 00021 class RecallAtN : public Evaluation 00022 { 00023 public: 00024 RecallAtN(Table::AnnotationTable* annotation, int n, int totalRelevance) : 00025 Evaluation(annotation) 00026 { 00027 mN = n; 00028 mTotalRelevance = totalRelevance; 00029 } 00030 00031 virtual double Compute(Table::AnnotationTableBaseType* table) 00032 { 00033 Sort(table, 2, false); 00034 00035 int positiveCount=0; 00036 for(int i=0 ; i<table->Size() && i<mN ; i++) 00037 { 00038 Quid q = table->Get1(i); 00039 if(mAnnotation->IsPositive(q)) 00040 positiveCount++; 00041 } 00042 double recall = ((double)positiveCount)/((double)mTotalRelevance); 00043 return recall; 00044 } 00045 private: 00046 int mN; // sorry not really descriptive name: N is the number at which we compute the precision. 00047 int mTotalRelevance; 00048 }; 00049 00050 }//namespace Core 00051 }//namespace Training 00052 }//namespace Impala 00053 00054 #endif