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 00015 class AreaUnderRocCurve : public Evaluation 00016 { 00017 public: 00018 AreaUnderRocCurve(Table::AnnotationTable* annotation) : 00019 Evaluation(annotation) 00020 { 00021 } 00022 00023 virtual double Compute(Table::AnnotationTableBaseType* table) 00024 { 00025 Sort(table, 2, false); 00026 return SubCompute(table); 00027 } 00028 00029 virtual double ComputeReverse(Table::AnnotationTableBaseType* table) 00030 { 00031 Sort(table, 2, false); 00032 Reverse(table); 00033 return SubCompute(table); 00034 } 00035 00036 private: 00037 double SubCompute(Table::AnnotationTableBaseType* table) 00038 { 00039 int pos = 0; 00040 int neg = 0; 00041 int area = 0; 00042 for(int i=0 ; i<table->Size() ; i++) 00043 { 00044 Quid q = table->Get1(i); 00045 if(mAnnotation->IsPositive(q)) 00046 ++pos; 00047 else //if(mAnnotation->IsNegative(q)) 00048 { 00049 area += pos; 00050 ++neg; 00051 } 00052 } 00053 return (double)area / (double)(pos*neg); 00054 } 00055 }; 00056 00057 }//namespace Core 00058 }//namespace Training 00059 }//namespace Impala 00060 00061 #endif