Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

PrecisionAtN.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Training_PrecisionAtN_h
00002 #define Impala_Core_Training_PrecisionAtN_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 
00018 class PrecisionAtN : public Evaluation
00019 {
00020 public:
00021     PrecisionAtN(Table::AnnotationTable* annotation, int n) :
00022         Evaluation(annotation)
00023     {
00024         mN = n;
00025     }
00026 
00027     virtual double Compute(Table::AnnotationTableBaseType* table)
00028     {
00029         Sort(table, 2, false);
00030 
00031         int positiveCount=0;
00032         int i;
00033         for(i=0 ; i<table->Size() && i<mN ; ++i)
00034         {
00035             Quid q = table->Get1(i);
00036             if(mAnnotation->IsPositive(q))
00037                 positiveCount++;
00038         }
00039         double precision = ((double)positiveCount)/((double)(i));
00040         return precision;
00041     }
00042 private:
00043     int mN; // sorry not really descriptive name: N is the number at which we compute the precision.
00044 };
00045 
00046 }//namespace Core
00047 }//namespace Training
00048 }//namespace Impala
00049 
00050 #endif

Generated on Fri Mar 19 09:31:24 2010 for ImpalaSrc by  doxygen 1.5.1