Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
^revdep$
^cran-comments\.md$
^CRAN-SUBMISSION$
^.claude$
12 changes: 8 additions & 4 deletions .github/workflows/no-suggest-cmd-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# r cmd check workflow without suggests of the mlr3 ecosystem v0.2.0
# r cmd check workflow without suggests of the mlr3 ecosystem v0.3.1
# https://github.com/mlr-org/actions
on:
workflow_dispatch:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
- {os: ubuntu-latest, r: 'release'}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -43,9 +43,14 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
extra-packages: |
any::rcmdcheck
any::testthat
any::knitr
any::rmarkdown
needs: check
dependencies: '"hard"'
cache: false

- uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
Expand All @@ -54,5 +59,4 @@ jobs:

- uses: r-lib/actions/check-r-package@v2
with:
error-on: '"note"'
args: 'c("--no-manual", "--as-cran")'
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ License: LGPL-3
URL: https://mlr3viz.mlr-org.com, https://github.com/mlr-org/mlr3viz
BugReports: https://github.com/mlr-org/mlr3viz/issues
Depends:
R (>= 3.3.0)
R (>= 3.3.0),
mlr3 (>= 1.3.0)
Imports:
checkmate,
data.table,
Expand All @@ -37,6 +38,7 @@ Imports:
viridis
Suggests:
bbotk (>= 1.0.0),
clue,
cluster,
GGally,
ggdendro,
Expand All @@ -45,7 +47,6 @@ Suggests:
glmnet,
knitr,
lgr,
mlr3 (>= 0.6.0),
mlr3cluster,
mlr3filters,
mlr3fselect (>= 1.3.0),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export(plot_learner_prediction)
import(checkmate)
import(data.table)
import(ggplot2)
import(mlr3)
import(mlr3misc)
importFrom(ggplot2,autoplot)
importFrom(ggplot2,fortify)
Expand Down
20 changes: 8 additions & 12 deletions R/BenchmarkResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,15 @@
#'
#' @export
#' @examples
#' if (requireNamespace("mlr3")) {
#' library(mlr3)
#' library(mlr3viz)
#' if (mlr3misc::require_namespaces("precrec", quietly = TRUE)) {
#' tasks = tsks(c("pima", "sonar"))
#' learner = lrns(c("classif.featureless", "classif.rpart"), predict_type = "prob")
#' resampling = rsmps("cv")
#' object = benchmark(benchmark_grid(tasks, learner, resampling))
#'
#' tasks = tsks(c("pima", "sonar"))
#' learner = lrns(c("classif.featureless", "classif.rpart"),
#' predict_type = "prob")
#' resampling = rsmps("cv")
#' object = benchmark(benchmark_grid(tasks, learner, resampling))
#'
#' head(fortify(object))
#' autoplot(object)
#' autoplot(object$clone(deep = TRUE)$filter(task_ids = "pima"), type = "roc")
#' head(fortify(object))
#' autoplot(object)
#' autoplot(object$clone(deep = TRUE)$filter(task_ids = "pima"), type = "roc")
#' }
autoplot.BenchmarkResult = function(object, type = "boxplot", measure = NULL, theme = theme_minimal(), ...) {
assert_choice(type, choices = c("boxplot", "roc", "prc", "ci"), null.ok = FALSE)
Expand Down
5 changes: 2 additions & 3 deletions R/EnsembleFSResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@
#'
#' @return [ggplot2::ggplot()].
#' @examples
#' if (mlr3misc::require_namespaces("mlr3fselect", quietly = TRUE)) {
#' \donttest{
#' if (requireNamespace("mlr3")) {
#' library(mlr3)
#' set.seed (42)
#' library(mlr3fselect)
#'
#' set.seed (42)
#' efsr = ensemble_fselect(
#' fselector = fs("random_search"),
#' task = tsk("sonar"),
Expand Down
16 changes: 7 additions & 9 deletions R/Filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@
#' @return [ggplot2::ggplot()].
#' @export
#' @examples
#' if (requireNamespace("mlr3")) {
#' library(mlr3)
#' library(mlr3viz)
#' library(mlr3filters)
#' if (mlr3misc::require_namespaces("mlr3filters", quietly = TRUE)) {
#' library(mlr3filters)
#'
#' task = tsk("mtcars")
#' f = flt("correlation")
#' f$calculate(task)
#' task = tsk("mtcars")
#' f = flt("correlation")
#' f$calculate(task)
#'
#' head(fortify(f))
#' autoplot(f, n = 5)
#' head(fortify(f))
#' autoplot(f, n = 5)
#' }
autoplot.Filter = function(object, type = "boxplot", n = Inf, theme = theme_minimal(), ...) { # nolint
assert_choice(type, choices = c("boxplot"), null.ok = FALSE)
Expand Down
5 changes: 0 additions & 5 deletions R/LearnerClassif.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@
#' @export
#' @examples
#' \donttest{
#' if (requireNamespace("mlr3")) {
#' library(mlr3)
#' library(mlr3viz)
#'
#' task = tsk("pima")$select(c("age", "pedigree"))
#' learner = lrn("classif.rpart", predict_type = "prob")
#' learner$train(task)
#'
#' autoplot(learner, type = "prediction", task)
#' }
#' }
autoplot.LearnerClassif = function(object, type = "prediction", task, grid_points = 100L, expand_range = 0, theme = theme_minimal(), ...) { # nolint
assert_choice(type, choices = c("prediction"), null.ok = FALSE)

Expand Down
4 changes: 2 additions & 2 deletions R/LearnerClassifGlmnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
#'
#' @export
#' @examples
#' if (mlr3misc::require_namespaces("mlr3learners", quietly = TRUE)) {
#' \dontrun{
#' library(mlr3)
#' library(mlr3viz)
#' library(mlr3learners)
#'
#' # classification
Expand All @@ -41,6 +40,7 @@
#' learner$train(task)
#' autoplot(learner, type = "ggfortify")
#' }
#' }
autoplot.LearnerClassifGlmnet = function(object, type = "prediction", task = NULL, grid_points = 100L, expand_range = 0, theme = theme_minimal(), ...) { # nolint
assert_choice(type, choices = c("prediction", "ggfortify"), null.ok = FALSE)
assert_has_model(object)
Expand Down
25 changes: 11 additions & 14 deletions R/LearnerClassifRpart.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,18 @@
#'
#' @export
#' @examples
#' if (requireNamespace("mlr3")) {
#' library(mlr3)
#' library(mlr3viz)
#' if (mlr3misc::require_namespaces(c("partykit", "ggparty"), quietly = TRUE)) {
#' # classification
#' task = tsk("iris")
#' learner = lrn("classif.rpart", keep_model = TRUE)
#' learner$train(task)
#' autoplot(learner, type = "ggparty")
#'
#' # classification
#' task = tsk("iris")
#' learner = lrn("classif.rpart", keep_model = TRUE)
#' learner$train(task)
#' autoplot(learner, type = "ggparty")
#'
#' # regression
#' task = tsk("mtcars")
#' learner = lrn("regr.rpart", keep_model = TRUE)
#' learner$train(task)
#' autoplot(learner, type = "ggparty")
#' # regression
#' task = tsk("mtcars")
#' learner = lrn("regr.rpart", keep_model = TRUE)
#' learner$train(task)
#' autoplot(learner, type = "ggparty")
#' }
autoplot.LearnerClassifRpart = function(object, type = "prediction", task = NULL, grid_points = 100L, expand_range = 0, theme = theme_minimal(), ...) { # nolint
assert_choice(type, choices = c("prediction", "ggparty"), null.ok = FALSE)
Expand Down
32 changes: 15 additions & 17 deletions R/LearnerClustHierarchical.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,25 @@
#'
#' @export
#' @examples
#' if (requireNamespace("mlr3")) {
#' library(mlr3)
#' library(mlr3cluster)
#' library(mlr3viz)
#' if (mlr3misc::require_namespaces("mlr3cluster", quietly = TRUE)) {
#' library(mlr3cluster)
#'
#' task = tsk("usarrests")
#' task = tsk("usarrests")
#'
#' # agnes clustering
#' learner = lrn("clust.agnes")
#' learner$train(task)
#' autoplot(learner)
#' # agnes clustering
#' learner = lrn("clust.agnes")
#' learner$train(task)
#' autoplot(learner)
#'
#' # diana clustering
#' learner = lrn("clust.diana")
#' learner$train(task)
#' autoplot(learner)
#' # diana clustering
#' learner = lrn("clust.diana")
#' learner$train(task)
#' autoplot(learner)
#'
#' # hclust clustering
#' learner = lrn("clust.hclust")
#' learner$train(task)
#' autoplot(learner, type = "scree")
#' # hclust clustering
#' learner = lrn("clust.hclust")
#' learner$train(task)
#' autoplot(learner, type = "scree")
#' }
autoplot.LearnerClustHierarchical = function(object, type = "dend", task = NULL, theme = theme_minimal(), theme_dendro = TRUE, ...) { # nolint
assert_choice(type, choices = c("dend", "scree"), null.ok = FALSE)
Expand Down
5 changes: 0 additions & 5 deletions R/LearnerRegr.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@
#' @export
#' @examples
#' \donttest{
#' if (requireNamespace("mlr3")) {
#' library(mlr3)
#' library(mlr3viz)
#'
#' task = tsk("mtcars")$select(c("am", "carb"))
#' learner = lrn("regr.rpart")
#' learner$train(task)
#'
#' autoplot(learner, type = "prediction", task)
#' }
#' }
autoplot.LearnerRegr = function(object, type = "prediction", task, grid_points = 100L, expand_range = 0, theme = theme_minimal(), ...) { # nolint
assert_choice(type, choices = c("prediction"), null.ok = FALSE)

Expand Down
61 changes: 30 additions & 31 deletions R/OptimInstanceBatchSingleCrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,45 +44,44 @@
#'
#' @export
#' @examples
#' if (requireNamespace("mlr3") && requireNamespace("bbotk") && requireNamespace("patchwork")) {
#' library(bbotk)
#' library(paradox)
#' if (mlr3misc::require_namespaces(c("paradox", "bbotk", "patchwork"), quietly = TRUE)) {
#' library(bbotk)
#'
#' fun = function(xs) {
#' c(y = -(xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
#' }
#' domain = ps(
#' x1 = p_dbl(-10, 10),
#' x2 = p_dbl(-5, 5)
#' )
#' codomain = ps(
#' y = p_dbl(tags = "maximize")
#' )
#' obfun = ObjectiveRFun$new(
#' fun = fun,
#' domain = domain,
#' codomain = codomain
#' )
#' fun = function(xs) {
#' c(y = -(xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
#' }
#' domain = ps(
#' x1 = p_dbl(-10, 10),
#' x2 = p_dbl(-5, 5)
#' )
#' codomain = ps(
#' y = p_dbl(tags = "maximize")
#' )
#' obfun = ObjectiveRFun$new(
#' fun = fun,
#' domain = domain,
#' codomain = codomain
#' )
#'
#' instance = oi(objective = obfun, terminator = trm("evals", n_evals = 20))
#' instance = oi(objective = obfun, terminator = trm("evals", n_evals = 20))
#'
#' optimizer = opt("random_search", batch_size = 2)
#' optimizer$optimize(instance)
#' optimizer = opt("random_search", batch_size = 2)
#' optimizer$optimize(instance)
#'
#' # plot y versus batch number
#' print(autoplot(instance, type = "performance"))
#' # plot y versus batch number
#' print(autoplot(instance, type = "performance"))
#'
#' # plot x1 values versus performance
#' print(autoplot(instance, type = "marginal", cols_x = "x1"))
#' # plot x1 values versus performance
#' print(autoplot(instance, type = "marginal", cols_x = "x1"))
#'
#' # plot parallel coordinates plot
#' print(autoplot(instance, type = "parallel"))
#' # plot parallel coordinates plot
#' print(autoplot(instance, type = "parallel"))
#'
#' # plot pairs
#' print(autoplot(instance, type = "pairs"))
#' # plot pairs
#' print(autoplot(instance, type = "pairs"))
#'
#' # plot incumbent
#' print(autoplot(instance, type = "incumbent"))
#' # plot incumbent
#' print(autoplot(instance, type = "incumbent"))
#' }
autoplot.OptimInstanceBatchSingleCrit = function(object, type = "marginal", cols_x = NULL, trafo = FALSE, learner = mlr3::lrn("regr.ranger"), grid_resolution = 100, batch = NULL, theme = theme_minimal(), ...) { # nolint
assert_choice(type, choices = c("marginal", "performance", "parameter", "parallel",
Expand Down
19 changes: 8 additions & 11 deletions R/PredictionClassif.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@
#' @export
#' @examples
#' \donttest{
#' if (requireNamespace("mlr3")) {
#' library(mlr3)
#' library(mlr3viz)
#' if (mlr3misc::require_namespaces("precrec", quietly = TRUE)) {
#' task = tsk("spam")
#' learner = lrn("classif.rpart", predict_type = "prob")
#' object = learner$train(task)$predict(task)
#'
#' task = tsk("spam")
#' learner = lrn("classif.rpart", predict_type = "prob")
#' object = learner$train(task)$predict(task)
#'
#' head(fortify(object))
#' autoplot(object)
#' autoplot(object, type = "roc")
#' autoplot(object, type = "prc")
#' head(fortify(object))
#' autoplot(object)
#' autoplot(object, type = "roc")
#' autoplot(object, type = "prc")
#' }
#' }
autoplot.PredictionClassif = function(object, type = "stacked", measure = NULL, theme = theme_minimal(), ...) { # nolint
Expand Down
Loading