00001 #ifndef Impala_Core_Training_MakeEvaluation_h
00002 #define Impala_Core_Training_MakeEvaluation_h
00003
00004 #include "Basis/String.h"
00005 #include "Core/Training/AveragePrecision.h"
00006 #include "Core/Training/BalancedAveragePrecision.h"
00007 #include "Core/Training/AreaUnderRocCurve.h"
00008 #include "Core/Training/PrecisionAtN.h"
00009 #include "Core/Training/RecallAtN.h"
00010
00011 namespace Impala
00012 {
00013 namespace Core
00014 {
00015 namespace Training
00016 {
00017
00027 Evaluation* MakeEvaluation(const std::string& description,
00028 Table::AnnotationTable* annotation)
00029 {
00030 ILOG_VAR(Impala.Core.Training.MakeEvaluation);
00031
00032 if(description == "ap" ||
00033 description == "AP" ||
00034 description == "AveragePrecision")
00035 return new AveragePrecision(annotation);
00036 if(description == "bap" ||
00037 description == "BAP" ||
00038 description == "BalancedAveragePrecision")
00039 return new BalancedAveragePrecision(annotation);
00040 if(description == "auc" ||
00041 description == "AUC" ||
00042 description == "AreaUnderRocCurve")
00043 return new AreaUnderRocCurve(annotation);
00044 if(description.substr(0,2) == "P@")
00045 {
00046 int n = atoi(description.substr(2));
00047 return new PrecisionAtN(annotation, n);
00048 }
00049 if(description.substr(0,10) == "precision@")
00050 {
00051 int n = atoi(description.substr(10));
00052 return new PrecisionAtN(annotation, n);
00053 }
00054 if(description.substr(0,2) == "R@")
00055 {
00056 int n = atoi(description.substr(2));
00057 int totalRelevance = annotation->GetNrPositive();
00058 return new RecallAtN(annotation, n, totalRelevance);
00059 }
00060 if(description.substr(0,10) == "recall@")
00061 {
00062 int n = atoi(description.substr(10));
00063 int totalRelevance = annotation->GetNrPositive();
00064 return new RecallAtN(annotation, n, totalRelevance);
00065 }
00066 ILOG_ERROR("description not recognised" << description);
00067 return new Evaluation(annotation);
00068 }
00069
00070
00071 }
00072 }
00073 }
00074
00075 #endif
00076