00001 #ifndef Impala_CoreTraining_AreaUnderRocCurve_h 00002 #define Impala_CoreTraining_AreaUnderRocCurve_h 00003 00004 #include "Core/Training/Evaluation.h" 00005 00006 namespace Impala 00007 { 00008 namespace Core 00009 { 00010 namespace Training 00011 { 00012 00016 class AreaUnderRocCurve : public Evaluation 00017 { 00018 public: 00019 00020 AreaUnderRocCurve(Table::AnnotationTable* annotation) : 00021 Evaluation(annotation) 00022 { 00023 } 00024 00025 virtual double 00026 Compute(Table::ScoreTable* table) 00027 { 00028 Sort(table, 2, false); 00029 return SubCompute(table); 00030 } 00031 00032 virtual double 00033 ComputeReverse(Table::ScoreTable* table) 00034 { 00035 Sort(table, 2, false); 00036 Reverse(table); 00037 return SubCompute(table); 00038 } 00039 00040 private: 00041 00042 double 00043 SubCompute(Table::ScoreTable* table) 00044 { 00045 int pos = 0; 00046 int neg = 0; 00047 int area = 0; 00048 for (int i=0 ; i<table->Size() ; i++) 00049 { 00050 Quid q = table->Get1(i); 00051 if (mAnnotation->IsPositive(q)) 00052 { 00053 ++pos; 00054 } 00055 else //if(mAnnotation->IsNegative(q)) 00056 { 00057 area += pos; 00058 ++neg; 00059 } 00060 } 00061 return (double)area / (double)(pos*neg); 00062 } 00063 }; 00064 00065 }//namespace Core 00066 }//namespace Training 00067 }//namespace Impala 00068 00069 #endif