Skip to content

Commit

Permalink
refactor: remove inferr (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc authored Nov 7, 2024
1 parent 4442c6f commit c222004
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 133 deletions.
5 changes: 1 addition & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Suggests:
mlr3cluster,
mlr3filters,
mlr3fselect (>= 1.0.0),
mlr3inferr,
mlr3learners,
mlr3tuning (>= 1.0.0),
paradox,
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# mlr3viz (development version)

- Add plot for `LearnerSurvCoxPH`.
- Add plot for confidence intervals (`mlr3inferr`)

# mlr3viz 0.9.0

Expand Down
37 changes: 0 additions & 37 deletions R/BenchmarkResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion man/autoplot.BenchmarkResult.Rd

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

75 changes: 0 additions & 75 deletions tests/testthat/_snaps/BenchmarkResult/bmr-holdout-ci.svg

This file was deleted.

15 changes: 0 additions & 15 deletions tests/testthat/test_BenchmarkResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})

0 comments on commit c222004

Please sign in to comment.