Commit 782b5bcfe4eb21717a477fa3cd6c54e14ebe7e0a
1 parent
26cffad3
removed unnecessary eval/plot functionality
Showing
2 changed files
with
9 additions
and
33 deletions
openbr/core/plot.cpp
| @@ -173,7 +173,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | @@ -173,7 +173,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | ||
| 173 | // Sort comparisons by simmat_val (score) | 173 | // Sort comparisons by simmat_val (score) |
| 174 | std::sort(comparisons.begin(), comparisons.end()); | 174 | std::sort(comparisons.begin(), comparisons.end()); |
| 175 | 175 | ||
| 176 | - double genuineSum = 0, impostorSum = 0; | ||
| 177 | QList<OperatingPoint> operatingPoints; | 176 | QList<OperatingPoint> operatingPoints; |
| 178 | QList<float> genuines, impostors; | 177 | QList<float> genuines, impostors; |
| 179 | QVector<int> firstGenuineReturns(simmat.rows, 0); | 178 | QVector<int> firstGenuineReturns(simmat.rows, 0); |
| @@ -192,7 +191,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | @@ -192,7 +191,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | ||
| 192 | const Comparison &comparison = comparisons[index]; | 191 | const Comparison &comparison = comparisons[index]; |
| 193 | if (comparison.genuine) { | 192 | if (comparison.genuine) { |
| 194 | truePositives++; | 193 | truePositives++; |
| 195 | - genuineSum += comparison.score; | ||
| 196 | genuines.append(comparison.score); | 194 | genuines.append(comparison.score); |
| 197 | if (firstGenuineReturns[comparison.query] < 1) | 195 | if (firstGenuineReturns[comparison.query] < 1) |
| 198 | firstGenuineReturns[comparison.query] = abs(firstGenuineReturns[comparison.query]) + 1; | 196 | firstGenuineReturns[comparison.query] = abs(firstGenuineReturns[comparison.query]) + 1; |
| @@ -201,7 +199,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | @@ -201,7 +199,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | ||
| 201 | minGenuineScore = comparison.score; | 199 | minGenuineScore = comparison.score; |
| 202 | } else { | 200 | } else { |
| 203 | falsePositives++; | 201 | falsePositives++; |
| 204 | - impostorSum += comparison.score; | ||
| 205 | impostors.append(comparison.score); | 202 | impostors.append(comparison.score); |
| 206 | if (firstGenuineReturns[comparison.query] < 1) | 203 | if (firstGenuineReturns[comparison.query] < 1) |
| 207 | firstGenuineReturns[comparison.query]--; | 204 | firstGenuineReturns[comparison.query]--; |
| @@ -247,7 +244,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | @@ -247,7 +244,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | ||
| 247 | QString::number(1-operatingPoint.TAR))); | 244 | QString::number(1-operatingPoint.TAR))); |
| 248 | } | 245 | } |
| 249 | 246 | ||
| 250 | - | ||
| 251 | // Write FAR/TAR Bar Chart (BC) | 247 | // Write FAR/TAR Bar Chart (BC) |
| 252 | lines.append(qPrintable(QString("BC,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3)))); | 248 | lines.append(qPrintable(QString("BC,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3)))); |
| 253 | lines.append(qPrintable(QString("BC,0.01,%1").arg(QString::number(result = getTAR(operatingPoints, 0.01), 'f', 3)))); | 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 &simmat, const Mat &mask, const QString &csv) | @@ -267,14 +263,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | ||
| 267 | sampledImpostorScores.append(impostorScore); | 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 | // Write Cumulative Match Characteristic (CMC) curve | 266 | // Write Cumulative Match Characteristic (CMC) curve |
| 279 | const int Max_Retrieval = 100; | 267 | const int Max_Retrieval = 100; |
| 280 | const int Report_Retrieval = 5; | 268 | const int Report_Retrieval = 5; |
| @@ -477,11 +465,6 @@ struct RPlot | @@ -477,11 +465,6 @@ struct RPlot | ||
| 477 | if (success && show) QtUtils::showFile(basename+"."+suffix); | 465 | if (success && show) QtUtils::showFile(basename+"."+suffix); |
| 478 | return success; | 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 | bool Plot(const QStringList &files, const br::File &destination, bool show) | 470 | bool Plot(const QStringList &files, const br::File &destination, bool show) |
| @@ -498,8 +481,7 @@ bool Plot(const QStringList &files, const br::File &destination, bool show) | @@ -498,8 +481,7 @@ bool Plot(const QStringList &files, const br::File &destination, bool show) | ||
| 498 | QString(", xlab=\"False Accept Rate\", ylab=\"True Accept Rate\") + theme_minimal()") + | 481 | QString(", xlab=\"False Accept Rate\", ylab=\"True Accept Rate\") + theme_minimal()") + |
| 499 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | 482 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + |
| 500 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + | 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 | 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\"") + | 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 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + | 487 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + |
| @@ -507,24 +489,21 @@ bool Plot(const QStringList &files, const br::File &destination, bool show) | @@ -507,24 +489,21 @@ bool Plot(const QStringList &files, const br::File &destination, bool show) | ||
| 507 | QString(", xlab=\"False Accept Rate\", ylab=\"False Reject Rate\") + geom_abline(alpha=0.5, colour=\"grey\", linetype=\"dashed\") + theme_minimal()") + | 489 | QString(", xlab=\"False Accept Rate\", ylab=\"False Reject Rate\") + geom_abline(alpha=0.5, colour=\"grey\", linetype=\"dashed\") + theme_minimal()") + |
| 508 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | 490 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + |
| 509 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + | 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 | p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") + | 494 | p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") + |
| 514 | QString(", xlab=\"Score%1\"").arg((p.flip ? p.major.size : p.minor.size) > 1 ? " / " + (p.flip ? p.major.header : p.minor.header) : QString()) + | 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 | QString(", ylab=\"Frequency%1\"").arg((p.flip ? p.minor.size : p.major.size) > 1 ? " / " + (p.flip ? p.minor.header : p.major.header) : QString()) + | 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 | 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))") + | 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 | (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()) + | 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 | 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()) + | 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 | ((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()") + | 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 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | 504 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + |
| 525 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + | 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 | 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") + | 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 | (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) + | 509 | (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) + |
| @@ -532,8 +511,7 @@ bool Plot(const QStringList &files, const br::File &destination, bool show) | @@ -532,8 +511,7 @@ bool Plot(const QStringList &files, const br::File &destination, bool show) | ||
| 532 | QString(", ylab=\"True Accept Rate%1\") + theme_minimal()").arg(p.minor.size > 1 ? " / " + p.minor.header : QString()) + | 511 | QString(", ylab=\"True Accept Rate%1\") + theme_minimal()").arg(p.minor.size > 1 ? " / " + p.minor.header : QString()) + |
| 533 | (p.major.size > 1 ? getScale("fill", p.major.header, p.major.size) : QString()) + | 512 | (p.major.size > 1 ? getScale("fill", p.major.header, p.major.size) : QString()) + |
| 534 | (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ X)").arg(p.minor.header) : QString(" + facet_grid(. ~ X, labeller=far_labeller)")) + | 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 | 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\"") + | 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 | ((p.flip ? p.major.size : p.minor.size) > 1 ? QString(", colour=factor(%1)").arg(p.flip ? p.major.header : p.minor.header) : QString()) + | 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 &files, const br::File &destination, bool show) | @@ -541,8 +519,7 @@ bool Plot(const QStringList &files, const br::File &destination, bool show) | ||
| 541 | ((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()) + | 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 | QString(" + scale_y_log10(labels=percent) + annotation_logticks(sides=\"l\")") + | 520 | QString(" + scale_y_log10(labels=percent) + annotation_logticks(sides=\"l\")") + |
| 543 | ((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()) + | 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 | return p.finalize(show); | 524 | return p.finalize(show); |
| 548 | } | 525 | } |
openbr/openbr.h
| @@ -258,10 +258,9 @@ BR_EXPORT const char *br_objects(const char *abstractions = ".*", const char *im | @@ -258,10 +258,9 @@ BR_EXPORT const char *br_objects(const char *abstractions = ".*", const char *im | ||
| 258 | * -# Cumulative Match Characteristic (CMC) | 258 | * -# Cumulative Match Characteristic (CMC) |
| 259 | * -# Error Rate (ERR) curve | 259 | * -# Error Rate (ERR) curve |
| 260 | * | 260 | * |
| 261 | - * Several files will be created: | 261 | + * Two files will be created: |
| 262 | * - <i>destination</i><tt>.R</tt> which is the auto-generated R script used to render the figures. | 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 | * \param num_files Number of <tt>.csv</tt> files. | 265 | * \param num_files Number of <tt>.csv</tt> files. |
| 267 | * \param files <tt>.csv</tt> files created using \ref br_eval. | 266 | * \param files <tt>.csv</tt> files created using \ref br_eval. |