Commit 08742a218a829a8ccbb8c9fd2f7b4b9ea6933c16
1 parent
6ebad57b
Make displaying confidence intervals optional.
Showing
1 changed file
with
14 additions
and
5 deletions
openbr/core/plot.cpp
| ... | ... | @@ -65,6 +65,8 @@ struct RPlot |
| 65 | 65 | QFile file; |
| 66 | 66 | QStringList pivotHeaders; |
| 67 | 67 | QVector< QSet<QString> > pivotItems; |
| 68 | + float confidence; | |
| 69 | + | |
| 68 | 70 | bool flip; |
| 69 | 71 | |
| 70 | 72 | struct Pivot |
| ... | ... | @@ -132,6 +134,12 @@ struct RPlot |
| 132 | 134 | } |
| 133 | 135 | } |
| 134 | 136 | const QString &smooth = destination.get<QString>("smooth", ""); |
| 137 | + if (destination.contains(QString("confidence"))) { | |
| 138 | + const QString &CI = destination.get<QString>("confidence"); | |
| 139 | + confidence = !CI.isEmpty() ? CI.toFloat()/100.0 : 0.95; | |
| 140 | + } else { | |
| 141 | + confidence = 0.95; | |
| 142 | + } | |
| 135 | 143 | major.smooth = !smooth.isEmpty() && (major.header == smooth) && (major.size > 1); |
| 136 | 144 | minor.smooth = !smooth.isEmpty() && (minor.header == smooth) && (minor.size > 1); |
| 137 | 145 | if (major.smooth) major.size = 1; |
| ... | ... | @@ -175,7 +183,7 @@ struct RPlot |
| 175 | 183 | "TS$Y <- as.character(TS$Y)\n" |
| 176 | 184 | "CMC$Y <- as.numeric(as.character(CMC$Y))\n" |
| 177 | 185 | "\n" |
| 178 | - "if (%1) {\n\tsummarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE, conf.interval=.95, .drop=TRUE) {\n\t\t" | |
| 186 | + "if (%1) {\n\tsummarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE, conf.interval=%5, .drop=TRUE) {\n\t\t" | |
| 179 | 187 | "require(plyr)\n\n\t\tlength2 <- function (x, na.rm=FALSE) {\n\t\t\tif (na.rm) sum(!is.na(x))\n\t\t\telse length(x)" |
| 180 | 188 | "\n\t\t}\n\n\t\tdatac <- ddply(data, groupvars, .drop=.drop, .fun = function(xx, col) {\n\t\t\t" |
| 181 | 189 | "c(N=length2(xx[[col]], na.rm=na.rm), mean=mean(xx[[col]], na.rm=na.rm), sd=sd(xx[[col]], na.rm=na.rm))\n\t\t\t}," |
| ... | ... | @@ -209,8 +217,9 @@ struct RPlot |
| 209 | 217 | "colnames(mat) <- algs\n\t" |
| 210 | 218 | "rownames(mat) <- c(\"Template Size (bytes):\")\n\t" |
| 211 | 219 | "TStable <- as.table(mat)\n}\n").arg(((major.smooth || minor.smooth) ? "TRUE" : "FALSE"), major.size > 1 ? major.header : (minor.header.isEmpty() ? major.header : minor.header), |
| 212 | - (major.smooth || minor.smooth) ? "paste(as.character(round(FT$Y, 3)), round(FT$ci, 3), sep=\"\\u00b1\")" : "FT$Y", | |
| 213 | - (major.smooth || minor.smooth) ? "paste(as.character(round(CT$Y, 3)), round(CT$ci, 3), sep=\"\\u00b1\")" : "CT$Y"))); | |
| 220 | + (major.smooth || minor.smooth) && confidence != 0 ? "paste(as.character(round(FT$Y, 3)), round(FT$ci, 3), sep=\"\\u00b1\")" : "FT$Y", | |
| 221 | + (major.smooth || minor.smooth) && confidence != 0 ? "paste(as.character(round(CT$Y, 3)), round(CT$ci, 3), sep=\"\\u00b1\")" : "CT$Y", | |
| 222 | + QString::number(confidence)))); | |
| 214 | 223 | |
| 215 | 224 | // Open output device |
| 216 | 225 | file.write(qPrintable(QString("\n" |
| ... | ... | @@ -297,7 +306,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 297 | 306 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + |
| 298 | 307 | (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + |
| 299 | 308 | QString(", xlab=\"False Accept Rate\", ylab=\"True Accept Rate\") + theme_minimal()") + |
| 300 | - ((p.major.smooth || p.minor.smooth) ? " + geom_errorbar(data=DET[seq(1, NROW(DET), by = 29),], aes(x=X, ymin=(1-Y)-ci, ymax=(1-Y)+ci), width=0.1, alpha=I(1/2))" : QString()) + | |
| 309 | + ((p.major.smooth || p.minor.smooth) && p.confidence != 0 ? " + geom_errorbar(data=DET[seq(1, NROW(DET), by = 29),], aes(x=X, ymin=(1-Y)-ci, ymax=(1-Y)+ci), width=0.1, alpha=I(1/2))" : QString()) + | |
| 301 | 310 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + |
| 302 | 311 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + |
| 303 | 312 | QString(" + scale_x_log10(labels=trans_format(\"log10\", math_format()))") + |
| ... | ... | @@ -310,7 +319,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 310 | 319 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + |
| 311 | 320 | (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + |
| 312 | 321 | QString(", xlab=\"False Accept Rate\", ylab=\"False Reject Rate\") + geom_abline(alpha=0.5, colour=\"grey\", linetype=\"dashed\") + theme_minimal()") + |
| 313 | - ((p.major.smooth || p.minor.smooth) ? " + geom_errorbar(data=DET[seq(1, NROW(DET), by = 29),], aes(x=X, ymin=Y-ci, ymax=Y+ci), width=0.1, alpha=I(1/2))" : QString()) + | |
| 322 | + ((p.major.smooth || p.minor.smooth) && p.confidence != 0 ? " + geom_errorbar(data=DET[seq(1, NROW(DET), by = 29),], aes(x=X, ymin=Y-ci, ymax=Y+ci), width=0.1, alpha=I(1/2))" : QString()) + | |
| 314 | 323 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + |
| 315 | 324 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + |
| 316 | 325 | QString(" + theme(legend.position=%1)").arg(rocOpts.contains("legendPosition") ? "c"+QtUtils::toString(rocOpts.get<QPointF>("legendPosition")) : "'bottom'") + | ... | ... |