Commit 855a80fb7bf2f34810de18ba0a88dee114b0c1f7

Authored by Ben Klein
1 parent 7e79e495

Change false accepts to a percentage, moved legends to bottom

openbr/core/eval.cpp
@@ -603,10 +603,10 @@ struct ResolvedDetection @@ -603,10 +603,10 @@ struct ResolvedDetection
603 603
604 struct DetectionOperatingPoint 604 struct DetectionOperatingPoint
605 { 605 {
606 - float Recall, FalsePositives, Precision;  
607 - DetectionOperatingPoint() : Recall(-1), FalsePositives(-1), Precision(-1) {} 606 + float Recall, FalsePositiveRate, Precision;
  607 + DetectionOperatingPoint() : Recall(-1), FalsePositiveRate(-1), Precision(-1) {}
608 DetectionOperatingPoint(float TP, float FP, float totalPositives) 608 DetectionOperatingPoint(float TP, float FP, float totalPositives)
609 - : Recall(TP/totalPositives), FalsePositives(FP), Precision(TP/(TP+FP)) {} 609 + : Recall(TP/totalPositives), FalsePositiveRate(FP/totalPositives), Precision(TP/(TP+FP)) {}
610 }; 610 };
611 611
612 static QStringList computeDetectionResults(const QList<ResolvedDetection> &detections, int totalTrueDetections, bool discrete) 612 static QStringList computeDetectionResults(const QList<ResolvedDetection> &detections, int totalTrueDetections, bool discrete)
@@ -637,12 +637,12 @@ static QStringList computeDetectionResults(const QList&lt;ResolvedDetection&gt; &amp;detec @@ -637,12 +637,12 @@ static QStringList computeDetectionResults(const QList&lt;ResolvedDetection&gt; &amp;detec
637 QStringList lines; lines.reserve(keep); 637 QStringList lines; lines.reserve(keep);
638 if (keep == 1) { 638 if (keep == 1) {
639 const DetectionOperatingPoint &point = points[0]; 639 const DetectionOperatingPoint &point = points[0];
640 - lines.append(QString("%1ROC, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.FalsePositives), QString::number(point.Recall))); 640 + lines.append(QString("%1ROC, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.FalsePositiveRate), QString::number(point.Recall)));
641 lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Recall), QString::number(point.Precision))); 641 lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Recall), QString::number(point.Precision)));
642 } else { 642 } else {
643 for (int i=0; i<keep; i++) { 643 for (int i=0; i<keep; i++) {
644 const DetectionOperatingPoint &point = points[double(i) / double(keep-1) * double(points.size()-1)]; 644 const DetectionOperatingPoint &point = points[double(i) / double(keep-1) * double(points.size()-1)];
645 - lines.append(QString("%1ROC, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.FalsePositives), QString::number(point.Recall))); 645 + lines.append(QString("%1ROC, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.FalsePositiveRate), QString::number(point.Recall)));
646 lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Recall), QString::number(point.Precision))); 646 lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Recall), QString::number(point.Precision)));
647 } 647 }
648 } 648 }
openbr/core/plot.cpp
@@ -350,10 +350,10 @@ bool PlotDetection(const QStringList &amp;files, const File &amp;destination, bool show) @@ -350,10 +350,10 @@ bool PlotDetection(const QStringList &amp;files, const File &amp;destination, bool show)
350 p.file.write(qPrintable(QString("qplot(X, Y, data=%1ROC%2").arg(type, (p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : QString(", geom=\"%1\"").arg(plotType)) + 350 p.file.write(qPrintable(QString("qplot(X, Y, data=%1ROC%2").arg(type, (p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : QString(", geom=\"%1\"").arg(plotType)) +
351 (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + 351 (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) +
352 (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + 352 (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) +
353 - QString(", xlab=\"False Accepts\", ylab=\"True Accept Rate\") + theme_minimal()") + 353 + QString(", xlab=\"Percentage of False Accepts Per Image\", ylab=\"True Accept Rate\") + theme_minimal()") +
354 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + 354 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) +
355 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + 355 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
356 - QString(" + scale_x_log10() + scale_y_continuous(labels=percent) + annotation_logticks(sides=\"b\") + ggtitle(\"%1\")\n\n").arg(type))); 356 + QString(" + scale_x_log10(labels=percent) + scale_y_continuous(labels=percent, limits=c(0,1)) + annotation_logticks(sides=\"b\") + ggtitle(\"%1\") + theme(legend.position=\"bottom\"")\n\n").arg(type)));
357 357
358 foreach (const QString &type, QStringList() << "Discrete" << "Continuous") 358 foreach (const QString &type, QStringList() << "Discrete" << "Continuous")
359 p.file.write(qPrintable(QString("qplot(X, Y, data=%1PR%2").arg(type, (p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : QString(", geom=\"%1\"").arg(plotType)) + 359 p.file.write(qPrintable(QString("qplot(X, Y, data=%1PR%2").arg(type, (p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : QString(", geom=\"%1\"").arg(plotType)) +
@@ -362,12 +362,12 @@ bool PlotDetection(const QStringList &amp;files, const File &amp;destination, bool show) @@ -362,12 +362,12 @@ bool PlotDetection(const QStringList &amp;files, const File &amp;destination, bool show)
362 QString(", xlab=\"Recall\", ylab=\"Precision\") + theme_minimal()") + 362 QString(", xlab=\"Recall\", ylab=\"Precision\") + theme_minimal()") +
363 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + 363 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) +
364 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + 364 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
365 - QString(" + scale_x_continuous(labels=percent) + scale_y_continuous(labels=percent) + ggtitle(\"%1\")\n\n").arg(type))); 365 + QString(" + scale_x_continuous(labels=percent, limits=c(0,1)) + scale_y_continuous(labels=percent, limits=c(0,1)) + ggtitle(\"%1\") + theme(legend.position=\"bottom\")\n\n").arg(type)));
366 366
367 p.file.write(qPrintable(QString("qplot(X, data=Overlap, geom=\"histogram\", position=\"identity\", xlab=\"Overlap\", ylab=\"Frequency\")") + 367 p.file.write(qPrintable(QString("qplot(X, data=Overlap, geom=\"histogram\", position=\"identity\", xlab=\"Overlap\", ylab=\"Frequency\")") +
368 QString(" + 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))") + 368 QString(" + 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))") +
369 (p.major.size > 1 ? (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ %1, scales=\"free\")").arg(p.minor.header, p.major.header) : QString(" + facet_wrap(~ %1, scales = \"free\")").arg(p.major.header)) : QString()) + 369 (p.major.size > 1 ? (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ %1, scales=\"free\")").arg(p.minor.header, p.major.header) : QString(" + facet_wrap(~ %1, scales = \"free\")").arg(p.major.header)) : QString()) +
370 - QString(" + theme(aspect.ratio=1)\n\n"))); 370 + QString(" + theme(aspect.ratio=1, legend.position=\"bottom\")\n\n")));
371 371
372 p.file.write(qPrintable(QString("ggplot(AverageOverlap, aes(x=%1, y=%2, label=round(X,3)), main=\"Average Overlap\") + geom_text() + theme_minimal()").arg(p.minor.size > 1 ? p.minor.header : "'X'", p.major.size > 1 ? p.major.header : "'Y'") + 372 p.file.write(qPrintable(QString("ggplot(AverageOverlap, aes(x=%1, y=%2, label=round(X,3)), main=\"Average Overlap\") + geom_text() + theme_minimal()").arg(p.minor.size > 1 ? p.minor.header : "'X'", p.major.size > 1 ? p.major.header : "'Y'") +
373 QString("%1%2\n\n").arg(p.minor.size > 1 ? "" : " + xlab(NULL)", p.major.size > 1 ? "" : " + ylab(NULL)"))); 373 QString("%1%2\n\n").arg(p.minor.size > 1 ? "" : " + xlab(NULL)", p.major.size > 1 ? "" : " + ylab(NULL)")));