Definition at line 810 of file mainUtil.cpp. References Impala::Core::Table::AveragePrecision(), Impala::Core::Table::AveragePrecisionConfusion(), Impala::Core::Table::AveragePrecisionJudgedConfusion(), Impala::Util::DatabaseReadStrings(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::CmdOptions::GetArg(), Impala::Util::Database::GetFilePath(), Impala::CmdOptions::GetInstance(), Impala::CmdOptions::GetNrArg(), ILOG_ERROR, ILOG_VAR, Impala::Core::Table::SimilarityTableSet::MakeFromFile(), Impala::Core::Database::MakeRawDataSet(), Impala::MakeString(), and Impala::QuidClass(). Referenced by mainUtil(). 00811 { 00812 #ifndef REPOSITORY_TODO 00813 typedef Core::Database::RawDataSet RawDataSet; 00814 typedef Core::Table::SimilarityTableSet SimilarityTableSet; 00815 typedef Core::Table::AnnotationTable AnnotationTable; 00816 using Impala::Core::Table::AveragePrecision; 00817 00818 ILOG_VAR(Impala.Application.Util.DoAPConfusion); 00819 CmdOptions& options = CmdOptions::GetInstance(); 00820 if (options.GetNrArg() < 4) 00821 { 00822 ILOG_ERROR("Need more parameters"); 00823 return; 00824 } 00825 String dataSetName = options.GetArg(1); 00826 String annoSet = options.GetArg(2); 00827 String namesPath = options.GetArg(3); 00828 String mappingName; 00829 if (options.GetNrArg() > 4) 00830 mappingName = options.GetArg(4); 00831 00832 RawDataSet* dataSet = Core::Database::MakeRawDataSet(dataSetName); 00833 Impala::Util::Database* db = dataSet->GetDatabase(); 00834 SimilarityTableSet* simSet = 00835 Core::Table::SimilarityTableSet::MakeFromFile( 00836 db->GetFilePath(".", namesPath, false, false), db); 00837 00838 Impala::Util::SimpleMap<String, String> conceptMapping; 00839 if (!mappingName.empty()) 00840 { 00841 std::vector<String> lines; 00842 Impala::Util::DatabaseReadStrings(lines, mappingName, db); 00843 for (int i=0 ; i<lines.size() ; i++) 00844 { 00845 Impala::Util::StringParser p(lines[i]); 00846 String src = p.GetString(' '); 00847 String dst = p.GetString(' ', false); 00848 std::cout << src << " => " << dst << std::endl; 00849 conceptMapping.Add(src, dst); 00850 } 00851 } 00852 00853 Core::Table::QuidTable* qTable = simSet->GetQuidTable(); 00854 int qClass = QuidClass(qTable->Get1(0)); 00855 Real64 map = 0; 00856 Real64 mapJ = 0; 00857 Real64 map2000 = 0; 00858 Real64 map2000J = 0; 00859 bool do2000 = (simSet->TableSize() > 2000); 00860 int nrMap = 0; 00861 std::cout << namesPath << ", size = " << simSet->TableSize() << std::endl; 00862 00863 AnnotationTable** allAnnotations = new AnnotationTable*[simSet->NrTables()]; 00864 00865 for (int c=0; c<simSet->NrTables() ; c++){ 00866 String concept = simSet->GetName(c); 00867 String mappedConcept; 00868 if (!mappingName.empty()) 00869 { 00870 if (conceptMapping.Get(concept, mappedConcept)) 00871 { 00872 concept = mappedConcept; 00873 } 00874 else 00875 { 00876 continue; 00877 } 00878 } 00879 String fName = dataSet->GetFilePathAnnotation(qClass, annoSet, 00880 concept + ".tab", 00881 false, false); 00882 00883 if (fName.empty()) 00884 { 00885 ILOG_ERROR("No groundtruth for " << concept); 00886 continue; 00887 } 00888 00889 allAnnotations[c] = AnnotationTable::MakeFromFile(concept, fName, db); 00890 allAnnotations[c]->UpdateQuidMap(); 00891 } 00892 00893 std::cout << "\nConfusion Matrix Average Precision" << std::endl; 00894 for (int c=0 ; c<simSet->NrTables() ; c++) 00895 { 00896 Real64* confEntry = AveragePrecisionConfusion(simSet->GetRankTable(c), allAnnotations, 00897 c, simSet->NrTables(), -1); 00898 00899 String concept = simSet->GetName(c); 00900 std::cout << MakeString(concept, 25) << "\t"; 00901 00902 Real64 total = 0; 00903 for (int i=0; i<simSet->NrTables() ; i++) 00904 { 00905 total += confEntry[i]; 00906 std::cout << confEntry[i] << "\t"; 00907 } 00908 00909 std::cout << total << std::endl; 00910 } 00911 00912 std::cout << "\nConfusion Matrix Average Precision Judged" << std::endl; 00913 for (int c=0 ; c<simSet->NrTables() ; c++) 00914 { 00915 Real64* confEntry = AveragePrecisionJudgedConfusion(simSet->GetRankTable(c), allAnnotations, 00916 c, simSet->NrTables(), -1); 00917 00918 String concept = simSet->GetName(c); 00919 std::cout << MakeString(concept, 25) << "\t "; 00920 00921 Real64 total = 0; 00922 for (int i=0; i<simSet->NrTables() ; i++) 00923 { 00924 total += confEntry[i]; 00925 std::cout << confEntry[i] << "\t "; 00926 } 00927 00928 std::cout << total << std::endl; 00929 } 00930 00931 for (int i=0; i < simSet->NrTables() ; i++) 00932 delete allAnnotations[i]; 00933 delete allAnnotations; 00934 delete simSet; 00935 delete dataSet; 00936 #endif 00937 }
Here is the call graph for this function:
|