Commit 8e3e48651f516f1a0cfda276bc2727a6d5d6d326
1 parent
513fdccb
first draft of -plotDetection
Showing
2 changed files
with
34 additions
and
2 deletions
openbr/core/eval.cpp
| ... | ... | @@ -377,7 +377,7 @@ static QStringList computeDetectionResults(const QList<ResolvedDetection> &detec |
| 377 | 377 | for (int i=0; i<keep; i++) { |
| 378 | 378 | const DetectionOperatingPoint &point = points[double(i) / double(keep-1) * double(points.size()-1)]; |
| 379 | 379 | lines.append(QString("%1ROC, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.FalsePositives), QString::number(point.Recall))); |
| 380 | - lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Precision), QString::number(point.Recall))); | |
| 380 | + lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Recall), QString::number(point.Precision))); | |
| 381 | 381 | } |
| 382 | 382 | return lines; |
| 383 | 383 | } | ... | ... |
openbr/core/plot.cpp
| ... | ... | @@ -238,7 +238,6 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 238 | 238 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + |
| 239 | 239 | QString(" + scale_x_log10(labels=percent) + scale_y_log10(labels=percent) + annotation_logticks()\n\n"))); |
| 240 | 240 | |
| 241 | - | |
| 242 | 241 | p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") + |
| 243 | 242 | QString(", xlab=\"Score%1\"").arg((p.flip ? p.major.size : p.minor.size) > 1 ? " / " + (p.flip ? p.major.header : p.minor.header) : QString()) + |
| 244 | 243 | QString(", ylab=\"Frequency%1\"").arg((p.flip ? p.minor.size : p.major.size) > 1 ? " / " + (p.flip ? p.minor.header : p.major.header) : QString()) + |
| ... | ... | @@ -278,6 +277,39 @@ bool PlotDetection(const QStringList &files, const File &destination, bool show) |
| 278 | 277 | |
| 279 | 278 | RPlot p(files, destination, false); |
| 280 | 279 | |
| 280 | + p.file.write("# Split data into individual plots\n" | |
| 281 | + "plot_index = which(names(data)==\"Plot\")\n" | |
| 282 | + "DiscreteROC <- data[grep(\"DiscreteROC\",data$Plot),-c(1)]\n" | |
| 283 | + "ContinuousROC <- data[grep(\"ContinuousROC\",data$Plot),-c(1)]\n" | |
| 284 | + "DiscretePR <- data[grep(\"DiscretePR\",data$Plot),-c(1)]\n" | |
| 285 | + "ContinuousPR <- data[grep(\"ContinuousPR\",data$Plot),-c(1)]\n" | |
| 286 | + "Overlap <- data[grep(\"Overlap\",data$Plot),-c(1)]\n" | |
| 287 | + "rm(data)\n" | |
| 288 | + "\n"); | |
| 289 | + | |
| 290 | + foreach (const QString &type, QStringList() << "Discrete" << "Continuous") | |
| 291 | + 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" : ", geom=\"line\"") + | |
| 292 | + (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + | |
| 293 | + (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + | |
| 294 | + QString(", xlab=\"False Accepts\", ylab=\"True Accept Rate\") + theme_minimal()") + | |
| 295 | + (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | |
| 296 | + (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + | |
| 297 | + QString(" + scale_x_log10() + scale_y_continuous(labels=percent) + annotation_logticks(sides=\"b\") + ggtitle(\"%1\")\n\n").arg(type))); | |
| 298 | + | |
| 299 | + foreach (const QString &type, QStringList() << "Discrete" << "Continuous") | |
| 300 | + 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" : ", geom=\"line\"") + | |
| 301 | + (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + | |
| 302 | + (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + | |
| 303 | + QString(", xlab=\"Recall\", ylab=\"Precision\") + theme_minimal()") + | |
| 304 | + (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | |
| 305 | + (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + | |
| 306 | + QString(" + scale_x_continuous(labels=percent) + scale_y_continuous(labels=percent) + ggtitle(\"%1\")\n\n").arg(type))); | |
| 307 | + | |
| 308 | + p.file.write(qPrintable(QString("qplot(X, data=Overlap, geom=\"histogram\", position=\"identity\", xlab=\"Overlap\", ylab=\"Frequency\")") + | |
| 309 | + 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))") + | |
| 310 | + (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()) + | |
| 311 | + QString(" + theme(aspect.ratio=1)\n\n"))); | |
| 312 | + | |
| 281 | 313 | return p.finalize(show); |
| 282 | 314 | } |
| 283 | 315 | ... | ... |