MCPcopy Create free account
hub / github.com/biometrics/openbr / Plot

Function Plot

openbr/core/plot.cpp:173–239  ·  view source on GitHub ↗

Does not work if dataset folder starts with a number

Source from the content-addressed store, hash-verified

171
172// Does not work if dataset folder starts with a number
173bool Plot(const QStringList &files, const File &destination, bool show)
174{
175 qDebug("Plotting %d file(s) to %s", files.size(), qPrintable(destination));
176
177 RPlot p(files, destination);
178 p.file.write("\nformatData()\n\n");
179 p.file.write(qPrintable(QString("algs <- %1\n").arg((p.major.size > 1 && p.minor.size > 1) && !(p.major.smooth || p.minor.smooth) ? QString("paste(TF$%1, TF$%2, sep=\"_\")").arg(p.major.header, p.minor.header)
180 : QString("TF$%1").arg(p.major.size > 1 ? p.major.header : (p.minor.header.isEmpty() ? p.major.header : p.minor.header)))));
181 p.file.write("algs <- algs[!duplicated(algs)]\n");
182
183 if (p.major.smooth || p.minor.smooth) {
184 QString groupvar = p.major.size > 1 ? p.major.header : (p.minor.header.isEmpty() ? p.major.header : p.minor.header);
185 foreach(const QString &data, QStringList() << "DET" << "IET" << "CMC" << "TF" << "FT" << "CT") {
186 p.file.write(qPrintable(QString("%1 <- summarySE(%1, measurevar=\"Y\", groupvars=c(\"%2\", \"X\"), conf.interval=confidence)"
187 "\n").arg(data, groupvar)));
188 }
189 p.file.write(qPrintable(QString("%1 <- summarySE(%1, measurevar=\"X\", groupvars=c(\"Error\", \"%2\", \"Y\"), conf.interval=confidence)"
190 "\n\n").arg("ERR", groupvar)));
191 }
192
193 // Use a br::file for simple storage of plot options
194 QMap<QString,File> optMap;
195 optMap.insert("rocOptions", File(QString("[xTitle=False Accept Rate,yTitle=True Accept Rate,xLog=true,yLog=false]")));
196 optMap.insert("detOptions", File(QString("[xTitle=False Accept Rate,yTitle=False Reject Rate,xLog=true,yLog=true]")));
197 optMap.insert("ietOptions", File(QString("[xTitle=False Positive Identification Rate (FPIR),yTitle=False Negative Identification Rate (FNIR),xLog=true,yLog=true]")));
198 optMap.insert("cmcOptions", File(QString("[xTitle=Rank,yTitle=Retrieval Rate,xLog=true,yLog=false,size=1,xLabels=(1,5,10,50,100),xBreaks=(1,5,10,50,100)]")));
199
200 foreach (const QString &key, optMap.keys()) {
201 const QStringList options = destination.get<QStringList>(key, QStringList());
202 foreach (const QString &option, options) {
203 QStringList words = QtUtils::parse(option, '=');
204 QtUtils::checkArgsSize(words[0], words, 1, 2);
205 optMap[key].set(words[0], words[1]);
206 }
207 }
208
209 // optional plot metadata and accuracy tables
210 if (destination.getBool("metadata", true)) {
211 p.file.write("\n# Write metadata table\n");
212 p.file.write(qPrintable(QString("plotMetadata(metadata=Metadata, title=\"%1 - %2\")\n").arg(PRODUCT_NAME, PRODUCT_VERSION)));
213
214 if (!destination.getBool("csv")) p.file.write("plot.new()\n");
215 QString table = "plotTable(tableData=%1, name=%2, labels=%3)\n";
216 p.file.write(qPrintable(table.arg("TF", "\"Table of True Accept Rates at various False Accept Rates\"",
217 "c(\"FAR = 1e-06\", \"FAR = 1e-05\", \"FAR = 1e-04\", \"FAR = 1e-03\", \"FAR = 1e-02\", \"FAR = 1e-01\")")));
218 p.file.write(qPrintable(table.arg("FT", "\"Table of False Accept Rates at various True Accept Rates\"",
219 "c(\"TAR = 0.40\", \"TAR = 0.50\", \"TAR = 0.65\", \"TAR = 0.75\", \"TAR = 0.85\", \"TAR = 0.95\")")));
220 p.file.write(qPrintable(table.arg("CT", "\"Table of retrieval rate at various ranks\"",
221 "c(\"Rank 1\", \"Rank 5\", \"Rank 10\", \"Rank 20\", \"Rank 50\", \"Rank 100\")")));
222 p.file.write(qPrintable(table.arg("TS", "\"Template Size by Algorithm\"",
223 "c(\"Template Size (bytes):\")")));
224 p.file.write("\n");
225 }
226
227 // Write plots
228 QString plot = "plot <- plotLine(lineData=%1, options=list(%2), flipY=%3)\nplot\n";
229 p.file.write(qPrintable(QString(plot).arg("DET", toRList(optMap["rocOptions"]), "TRUE")));
230 p.file.write(qPrintable(QString(plot).arg("DET", toRList(optMap["detOptions"]), "FALSE")));

Callers 1

br_plotFunction · 0.85

Calls 8

FileFunction · 0.85
toRListFunction · 0.85
isEmptyMethod · 0.80
getBoolMethod · 0.80
sizeMethod · 0.45
writeMethod · 0.45
insertMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected