From c22200430e078054a9c36689764931d308e7a45f Mon Sep 17 00:00:00 2001 From: Marc Becker <33069354+be-marc@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:43:15 +0100 Subject: [PATCH] refactor: remove inferr (#154) --- DESCRIPTION | 5 +- NEWS.md | 1 - R/BenchmarkResult.R | 37 --------- man/autoplot.BenchmarkResult.Rd | 1 - .../_snaps/BenchmarkResult/bmr-holdout-ci.svg | 75 ------------------- tests/testthat/test_BenchmarkResult.R | 15 ---- 6 files changed, 1 insertion(+), 133 deletions(-) delete mode 100644 tests/testthat/_snaps/BenchmarkResult/bmr-holdout-ci.svg diff --git a/DESCRIPTION b/DESCRIPTION index 8368f7b9..07d89fc2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -49,7 +49,6 @@ Suggests: mlr3cluster, mlr3filters, mlr3fselect (>= 1.0.0), - mlr3inferr, mlr3learners, mlr3tuning (>= 1.0.0), paradox, @@ -65,9 +64,7 @@ Suggests: survminer, mlr3proba (>= 0.6.3) Remotes: - mlr-org/mlr3, - mlr-org/mlr3proba, - mlr-org/mlr3inferr + mlr-org/mlr3proba Additional_repositories: https://mlr-org.r-universe.dev Config/testthat/edition: 3 diff --git a/NEWS.md b/NEWS.md index 506e6626..2e2d754e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,6 @@ # mlr3viz (development version) - Add plot for `LearnerSurvCoxPH`. -- Add plot for confidence intervals (`mlr3inferr`) # mlr3viz 0.9.0 diff --git a/R/BenchmarkResult.R b/R/BenchmarkResult.R index a72e0052..798fe0cc 100644 --- a/R/BenchmarkResult.R +++ b/R/BenchmarkResult.R @@ -12,7 +12,6 @@ #' Requires package \CRANpkg{precrec}. #' * `"prc"`: Precision recall curve. #' See `"roc"`. -#' * `"ci"`: Plot confidence intervals. Pass a `msr("ci", ...)` from the `mlr3inferr` package as argument `measure`. #' #' @param object ([mlr3::BenchmarkResult]). #' @template param_type @@ -47,42 +46,6 @@ autoplot.BenchmarkResult = function(object, type = "boxplot", measure = NULL, th task = object$tasks$task[[1L]] measure = mlr3::assert_measure(mlr3::as_measure(measure, task_type = task$task_type), task = task) - if (identical(type, "ci")) { - mlr3misc::require_namespaces("mlr3inferr") - - assert_class(measure, "MeasureAbstractCi") - mid = measure$id - - tbl = object$aggregate(measure) - - tmp = map(object$resamplings$resampling, function(x) { - list(class(x), x$param_set$values) - }) - - if (length(unique(tmp)) != 1) { - stopf("Plot of type 'ci' requires exactly one resampling method") - } - - # static checker - .data = NULL - task_id = NULL - p = ggplot(tbl, aes(x = .data[["learner_id"]], y = .data[[mid]])) + - geom_point() + - geom_errorbar(aes(ymin = .data[[paste0(mid, ".lower")]], ymax = .data[[paste0(mid, ".upper")]]), width = 0.2) + - facet_wrap(vars(task_id), scales = "free_y") + - labs( - title = sprintf("Confidence Intervals for alpha = %s", measure$param_set$values$alpha), - x = "Learner", - y = paste0(measure$measure$id) - ) + - theme + - theme( - axis.text.x = element_text(angle = 45, hjust = 1), - axis.title.x = element_blank() - ) - return(p) - } - measure_id = measure$id tab = fortify(object, measure = measure) tab$nr = sprintf("%09d", tab$nr) diff --git a/man/autoplot.BenchmarkResult.Rd b/man/autoplot.BenchmarkResult.Rd index ca060675..028022b2 100644 --- a/man/autoplot.BenchmarkResult.Rd +++ b/man/autoplot.BenchmarkResult.Rd @@ -41,7 +41,6 @@ Note that you can subset any \link[mlr3:BenchmarkResult]{mlr3::BenchmarkResult} Requires package \CRANpkg{precrec}. \item \code{"prc"}: Precision recall curve. See \code{"roc"}. -\item \code{"ci"}: Plot confidence intervals. Pass a \code{msr("ci", ...)} from the \code{mlr3inferr} package as argument \code{measure}. } } \examples{ diff --git a/tests/testthat/_snaps/BenchmarkResult/bmr-holdout-ci.svg b/tests/testthat/_snaps/BenchmarkResult/bmr-holdout-ci.svg deleted file mode 100644 index b1bb7967..00000000 --- a/tests/testthat/_snaps/BenchmarkResult/bmr-holdout-ci.svg +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -mtcars - - -regr.featureless -regr.rpart -0 -25 -50 -75 -regr.mse -Confidence Intervals for alpha = 0.05 - - diff --git a/tests/testthat/test_BenchmarkResult.R b/tests/testthat/test_BenchmarkResult.R index dcc3207e..b1aca587 100644 --- a/tests/testthat/test_BenchmarkResult.R +++ b/tests/testthat/test_BenchmarkResult.R @@ -49,18 +49,3 @@ test_that("holdout roc plot (#54)", { expect_doppelganger("bmr_holdout_roc", p) }) -skip_if_not_installed("mlr3inferr") -skip_if_not_installed("rpart") - -test_that("CI plot", { - bmr = benchmark(benchmark_grid(tsks(c("mtcars", "mtcars")), - lrns(c("regr.featureless", "regr.rpart")), rsmp("holdout"))) - - p = autoplot(bmr, "ci", msr("ci", "regr.mse")) - expect_true(is.ggplot(p)) - expect_doppelganger("bmr_holdout_ci", p) - - bmr = benchmark(benchmark_grid(tsk("iris"), lrn("classif.rpart"), - rsmps(c("holdout", "cv")))) - expect_error(autoplot(bmr, "ci", msr("ci", "classif.acc")), "one resampling method") -})