Definition at line 337 of file ConfusionMatrix.h. References conceptSimTable, Impala::Core::Column::Find(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::GetColumn1(), Impala::Core::Table::SimilarityTableSet::GetName(), Impala::Core::Table::AnnotationTable::GetNrNegative(), Impala::Core::Table::AnnotationTable::GetNrPositive(), Impala::Core::Table::SimilarityTableSet::GetRankTable(), Impala::Core::Table::SimilarityTableSet::GetSimTable(), Impala::Core::Table::AnnotationTableSet::GetTable(), Impala::Core::Table::AnnotationTable::IsPositive(), Impala::Core::Table::AnnotationTable::IsSkip(), mAnnoTabSet, Impala::Core::Table::Bayes::mConceptNum, Impala::Core::Table::Bayes::mConceptSet, mConceptSimSet, mFeatureName, mQuidTable, Impala::Core::Table::Bayes::mSetName, Impala::Core::Table::Bayes::mTableSize, and Impala::Core::Table::Bayes::tabConcept. 00338 { 00339 std::cout << "DumpConfusionMatrixCAMP() - for CAMP tool by Jasper" << std::endl; 00340 00341 // load annotation and similarity tables 00342 for (int c=0 ; c< mConceptNum ; c++) 00343 { 00344 tabConcept[c] = mAnnoTabSet->GetTable(c); 00345 00346 std::cout << "sim table " << c << ", name = " << mConceptSimSet->GetName(c) << std::endl; 00347 conceptSimTable[c] = mConceptSimSet->GetSimTable(c); 00348 } 00349 00350 // we assume skipping is concept-independent. 00351 Impala::Core::Table::AnnotationTable* truth = tabConcept[0]; 00352 int nTotalShots = truth->GetNrPositive() + truth->GetNrNegative(); 00353 00354 00355 // dump similarity table for all the concepts, into a matrix 00356 String fileSimTable = "./ConfusionMatrix/" + mSetName + "_" + mConceptSet + "_" + mFeatureName + "_sim_table.txt"; 00357 FILE* fpSim = fopen(fileSimTable.c_str(), "wt"); 00358 if (NULL == fpSim) 00359 { 00360 std::cout << "File path deos NOT exist: " << fileSimTable << std::endl; 00361 return; 00362 } 00363 fprintf(fpSim,"%d\t%d\n",nTotalShots,mConceptNum); 00364 00365 // dump annotation table for all the concepts, into a matrix 00366 String fileAnnoTable = "./ConfusionMatrix/" + mSetName + "_" + mConceptSet + "_" + mFeatureName + "_anno_table.txt"; 00367 FILE* fpAnno = fopen(fileAnnoTable.c_str(), "wt"); 00368 if (NULL == fpAnno) 00369 { 00370 std::cout << "File path deos NOT exist: " << fileAnnoTable << std::endl; 00371 return; 00372 } 00373 fprintf(fpAnno,"%d\t%d\n",nTotalShots,mConceptNum); 00374 00375 std::cout << "start to merge sim and anno tables into two single files ..." << std::endl; 00376 for (int i=0 ; i<mTableSize ; i++) 00377 { 00378 // only for un-sorted table 00379 Quid quid = mQuidTable->Get1(i); 00380 00381 bool bIsSkip = false; 00382 for (int c=0 ; c<mConceptNum ; c++) 00383 { 00384 Impala::Core::Table::SimilarityTableSet::RankTableType* rank = mConceptSimSet->GetRankTable(c); 00385 Impala::Core::Table::AnnotationTable* groundTruth = tabConcept[c]; 00386 00387 Quid q; 00388 int curPos = -1; 00389 if (bSorted) 00390 { 00391 // only for similarity-based sorted table 00392 q = rank->Get1(i); 00393 curPos = Column::Find(mQuidTable->GetColumn1(), q); 00394 if (curPos == mTableSize) 00395 { 00396 // if returned index is equal to table size, it mean that quid is not found. 00397 std::cout << "Can NOT find the Quid: " << QuidObj(q) << std::endl; 00398 continue; 00399 } 00400 } 00401 else 00402 { 00403 //for un-sorted table 00404 q = quid; 00405 curPos = i; 00406 } 00407 00408 // 1) dump similarity table for the concept c, into a matrix 00409 if (!groundTruth->IsSkip(q)) 00410 { 00411 // skipped shots are all ignored. 00412 // only saving positive or negative samples 00413 Real64 prob = conceptSimTable[c]->Get1(curPos); 00414 fprintf(fpSim,"%f\t", prob); 00415 } 00416 else 00417 { 00418 // we assume skipping is concept-independent. 00419 bIsSkip = true; 00420 00421 break; 00422 } 00423 00424 // 2) dump annotation table for the concept c, into a matrix 00425 if ( groundTruth->IsPositive(q) ) 00426 fprintf(fpAnno,"%d ", 1); 00427 else // ( groundTruth->IsNegative(q) ) 00428 fprintf(fpAnno,"%d ", 0); 00429 //else //( groundTruth->IsSkip(q) ) 00430 //fprintf(fpAnno,"%d ", -1); 00431 00432 } 00433 00434 if ( !bIsSkip) 00435 { 00436 // no blank line for skipped shots. 00437 fprintf(fpSim,"\n"); 00438 fprintf(fpAnno,"\n"); 00439 } 00440 00441 if (i%20000 == 0 && i>0) 00442 { 00443 std::cout << " both saved: " << i << " lines." << std::endl; 00444 } 00445 00446 } 00447 fclose(fpSim); 00448 fclose(fpAnno); 00449 00450 std::cout << "Done. [*_sim_table.txt;*_anno_table.txt]" << std::endl; 00451 00452 int x=0; 00453 }
Here is the call graph for this function:
|