Commit 82120538e8dcb0b7aced8d86e395f965f8c9b7cf
1 parent
4799a4ce
Added table of TAR values at FAR values from 1e-01 to 1e-06, cleaned up axis labels
Showing
2 changed files
with
30 additions
and
12 deletions
openbr/core/eval.cpp
| ... | ... | @@ -232,6 +232,13 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) |
| 232 | 232 | lines.append(QString("FRR,%1,%2").arg(QString::number(operatingPoint.score), |
| 233 | 233 | QString::number(1-operatingPoint.TAR))); |
| 234 | 234 | } |
| 235 | + // Write FAR/TAR Table (FT) | |
| 236 | + lines.append(qPrintable(QString("FT,0.000001,%1").arg(QString::number(getTAR(operatingPoints, 0.000001), 'f', 3)))); | |
| 237 | + lines.append(qPrintable(QString("FT,0.00001,%1").arg(QString::number(getTAR(operatingPoints, 0.00001), 'f', 3)))); | |
| 238 | + lines.append(qPrintable(QString("FT,0.0001,%1").arg(QString::number(getTAR(operatingPoints, 0.0001), 'f', 3)))); | |
| 239 | + lines.append(qPrintable(QString("FT,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3)))); | |
| 240 | + lines.append(qPrintable(QString("FT,0.01,%1").arg(QString::number(getTAR(operatingPoints, 0.01), 'f', 3)))); | |
| 241 | + lines.append(qPrintable(QString("FT,0.1,%1").arg(QString::number(getTAR(operatingPoints, 0.1), 'f', 3)))); | |
| 235 | 242 | |
| 236 | 243 | // Write FAR/TAR Bar Chart (BC) |
| 237 | 244 | lines.append(qPrintable(QString("BC,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3)))); | ... | ... |
openbr/core/plot.cpp
| ... | ... | @@ -134,6 +134,7 @@ struct RPlot |
| 134 | 134 | "FAR <- data[grep(\"FAR\",data$Plot),-c(1)]\n" |
| 135 | 135 | "FRR <- data[grep(\"FRR\",data$Plot),-c(1)]\n" |
| 136 | 136 | "SD <- data[grep(\"SD\",data$Plot),-c(1)]\n" |
| 137 | + "FT <- data[grep(\"FT\",data$Plot),-c(1)]\n" | |
| 137 | 138 | "BC <- data[grep(\"BC\",data$Plot),-c(1)]\n" |
| 138 | 139 | "CMC <- data[grep(\"CMC\",data$Plot),-c(1)]\n" |
| 139 | 140 | "FAR$Error <- \"FAR\"\n" |
| ... | ... | @@ -146,13 +147,22 @@ struct RPlot |
| 146 | 147 | "DET$Y <- as.numeric(as.character(DET$Y))\n" |
| 147 | 148 | "ERR$Y <- as.numeric(as.character(ERR$Y))\n" |
| 148 | 149 | "SD$Y <- as.factor(unique(as.character(SD$Y)))\n" |
| 150 | + "FT$Y <- as.numeric(as.character(FT$Y))\n" | |
| 149 | 151 | "BC$Y <- as.numeric(as.character(BC$Y))\n" |
| 150 | 152 | "CMC$Y <- as.numeric(as.character(CMC$Y))\n" |
| 151 | 153 | "\n" |
| 152 | 154 | "# Code to format FAR values\n" |
| 153 | 155 | "far_names <- list('0.001'=\"FAR = 0.1%\", '0.01'=\"FAR = 1%\")\n" |
| 154 | - "far_labeller <- function(variable,value) { return(far_names[as.character(value)]) }\n"); | |
| 155 | - | |
| 156 | + "far_labeller <- function(variable,value) { return(far_names[as.character(value)]) }\n" | |
| 157 | + "\n" | |
| 158 | + "# Code to format TAR@FAR table\n" | |
| 159 | + "algs <- unique(FT$.)\n" | |
| 160 | + "algs <- algs[!duplicated(algs)]\n" | |
| 161 | + "mat <- matrix(FT$Y,nrow=6,ncol=length(algs),byrow=FALSE)\n" | |
| 162 | + "colnames(mat) <- algs \n" | |
| 163 | + "rownames(mat) <- c(\"FAR = 1e-06\", \"FAR = 1e-05\", \"FAR = 1e-04\", \"FAR = 1e-03\", \"FAR = 1e-02\", \"FAR = 1e-01\")\n" | |
| 164 | + "table <- as.table(mat)\n"); | |
| 165 | + | |
| 156 | 166 | // Open output device |
| 157 | 167 | file.write(qPrintable(QString("\n" |
| 158 | 168 | "# Open output device\n" |
| ... | ... | @@ -172,7 +182,10 @@ struct RPlot |
| 172 | 182 | "print(textplot(MT[,!(names(MT) %in% c(\"Gallery\", \"Probe\"))], show.rownames=FALSE))\n" |
| 173 | 183 | "print(title(\"Matches\"))\n" |
| 174 | 184 | "plot.new()\n" |
| 175 | - "print(title(\"Gallery * Probe = Genuine + Impostor + Ignored\"))\n"; | |
| 185 | + "print(title(\"Gallery * Probe = Genuine + Impostor + Ignored\"))\n" | |
| 186 | + "plot.new()\n" | |
| 187 | + "print(title(\"Table of True Accept Rates at various False Accept Rates\"))\n" | |
| 188 | + "print(textplot(table,valign=\"top\",cex=1))\n"; | |
| 176 | 189 | file.write(qPrintable(textplot.arg(PRODUCT_NAME, PRODUCT_VERSION))); |
| 177 | 190 | } |
| 178 | 191 | |
| ... | ... | @@ -244,7 +257,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 244 | 257 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + |
| 245 | 258 | (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + |
| 246 | 259 | QString(", xlab=\"False Accept Rate\", ylab=\"True Accept Rate\") + theme_minimal()") + |
| 247 | - (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | |
| 260 | + (p.major.size > 1 ? getScale("colour", "Algorithm", p.major.size) : QString()) + | |
| 248 | 261 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + |
| 249 | 262 | QString(" + scale_x_log10(labels=trans_format(\"log10\", math_format()))") + |
| 250 | 263 | (rocOpts.contains("yLimits") ? QString(" + scale_y_continuous(labels=percent) + coord_cartesian(ylim=%1)").arg("c"+QtUtils::toString(rocOpts.get<QPointF>("yLimits",QPointF()))) : QString(" + scale_y_continuous(labels=percent)")) + |
| ... | ... | @@ -256,13 +269,12 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 256 | 269 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + |
| 257 | 270 | (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + |
| 258 | 271 | QString(", xlab=\"False Accept Rate\", ylab=\"False Reject Rate\") + geom_abline(alpha=0.5, colour=\"grey\", linetype=\"dashed\") + theme_minimal()") + |
| 259 | - (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | |
| 272 | + (p.major.size > 1 ? getScale("colour", "Algorithm", p.major.size) : QString()) + | |
| 260 | 273 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + |
| 261 | 274 | QString(" + scale_x_log10(labels=trans_format(\"log10\", math_format())) + scale_y_log10(labels=trans_format(\"log10\", math_format())) + annotation_logticks()\n\n"))); |
| 262 | 275 | |
| 263 | 276 | p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") + |
| 264 | - QString(", xlab=\"Score%1\"").arg((p.flip ? p.major.size : p.minor.size) > 1 ? " / " + (p.flip ? p.major.header : p.minor.header) : QString()) + | |
| 265 | - QString(", ylab=\"Frequency%1\"").arg((p.flip ? p.minor.size : p.major.size) > 1 ? " / " + (p.flip ? p.minor.header : p.major.header) : QString()) + | |
| 277 | + QString(", xlab=\"Score\", ylab=\"Frequency\"") + | |
| 266 | 278 | 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))") + |
| 267 | 279 | (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()) + |
| 268 | 280 | QString(" + theme(aspect.ratio=1)\n\n"))); |
| ... | ... | @@ -271,7 +283,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 271 | 283 | QString(((p.major.smooth || p.minor.smooth) ? (minimalist ? " + stat_summary(geom=\"line\", fun.y=mean, size=%1)" : " + stat_summary(geom=\"line\", fun.y=min, aes(linetype=\"Min/Max\"), size=%1) + stat_summary(geom=\"line\", " |
| 272 | 284 | "fun.y=max, aes(linetype=\"Min/Max\"), size=%1) + stat_summary(geom=\"line\", fun.y=mean, aes(linetype=\"Mean\"), size=%1) + scale_linetype_manual(\"Legend\", values=c(\"Mean\"=1, \"Min/Max\"=2))") : " + geom_line(size=%1)")).arg(QString::number(cmcOpts.get<float>("thickness",1))) + |
| 273 | 285 | (minimalist ? "" : " + scale_x_log10(labels=c(1,5,10,50,100), breaks=c(1,5,10,50,100)) + annotation_logticks(sides=\"b\")") + |
| 274 | - (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | |
| 286 | + (p.major.size > 1 ? getScale("colour", "Algorithm", p.major.size) : QString()) + | |
| 275 | 287 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + |
| 276 | 288 | (cmcOpts.contains("yLimits") ? QString(" + scale_y_continuous(labels=percent) + coord_cartesian(ylim=%1)").arg("c"+QtUtils::toString(cmcOpts.get<QPointF>("yLimits",QPointF()))) : QString(" + scale_y_continuous(labels=percent)")) + |
| 277 | 289 | QString(" + theme_minimal() + theme(legend.title = element_text(size = %1), plot.title = element_text(size = %1), axis.text = element_text(size = %1), axis.title.x = element_text(size = %1), axis.title.y = element_text(size = %1)," |
| ... | ... | @@ -279,16 +291,15 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 279 | 291 | |
| 280 | 292 | 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") + |
| 281 | 293 | (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) + |
| 282 | - QString(", xlab=\"%1False Accept Rate\"").arg(p.major.size > 1 ? p.major.header + " / " : QString()) + | |
| 283 | - QString(", ylab=\"True Accept Rate%1\") + theme_minimal()").arg(p.minor.size > 1 ? " / " + p.minor.header : QString()) + | |
| 284 | - (p.major.size > 1 ? getScale("fill", p.major.header, p.major.size) : QString()) + | |
| 294 | + QString(", xlab=\"False Accept Rate\", ylab=\"True Accept Rate\") + theme_minimal()") + | |
| 295 | + (p.major.size > 1 ? getScale("fill", "Algorithm", p.major.size) : QString()) + | |
| 285 | 296 | (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ X)").arg(p.minor.header) : QString(" + facet_grid(. ~ X, labeller=far_labeller)")) + |
| 286 | 297 | 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"))); |
| 287 | 298 | |
| 288 | 299 | 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\"") + |
| 289 | 300 | ((p.flip ? p.major.size : p.minor.size) > 1 ? QString(", colour=factor(%1)").arg(p.flip ? p.major.header : p.minor.header) : QString()) + |
| 290 | 301 | QString(", xlab=\"Score%1\", ylab=\"Error Rate\") + theme_minimal()").arg((p.flip ? p.minor.size : p.major.size) > 1 ? " / " + (p.flip ? p.minor.header : p.major.header) : QString()) + |
| 291 | - ((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()) + | |
| 302 | + ((p.flip ? p.major.size : p.minor.size) > 1 ? getScale("colour", p.flip ? "Algorithm" : "Algorithm", p.flip ? p.major.size : p.minor.size) : QString()) + | |
| 292 | 303 | QString(" + scale_y_log10(labels=percent) + annotation_logticks(sides=\"l\")") + |
| 293 | 304 | ((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()) + |
| 294 | 305 | QString(" + theme(aspect.ratio=1)\n\n"))); | ... | ... |