Skip to content

Commit

Permalink
fix PMCMRplus
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelS1 committed Oct 4, 2021
1 parent 74a4cfe commit 9d6c566
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ man-roxygen
^\.lintr
^.editorconfig$
^.ignore$
^.vscode
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ $RECYCLE.BIN/
!.vscode/extensions.json
*.code-workspace
.vscode
check/*
CRAN-RELEASE
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mlr3benchmark
Title: Analysis and Visualisation of Benchmark Experiments
Version: 0.1.2.9000
Version: 0.1.3
Authors@R:
c(person(given = "Sonabend",
family = "Raphael",
Expand Down Expand Up @@ -36,10 +36,10 @@ Imports:
ggplot2,
mlr3misc,
R6
Suggests:
Suggests:
mlr3,
mlr3learners,
PMCMR,
PMCMRplus,
rpart,
testthat,
xgboost
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mlr3benchmark 0.1.2.9000
# mlr3benchmark 0.1.3

* Fix README
* Fix for PMCMRplus

# mlr3benchmark 0.1.2

Expand Down
8 changes: 4 additions & 4 deletions R/BenchmarkAggr.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ BenchmarkAggr = R6Class("BenchmarkAggr",
},

#' @description Posthoc Friedman Nemenyi tests. Computed with
#' [PMCMR::posthoc.friedman.nemenyi.test]. If global `$friedman_test` is non-significant then
#' [PMCMRplus::frdAllPairsNemenyiTest]. If global `$friedman_test` is non-significant then
#' this is returned and no post-hocs computed. Also returns critical difference
#' @param meas `(character(1))` \cr
#' Measure to rank the data against, should be in `$measures`. Can be `NULL` if only one measure
Expand All @@ -216,8 +216,8 @@ BenchmarkAggr = R6Class("BenchmarkAggr",
#' p.value for which the global test will be considered significant.
friedman_posthoc = function(meas = NULL, p.value = 0.05) { # nolint

if (!requireNamespace("PMCMR", quietly = TRUE)) {
stop("Package PMCMR required for post-hoc Friedman tests.")
if (!requireNamespace("PMCMRplus", quietly = TRUE)) {
stop("Package PMCMRplus required for post-hoc Friedman tests.")
}

if (self$nlrns == 2) {
Expand All @@ -242,7 +242,7 @@ BenchmarkAggr = R6Class("BenchmarkAggr",
if (f.rejnull) {
form = as.formula(paste0(meas, " ~ ", self$col_roles$learner_id, " | ",
self$col_roles$task_id))
nem_test = PMCMR::posthoc.friedman.nemenyi.test(form, data = private$.dt) # nolint
nem_test = PMCMRplus::frdAllPairsNemenyiTest(form, data = private$.dt) # nolint
nem_test$f.rejnull = f.rejnull # nolint
return(nem_test)
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/autoplot.BenchmarkAggr.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#' # mean and error bars
#' autoplot(obj, type = "mean", level = 0.95)
#'
#' if (requireNamespace("PMCMR", quietly = TRUE)) {
#' if (requireNamespace("PMCMRplus", quietly = TRUE)) {
#' # critical differences
#' autoplot(obj, type = "cd",style = 1)
#' autoplot(obj, type = "cd",style = 2)
Expand Down
2 changes: 1 addition & 1 deletion man/BenchmarkAggr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/autoplot.BenchmarkAggr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test_BenchmarkAggr.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test_that("public methods", {
data.table(tasks = factor(c("A", "B")), learners = factor(c("L3", "L3")),
RMSE = c(3, 4), MSE = c(9, 16)))

skip_if_not_installed("PMCMR")
skip_if_not_installed("PMCMRplus")
expect_error(ba$friedman_posthoc(), "measures")
expect_warning(ba$friedman_posthoc(meas = "RMSE"), "Cannot reject")
expect_silent(ba$friedman_posthoc(p.value = 0.9, meas = "RMSE"))
Expand Down
18 changes: 10 additions & 8 deletions tests/testthat/test_autoplot_BenchmarkAggr.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ test_that("autoplot.BenchmarkAggr", {
expect_true(is.ggplot(autoplot(ba, type = "mean")))
expect_true(is.ggplot(autoplot(ba, type = "box")))

skip_if_not_installed("PMCMR")
skip_if_not_installed("PMCMRplus")
expect_true(is.ggplot(autoplot(ba, type = "fn")))
expect_true(is.ggplot(autoplot(ba, type = "cd")))
})

test_that("autoplot.BenchmarkAggr cd", {
skip_if_not_installed("PMCMR")
skip_if_not_installed("PMCMRplus")

set.seed(1)
df = data.frame(task_id = factor(rep(c("A", "B"), each = 5)),
Expand All @@ -30,19 +30,21 @@ test_that("autoplot.BenchmarkAggr cd", {
})

test_that("autoplot with BenchmarkAggr from mlr3::benchmark()", {
skip_if_not_installed("PMCMR")
skip_if_not_installed("PMCMRplus")
skip_if_not_installed("mlr3")
skip_if_not_installed("ggplot2")
skip_if_not_installed("mlr3learners")
skip_if_not_installed("rpart")
skip_if_not_installed("ranger")
set.seed(1)

library("mlr3")
task = tsks(c("iris", "sonar", "wine", "zoo"))
learns = lrns(c("classif.featureless", "classif.rpart", "classif.ranger"))

task = tsks(c("iris", "sonar"))
learns = c(lrns(c("classif.featureless", "classif.rpart")),
lrn("classif.rpart", id = "rpart2")
)
bm = benchmark(benchmark_grid(task, learns, rsmp("cv", folds = 3)))
ba = BenchmarkAggr$new(bm$aggregate())
ba = as.BenchmarkAggr(bm)

expect_true(ggplot2::is.ggplot(autoplot(ba, type = "cd")))
expect_true(ggplot2::is.ggplot(autoplot(ba, type = "cd", p.value = 0.2)))
})

0 comments on commit 9d6c566

Please sign in to comment.