From 59404958c75f4a27d62dceb960c21abcef8a7887 Mon Sep 17 00:00:00 2001 From: pat-s Date: Mon, 30 May 2022 21:09:17 +0200 Subject: [PATCH 1/3] allow reordering tasks in facets for `autoplot.bmr()` --- .pre-commit-config.yaml | 5 +++-- R/BenchmarkResult.R | 7 +++++++ man/autoplot.BenchmarkResult.Rd | 11 ++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d095cdde..4d674461 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # R specific hooks: https://github.com/lorenzwalthert/precommit repos: - repo: https://github.com/lorenzwalthert/precommit - rev: v0.2.2.9009 + rev: v0.3.0 hooks: - id: style-files args: [--style_pkg=styler.mlr, --style_fun=mlr_style] @@ -13,6 +13,7 @@ repos: additional_dependencies: - checkmate - data.table + - mlr3 - ggplot2 - mlr3misc - scales @@ -46,7 +47,7 @@ repos: - id: no-browser-statement - id: deps-in-desc - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.2.0 hooks: - id: check-added-large-files args: ['--maxkb=1000'] diff --git a/R/BenchmarkResult.R b/R/BenchmarkResult.R index a3cba7b6..0bd771de 100644 --- a/R/BenchmarkResult.R +++ b/R/BenchmarkResult.R @@ -17,6 +17,8 @@ #' * `"prc"`: Precision recall curve. See `"roc"`. #' #' @param object ([mlr3::BenchmarkResult]). +#' @param custom_facet_order (`character()`)\cr +#' Vector specyfing a custom facet order. Only applies for `type = "boxplot"`. #' @template param_type #' @template param_measure #' @param ... (`any`): @@ -46,6 +48,7 @@ autoplot.BenchmarkResult = function(object, # nolint type = "boxplot", measure = NULL, + custom_facet_order = NULL, ...) { assert_string(type) @@ -62,6 +65,10 @@ autoplot.BenchmarkResult = function(object, # nolint switch(type, "boxplot" = { + if (!is.null(custom_facet_order)) { + checkmate::assert_character(custom_facet_order) + tab$task_id = factor(tab$task_id, levels = custom_facet_order, ordered = TRUE) + } ggplot(tab, mapping = aes(x = .data$nr, y = .data[[measure_id]])) + geom_boxplot(...) + labs(x = "") + diff --git a/man/autoplot.BenchmarkResult.Rd b/man/autoplot.BenchmarkResult.Rd index 83358b75..13adbffe 100644 --- a/man/autoplot.BenchmarkResult.Rd +++ b/man/autoplot.BenchmarkResult.Rd @@ -4,7 +4,13 @@ \alias{autoplot.BenchmarkResult} \title{Plot for BenchmarkResult} \usage{ -\method{autoplot}{BenchmarkResult}(object, type = "boxplot", measure = NULL, ...) +\method{autoplot}{BenchmarkResult}( + object, + type = "boxplot", + measure = NULL, + custom_facet_order = NULL, + ... +) } \arguments{ \item{object}{(\link[mlr3:BenchmarkResult]{mlr3::BenchmarkResult}).} @@ -15,6 +21,9 @@ Type of the plot. See description.} \item{measure}{(\link[mlr3:Measure]{mlr3::Measure})\cr Performance measure to use.} +\item{custom_facet_order}{(\code{character()})\cr +Vector specyfing a custom facet order. Only applies for \code{type = "boxplot"}.} + \item{...}{(\code{any}): Additional arguments, passed down to the respective \code{geom} or plotting function.} } From 5b8ec484d085cc5d8b32147dcad339fe2d1155b8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 19:15:16 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- man/autoplot.LearnerClassifGlmnet.Rd | 4 ++-- man/autoplot.LearnerClustHierarchical.Rd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/autoplot.LearnerClassifGlmnet.Rd b/man/autoplot.LearnerClassifGlmnet.Rd index 32d87fc6..7bb78a9c 100644 --- a/man/autoplot.LearnerClassifGlmnet.Rd +++ b/man/autoplot.LearnerClassifGlmnet.Rd @@ -17,8 +17,8 @@ \method{autoplot}{LearnerRegrGlmnet}(object, ...) } \arguments{ -\item{object}{(\link[mlr3learners:mlr_learners_classif.glmnet]{mlr3learners::LearnerClassifGlmnet} | \link[mlr3learners:mlr_learners_regr.glmnet]{mlr3learners::LearnerRegrGlmnet} | -\link[mlr3learners:mlr_learners_regr.cv_glmnet]{mlr3learners::LearnerRegrCVGlmnet} | \link[mlr3learners:mlr_learners_regr.cv_glmnet]{mlr3learners::LearnerRegrCVGlmnet}).} +\item{object}{(\link[mlr3learners:LearnerClassifGlmnet]{mlr3learners::LearnerClassifGlmnet} | \link[mlr3learners:LearnerRegrGlmnet]{mlr3learners::LearnerRegrGlmnet} | +\link[mlr3learners:LearnerRegrCVGlmnet]{mlr3learners::LearnerRegrCVGlmnet} | \link[mlr3learners:LearnerRegrCVGlmnet]{mlr3learners::LearnerRegrCVGlmnet}).} \item{...}{(\code{any}): Additional arguments, passed down to \code{\link[ggparty:autoplot.party]{ggparty::autoplot.party()}}.} diff --git a/man/autoplot.LearnerClustHierarchical.Rd b/man/autoplot.LearnerClustHierarchical.Rd index 9a11070d..3ef98181 100644 --- a/man/autoplot.LearnerClustHierarchical.Rd +++ b/man/autoplot.LearnerClustHierarchical.Rd @@ -7,7 +7,7 @@ \method{autoplot}{LearnerClustHierarchical}(object, type = "dend", ...) } \arguments{ -\item{object}{(\link[mlr3cluster:mlr_learners_clust.agnes]{mlr3cluster::LearnerClustAgnes} | \link[mlr3cluster:mlr_learners_clust.diana]{mlr3cluster::LearnerClustDiana} | \link[mlr3cluster:mlr_learners_clust.hclust]{mlr3cluster::LearnerClustHclust}).} +\item{object}{(\link[mlr3cluster:LearnerClustAgnes]{mlr3cluster::LearnerClustAgnes} | \link[mlr3cluster:LearnerClustDiana]{mlr3cluster::LearnerClustDiana} | \link[mlr3cluster:LearnerClustHclust]{mlr3cluster::LearnerClustHclust}).} \item{type}{(character(1)):\cr Type of the plot. See description.} From 3d54489f94579d42830497e799c9d97a915176cf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 14:43:03 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- man/autoplot.LearnerClassifGlmnet.Rd | 4 ++-- man/autoplot.LearnerClustHierarchical.Rd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/autoplot.LearnerClassifGlmnet.Rd b/man/autoplot.LearnerClassifGlmnet.Rd index 7bb78a9c..32d87fc6 100644 --- a/man/autoplot.LearnerClassifGlmnet.Rd +++ b/man/autoplot.LearnerClassifGlmnet.Rd @@ -17,8 +17,8 @@ \method{autoplot}{LearnerRegrGlmnet}(object, ...) } \arguments{ -\item{object}{(\link[mlr3learners:LearnerClassifGlmnet]{mlr3learners::LearnerClassifGlmnet} | \link[mlr3learners:LearnerRegrGlmnet]{mlr3learners::LearnerRegrGlmnet} | -\link[mlr3learners:LearnerRegrCVGlmnet]{mlr3learners::LearnerRegrCVGlmnet} | \link[mlr3learners:LearnerRegrCVGlmnet]{mlr3learners::LearnerRegrCVGlmnet}).} +\item{object}{(\link[mlr3learners:mlr_learners_classif.glmnet]{mlr3learners::LearnerClassifGlmnet} | \link[mlr3learners:mlr_learners_regr.glmnet]{mlr3learners::LearnerRegrGlmnet} | +\link[mlr3learners:mlr_learners_regr.cv_glmnet]{mlr3learners::LearnerRegrCVGlmnet} | \link[mlr3learners:mlr_learners_regr.cv_glmnet]{mlr3learners::LearnerRegrCVGlmnet}).} \item{...}{(\code{any}): Additional arguments, passed down to \code{\link[ggparty:autoplot.party]{ggparty::autoplot.party()}}.} diff --git a/man/autoplot.LearnerClustHierarchical.Rd b/man/autoplot.LearnerClustHierarchical.Rd index 3ef98181..9a11070d 100644 --- a/man/autoplot.LearnerClustHierarchical.Rd +++ b/man/autoplot.LearnerClustHierarchical.Rd @@ -7,7 +7,7 @@ \method{autoplot}{LearnerClustHierarchical}(object, type = "dend", ...) } \arguments{ -\item{object}{(\link[mlr3cluster:LearnerClustAgnes]{mlr3cluster::LearnerClustAgnes} | \link[mlr3cluster:LearnerClustDiana]{mlr3cluster::LearnerClustDiana} | \link[mlr3cluster:LearnerClustHclust]{mlr3cluster::LearnerClustHclust}).} +\item{object}{(\link[mlr3cluster:mlr_learners_clust.agnes]{mlr3cluster::LearnerClustAgnes} | \link[mlr3cluster:mlr_learners_clust.diana]{mlr3cluster::LearnerClustDiana} | \link[mlr3cluster:mlr_learners_clust.hclust]{mlr3cluster::LearnerClustHclust}).} \item{type}{(character(1)):\cr Type of the plot. See description.}