Definition at line 1173 of file mainUtil.cpp. References Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Add(), Impala::Core::Table::AveragePrecision(), Impala::Core::Table::AveragePrecisionConfusion(), Impala::Core::Table::AveragePrecisionJudgedConfusion(), Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Get(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::CmdOptions::GetArg(), Impala::CmdOptions::GetInstance(), Impala::CmdOptions::GetNrArg(), ILOG_ERROR, ILOG_VAR, Impala::Core::Database::MakeRawDataSet(), Impala::MakeString(), Impala::QuidClass(), Impala::Persistency::File::ReadStrings(), and Impala::Persistency::RepositoryGetFile(). Referenced by mainUtil(). 01174 { 01175 typedef Core::Database::RawDataSet RawDataSet; 01176 typedef Core::Table::SimilarityTableSet SimilarityTableSet; 01177 typedef Core::Table::AnnotationTable AnnotationTable; 01178 using Impala::Core::Table::AveragePrecision; 01179 01180 ILOG_VAR(Impala.Application.Util.DoAPConfusion); 01181 CmdOptions& options = CmdOptions::GetInstance(); 01182 if (options.GetNrArg() < 5) 01183 { 01184 ILOG_ERROR("Need more parameters"); 01185 return; 01186 } 01187 String dataSetName = options.GetArg(1); 01188 String conceptSet = options.GetArg(2); 01189 String model = options.GetArg(3); 01190 String feature = options.GetArg(4); 01191 String mappingName; 01192 if (options.GetNrArg() > 5) 01193 mappingName = options.GetArg(5); 01194 01195 RawDataSet* dataSet = Core::Database::MakeRawDataSet(dataSetName); 01196 SimilarityTableSetLocator simLoc(dataSet->GetLocator(), true, "", 01197 conceptSet, model, feature, ""); 01198 SimilarityTableSet* simSet = SimilarityTableSetRepository().Get(simLoc); 01199 Impala::Util::SimpleMap<String, String> conceptMapping; 01200 if (!mappingName.empty()) 01201 { 01202 std::vector<String> lines; 01203 Persistency::File file = RepositoryGetFile(mappingName, false, false); 01204 file.ReadStrings(lines); 01205 for (int i=0 ; i<lines.size() ; i++) 01206 { 01207 Impala::Util::StringParser p(lines[i]); 01208 String src = p.GetString(' '); 01209 String dst = p.GetString(' ', false); 01210 std::cout << src << " => " << dst << std::endl; 01211 conceptMapping.Add(src, dst); 01212 } 01213 } 01214 01215 Core::Table::QuidTable* qTable = simSet->GetQuidTable(); 01216 int qClass = QuidClass(qTable->Get1(0)); 01217 Real64 map = 0; 01218 Real64 mapJ = 0; 01219 Real64 map2000 = 0; 01220 Real64 map2000J = 0; 01221 bool do2000 = (simSet->TableSize() > 2000); 01222 int nrMap = 0; 01223 std::cout << simLoc << ", size = " << simSet->TableSize() << std::endl; 01224 01225 AnnotationTable** allAnnotations = new AnnotationTable*[simSet->NrTables()]; 01226 01227 for (int c=0 ; c<simSet->NrTables() ; c++) 01228 { 01229 String concept = simSet->GetName(c); 01230 String mappedConcept; 01231 if (!mappingName.empty()) 01232 { 01233 if (conceptMapping.Get(concept, mappedConcept)) 01234 { 01235 concept = mappedConcept; 01236 } 01237 else 01238 { 01239 continue; 01240 } 01241 } 01242 AnnotationTableLocator annoLoc(dataSet->GetLocator(), qClass, 01243 conceptSet, concept); 01244 if (!AnnotationTableRepository().Exists(annoLoc)) 01245 { 01246 ILOG_ERROR("No groundtruth for " << concept); 01247 continue; 01248 } 01249 allAnnotations[c] = AnnotationTableRepository().Get(annoLoc); 01250 allAnnotations[c]->UpdateQuidMap(); 01251 } 01252 01253 std::cout << "\nConfusion Matrix Average Precision" << std::endl; 01254 for (int c=0 ; c<simSet->NrTables() ; c++) 01255 { 01256 Real64* confEntry = AveragePrecisionConfusion(simSet->GetRankTable(c), 01257 allAnnotations, 01258 c, simSet->NrTables(), -1); 01259 01260 String concept = simSet->GetName(c); 01261 std::cout << MakeString(concept, 25) << "\t"; 01262 01263 Real64 total = 0; 01264 for (int i=0; i<simSet->NrTables() ; i++) 01265 { 01266 total += confEntry[i]; 01267 std::cout << confEntry[i] << "\t"; 01268 } 01269 01270 std::cout << total << std::endl; 01271 } 01272 01273 std::cout << "\nConfusion Matrix Average Precision Judged" << std::endl; 01274 for (int c=0 ; c<simSet->NrTables() ; c++) 01275 { 01276 Real64* confEntry = 01277 AveragePrecisionJudgedConfusion(simSet->GetRankTable(c), 01278 allAnnotations, 01279 c, simSet->NrTables(), -1); 01280 01281 String concept = simSet->GetName(c); 01282 std::cout << MakeString(concept, 25) << "\t "; 01283 01284 Real64 total = 0; 01285 for (int i=0; i<simSet->NrTables() ; i++) 01286 { 01287 total += confEntry[i]; 01288 std::cout << confEntry[i] << "\t "; 01289 } 01290 01291 std::cout << total << std::endl; 01292 } 01293 01294 for (int i=0; i < simSet->NrTables() ; i++) 01295 delete allAnnotations[i]; 01296 delete allAnnotations; 01297 delete simSet; 01298 delete dataSet; 01299 }
Here is the call graph for this function: ![]()
|