Commit 782b5bcfe4eb21717a477fa3cd6c54e14ebe7e0a

Authored by Josh Klontz
1 parent 26cffad3

removed unnecessary eval/plot functionality

openbr/core/plot.cpp
... ... @@ -173,7 +173,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv)
173 173 // Sort comparisons by simmat_val (score)
174 174 std::sort(comparisons.begin(), comparisons.end());
175 175  
176   - double genuineSum = 0, impostorSum = 0;
177 176 QList<OperatingPoint> operatingPoints;
178 177 QList<float> genuines, impostors;
179 178 QVector<int> firstGenuineReturns(simmat.rows, 0);
... ... @@ -192,7 +191,6 @@ float Evaluate(const Mat &amp;simmat, const Mat &amp;mask, const QString &amp;csv)
192 191 const Comparison &comparison = comparisons[index];
193 192 if (comparison.genuine) {
194 193 truePositives++;
195   - genuineSum += comparison.score;
196 194 genuines.append(comparison.score);
197 195 if (firstGenuineReturns[comparison.query] < 1)
198 196 firstGenuineReturns[comparison.query] = abs(firstGenuineReturns[comparison.query]) + 1;
... ... @@ -201,7 +199,6 @@ float Evaluate(const Mat &amp;simmat, const Mat &amp;mask, const QString &amp;csv)
201 199 minGenuineScore = comparison.score;
202 200 } else {
203 201 falsePositives++;
204   - impostorSum += comparison.score;
205 202 impostors.append(comparison.score);
206 203 if (firstGenuineReturns[comparison.query] < 1)
207 204 firstGenuineReturns[comparison.query]--;
... ... @@ -247,7 +244,6 @@ float Evaluate(const Mat &amp;simmat, const Mat &amp;mask, const QString &amp;csv)
247 244 QString::number(1-operatingPoint.TAR)));
248 245 }
249 246  
250   -
251 247 // Write FAR/TAR Bar Chart (BC)
252 248 lines.append(qPrintable(QString("BC,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3))));
253 249 lines.append(qPrintable(QString("BC,0.01,%1").arg(QString::number(result = getTAR(operatingPoints, 0.01), 'f', 3))));
... ... @@ -267,14 +263,6 @@ float Evaluate(const Mat &amp;simmat, const Mat &amp;mask, const QString &amp;csv)
267 263 sampledImpostorScores.append(impostorScore);
268 264 }
269 265  
270   - const double hGenuine = Common::KernelDensityBandwidth(sampledGenuineScores);
271   - foreach (double f, sampledGenuineScores)
272   - lines.append(QString("KDEGenuine,%1,%2").arg(QString::number(f), QString::number(Common::KernelDensityEstimation(sampledGenuineScores, f, hGenuine))));
273   -
274   - const double hImpostor = Common::KernelDensityBandwidth(sampledImpostorScores);
275   - foreach (double f, sampledImpostorScores)
276   - lines.append(QString("KDEImpostor,%1,%2").arg(QString::number(f), QString::number(Common::KernelDensityEstimation(sampledImpostorScores, f, hImpostor))));
277   -
278 266 // Write Cumulative Match Characteristic (CMC) curve
279 267 const int Max_Retrieval = 100;
280 268 const int Report_Retrieval = 5;
... ... @@ -477,11 +465,6 @@ struct RPlot
477 465 if (success && show) QtUtils::showFile(basename+"."+suffix);
478 466 return success;
479 467 }
480   -
481   - QString subfile(const QString &name) const
482   - {
483   - return basename+"_"+name+"."+suffix;
484   - }
485 468 };
486 469  
487 470 bool Plot(const QStringList &files, const br::File &destination, bool show)
... ... @@ -498,8 +481,7 @@ bool Plot(const QStringList &amp;files, const br::File &amp;destination, bool show)
498 481 QString(", xlab=\"False Accept Rate\", ylab=\"True Accept Rate\") + theme_minimal()") +
499 482 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) +
500 483 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
501   - QString(" + scale_x_log10(labels=percent) + scale_y_continuous(labels=percent) + annotation_logticks(sides=\"b\")") +
502   - QString("\nggsave(\"%1\")\n\n").arg(p.subfile("ROC"))));
  484 + QString(" + scale_x_log10(labels=percent) + scale_y_continuous(labels=percent) + annotation_logticks(sides=\"b\")\n\n")));
503 485  
504 486 p.file.write(qPrintable(QString("qplot(X, Y, data=DET%1").arg((p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") +
505 487 (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) +
... ... @@ -507,24 +489,21 @@ bool Plot(const QStringList &amp;files, const br::File &amp;destination, bool show)
507 489 QString(", xlab=\"False Accept Rate\", ylab=\"False Reject Rate\") + geom_abline(alpha=0.5, colour=\"grey\", linetype=\"dashed\") + theme_minimal()") +
508 490 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) +
509 491 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
510   - QString(" + scale_x_log10(labels=percent) + scale_y_log10(labels=percent) + annotation_logticks()") +
511   - QString("\nggsave(\"%1\")\n\n").arg(p.subfile("DET"))));
  492 + QString(" + scale_x_log10(labels=percent) + scale_y_log10(labels=percent) + annotation_logticks()\n\n")));
512 493  
513 494 p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") +
514 495 QString(", xlab=\"Score%1\"").arg((p.flip ? p.major.size : p.minor.size) > 1 ? " / " + (p.flip ? p.major.header : p.minor.header) : QString()) +
515 496 QString(", ylab=\"Frequency%1\"").arg((p.flip ? p.minor.size : p.major.size) > 1 ? " / " + (p.flip ? p.minor.header : p.major.header) : QString()) +
516 497 QString(") + scale_fill_manual(\"Ground Truth\", values=c(\"blue\", \"red\")) + theme_minimal() + scale_x_continuous(minor_breaks=NULL) + scale_y_continuous(minor_breaks=NULL) + theme(axis.text.y=element_blank(), axis.ticks=element_blank(), axis.text.x=element_text(angle=-90, hjust=0))") +
517 498 (p.major.size > 1 ? (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ %1, scales=\"free\")").arg((p.flip ? p.major.header : p.minor.header), (p.flip ? p.minor.header : p.major.header)) : QString(" + facet_wrap(~ %1, scales = \"free\")").arg(p.major.header)) : QString()) +
518   - QString(" + theme(aspect.ratio=1)") +
519   - QString("\nggsave(\"%1\")\n\n").arg(p.subfile("SD"))));
  499 + QString(" + theme(aspect.ratio=1)\n\n")));
520 500  
521 501 p.file.write(qPrintable(QString("ggplot(CMC, aes(x=X, y=Y%1%2)) + xlab(\"Rank\") + ylab(\"Retrieval Rate\")").arg(p.major.size > 1 ? QString(" ,colour=factor(%1)").arg(p.major.header) : QString(), p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) +
522 502 ((p.major.smooth || p.minor.smooth) ? (minimalist ? " + stat_summary(geom=\"line\", fun.y=mean)" : " + stat_summary(geom=\"line\", fun.y=min, aes(linetype=\"Min/Max\")) + stat_summary(geom=\"line\", fun.y=max, aes(linetype=\"Min/Max\")) + stat_summary(geom=\"line\", fun.y=mean, aes(linetype=\"Mean\")) + scale_linetype_manual(\"Legend\", values=c(\"Mean\"=1, \"Min/Max\"=2))") : " + geom_line()") +
523   - (minimalist ? "" : "+ scale_x_log10(labels=c(1,5,10,50,100), breaks=c(1,5,10,50,100)) + annotation_logticks(sides=\"b\")") +
  503 + (minimalist ? "" : " + scale_x_log10(labels=c(1,5,10,50,100), breaks=c(1,5,10,50,100)) + annotation_logticks(sides=\"b\")") +
524 504 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) +
525 505 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
526   - QString(" + theme_minimal() + scale_y_continuous(labels=percent)") +
527   - QString("\nggsave(\"%1\")\n\n").arg(p.subfile("CMC"))));
  506 + QString(" + theme_minimal() + scale_y_continuous(labels=percent)\n\n")));
528 507  
529 508 p.file.write(qPrintable(QString("qplot(factor(%1)%2, data=BC, %3").arg(p.major.smooth ? (p.minor.header.isEmpty() ? "Algorithm" : p.minor.header) : p.major.header, (p.major.smooth || p.minor.smooth) ? ", Y" : "", (p.major.smooth || p.minor.smooth) ? "geom=\"boxplot\"" : "geom=\"bar\", position=\"dodge\", weight=Y") +
530 509 (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) +
... ... @@ -532,8 +511,7 @@ bool Plot(const QStringList &amp;files, const br::File &amp;destination, bool show)
532 511 QString(", ylab=\"True Accept Rate%1\") + theme_minimal()").arg(p.minor.size > 1 ? " / " + p.minor.header : QString()) +
533 512 (p.major.size > 1 ? getScale("fill", p.major.header, p.major.size) : QString()) +
534 513 (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ X)").arg(p.minor.header) : QString(" + facet_grid(. ~ X, labeller=far_labeller)")) +
535   - QString(" + scale_y_continuous(labels=percent) + theme(legend.position=\"none\", axis.text.x=element_text(angle=-90, hjust=0))%1").arg((p.major.smooth || p.minor.smooth) ? "" : " + geom_text(data=BC, aes(label=Y, y=0.05))") +
536   - QString("\nggsave(\"%1\")\n\n").arg(p.subfile("BC"))));
  514 + QString(" + scale_y_continuous(labels=percent) + theme(legend.position=\"none\", axis.text.x=element_text(angle=-90, hjust=0))%1").arg((p.major.smooth || p.minor.smooth) ? "" : " + geom_text(data=BC, aes(label=Y, y=0.05))\n\n")));
537 515  
538 516 p.file.write(qPrintable(QString("qplot(X, Y, data=ERR%1, linetype=Error").arg((p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") +
539 517 ((p.flip ? p.major.size : p.minor.size) > 1 ? QString(", colour=factor(%1)").arg(p.flip ? p.major.header : p.minor.header) : QString()) +
... ... @@ -541,8 +519,7 @@ bool Plot(const QStringList &amp;files, const br::File &amp;destination, bool show)
541 519 ((p.flip ? p.major.size : p.minor.size) > 1 ? getScale("colour", p.flip ? p.major.header : p.minor.header, p.flip ? p.major.size : p.minor.size) : QString()) +
542 520 QString(" + scale_y_log10(labels=percent) + annotation_logticks(sides=\"l\")") +
543 521 ((p.flip ? p.minor.size : p.major.size) > 1 ? QString(" + facet_wrap(~ %1, scales=\"free_x\")").arg(p.flip ? p.minor.header : p.major.header) : QString()) +
544   - QString(" + theme(aspect.ratio=1)") +
545   - QString("\nggsave(\"%1\")\n\n").arg(p.subfile("ERR"))));
  522 + QString(" + theme(aspect.ratio=1)\n\n")));
546 523  
547 524 return p.finalize(show);
548 525 }
... ...
openbr/openbr.h
... ... @@ -258,10 +258,9 @@ BR_EXPORT const char *br_objects(const char *abstractions = &quot;.*&quot;, const char *im
258 258 * -# Cumulative Match Characteristic (CMC)
259 259 * -# Error Rate (ERR) curve
260 260 *
261   - * Several files will be created:
  261 + * Two files will be created:
262 262 * - <i>destination</i><tt>.R</tt> which is the auto-generated R script used to render the figures.
263   - * - <i>destination</i><tt>.pdf</tt> which has all of the figures in one file (convenient for attaching in an email).
264   - * - <i>destination</i><tt>_ROC.pdf</tt>, ..., <i>destination</i><tt>_ERR.pdf</tt> which has each figure in a separate file (convenient for including in a presentation).
  263 + * - <i>destination</i><tt>.pdf</tt> which has all of the figures in one file multi-page file.
265 264 *
266 265 * \param num_files Number of <tt>.csv</tt> files.
267 266 * \param files <tt>.csv</tt> files created using \ref br_eval.
... ...