Commit 4fca0204ec12aabaa72d2688f9758a6df968546b

Authored by bhklein
1 parent 809523f2

some fixes to iet calculation

Showing 1 changed file with 24 additions and 9 deletions
openbr/core/eval.cpp
@@ -1358,14 +1358,19 @@ void EvalKNN(const QString &knnGraph, const QString &knnTruth, const QString &ie @@ -1358,14 +1358,19 @@ void EvalKNN(const QString &knnGraph, const QString &knnTruth, const QString &ie
1358 */ 1358 */
1359 QVector<int> firstGenuineReturns(probeCount, 0); 1359 QVector<int> firstGenuineReturns(probeCount, 0);
1360 QList<float> matedSimilarities, unmatedSimilarities; 1360 QList<float> matedSimilarities, unmatedSimilarities;
1361 - size_t numMatedSearches = 0; 1361 + size_t numMatedSearches = 0, numUnmatedSearches = 0;
1362 for (size_t i=0; i<probeCount; i++) { 1362 for (size_t i=0; i<probeCount; i++) {
1363 const QList<size_t> &mates = truth[i]; 1363 const QList<size_t> &mates = truth[i];
1364 - if (!mates.empty())  
1365 - numMatedSearches++;  
1366 -  
1367 bool recordedHighestMatedSimilarity = false; 1364 bool recordedHighestMatedSimilarity = false;
1368 bool recordedHighestUnmatedSimilarity = false; 1365 bool recordedHighestUnmatedSimilarity = false;
  1366 + if (!mates.empty()) {
  1367 + numMatedSearches++;
  1368 + recordedHighestUnmatedSimilarity = true;
  1369 + } else {
  1370 + numUnmatedSearches++;
  1371 + recordedHighestMatedSimilarity = true;
  1372 + }
  1373 +
1369 for (size_t j=0; j<k; j++) { 1374 for (size_t j=0; j<k; j++) {
1370 const Candidate &neighbor = neighbors[i*k+j]; 1375 const Candidate &neighbor = neighbors[i*k+j];
1371 1376
@@ -1421,8 +1426,9 @@ void EvalKNN(const QString &amp;knnGraph, const QString &amp;knnTruth, const QString &amp;ie @@ -1421,8 +1426,9 @@ void EvalKNN(const QString &amp;knnGraph, const QString &amp;knnTruth, const QString &amp;ie
1421 * for each threshold count the number mated and unmated searches, 1426 * for each threshold count the number mated and unmated searches,
1422 * record the corresponding FPIR and FNIR values for the threshold. 1427 * record the corresponding FPIR and FNIR values for the threshold.
1423 */ 1428 */
1424 - size_t matedCount = 0;  
1425 - size_t unmatedCount = 0; 1429 + QList<OperatingPoint> operatingPoints;
  1430 + size_t matedCount = 0, previousMatedCount = 0;
  1431 + size_t unmatedCount = 0, previousUnmatedCount = 0;
1426 while (!matedSimilarities.empty()) { 1432 while (!matedSimilarities.empty()) {
1427 const float threshold = matedSimilarities.back(); 1433 const float threshold = matedSimilarities.back();
1428 while (!matedSimilarities.empty() && (matedSimilarities.back() >= threshold)) { 1434 while (!matedSimilarities.empty() && (matedSimilarities.back() >= threshold)) {
@@ -1433,10 +1439,19 @@ void EvalKNN(const QString &amp;knnGraph, const QString &amp;knnTruth, const QString &amp;ie @@ -1433,10 +1439,19 @@ void EvalKNN(const QString &amp;knnGraph, const QString &amp;knnTruth, const QString &amp;ie
1433 unmatedSimilarities.removeLast(); 1439 unmatedSimilarities.removeLast();
1434 unmatedCount++; 1440 unmatedCount++;
1435 } 1441 }
1436 - ietFile.write(qPrintable(QString::number(threshold) + "," +  
1437 - QString::number(double(unmatedCount) / double(numUnmatedSimilarities)) + "," +  
1438 - QString::number(1.0 - double(matedCount) / double(numMatedSimilarities)) + "\n")); 1442 + if ((unmatedCount > previousUnmatedCount) && (matedCount > previousMatedCount)) {
  1443 + previousMatedCount = matedCount;
  1444 + previousUnmatedCount = unmatedCount;
  1445 + operatingPoints.append(OperatingPoint(threshold,
  1446 + double(unmatedCount) / double(numUnmatedSimilarities),
  1447 + 1.0 - double(matedCount) / double(numMatedSimilarities)));
  1448 + }
1439 } 1449 }
  1450 +
  1451 + foreach(const OperatingPoint &operatingPoint, operatingPoints)
  1452 + ietFile.write(qPrintable(QString::number(operatingPoint.score) + "," +
  1453 + QString::number(operatingPoint.FAR) + "," +
  1454 + QString::number(operatingPoint.TAR) + "\n"));
1440 } 1455 }
1441 1456
1442 } // namespace br 1457 } // namespace br