Home || Visual Search || Applications || Architecture || 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 
00019 class PrecisionAtN : public Evaluation
00020 {
00021 public:
00022 
00023     PrecisionAtN(Table::AnnotationTable* annotation, int n) :
00024         Evaluation(annotation)
00025     {
00026         mN = n;
00027     }
00028 
00029     virtual double
00030     Compute(Table::ScoreTable* table)
00031     {
00032         Sort(table, 2, false);
00033 
00034         int positiveCount = 0;
00035         int i;
00036         for (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 precision = ((double)positiveCount)/((double)(i));
00043         return precision;
00044     }
00045 
00046 private:
00047 
00048     int mN; // N is the number at which we compute the precision.
00049 
00050 };
00051 
00052 }//namespace Core
00053 }//namespace Training
00054 }//namespace Impala
00055 
00056 #endif

Generated on Thu Jan 13 09:04:41 2011 for ImpalaSrc by  doxygen 1.5.1