Files
benchmark/src/benchmark.r

41 lines
2.4 KiB
R

library(glue)
args = commandArgs(trailingOnly=TRUE)
if (length(args)!=1) {
stop("Only one argument must be supplied (score).n", call.=FALSE)
}
csv_file <- glue("results/exreport_{args[1]}.csv")
destination <- "exreport/"
results <- read.csv(csv_file)
library(exreport)
experiment <- expCreate(results, method="classifier", problem="dataset", name="Ranking")
testScore <- testMultipleControl(experiment, args[1], "max")
summary(testScore)
table1 <- tabularTestSummary(testScore, columns = c("pvalue", "rank", "wtl"))
table1
plot1 <- plotExpSummary(experiment, args[1], columns = 3)
plot2 <- plotCumulativeRank(testScore)
plot3 <- plotRankDistribution(testScore)
report <- exreport("Ranking Report")
# Add the experiment object for reference:
report <- exreportAdd(report, experiment)
# Now add the test:
report <- exreportAdd(report, testScore)
# Finally you can add the different tables and plots.
report <- exreportAdd(report, list(plot1, plot2, table1, plot3))
# At this point we would like to include an additional item in our report. We need a detailed table of our experiment,
# as we are preparing a scientific paper and we would like to have an overview of it to be included in an annex,
# despite the good summaries that we are providing with the plots and tests. Fortnunately, we have another built in
# function for this.
# We have decided to generate the table at this point of the tutorial to discusse some special formating parameters of this function. Concretely, some of the tabular outputs generated by exreport have some properties that are only useful when rendering the objets in a graphic report, and have no effect in the object representation in the R console. In this case, we will tell the function to boldface the method that maximices the result for each column, and to split the table into to pieces when rendering.
# We create the table:
table2 <- tabularExpSummary(experiment, args[1], digits=4, format="f", boldfaceColumns="max", rowsAsMethod=FALSE)
# And add it to the report:
report <- exreportAdd(report, table2)
# Now that we have finished adding elements to the report it is time to render it. We want to generate an HTML report, so we call the appropiate function, by default it renders and opens the report in your browser using a temporary file, but you can optionally specify a folder in which the report will be saved for future use.
# Render the report:
exreportRender(report, destination=destination, target = "html", visualize = T)