From 99f028a83f8e73aa4a732043d49f3df98030acd3 Mon Sep 17 00:00:00 2001 From: pat-s Date: Mon, 9 May 2022 18:02:45 +0200 Subject: [PATCH 1/2] add mlr3 targets post --- .../2022-05-08-mlr3-targets/mlr3-targets.Rmd | 55 + .../2022-05-08-mlr3-targets/mlr3-targets.html | 1557 +++++++++++++++++ 2 files changed, 1612 insertions(+) create mode 100644 mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.Rmd create mode 100644 mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.html diff --git a/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.Rmd b/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.Rmd new file mode 100644 index 00000000..54944913 --- /dev/null +++ b/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.Rmd @@ -0,0 +1,55 @@ +--- +title: "mlr3-targets: how to use {mlr3} and {targets}" +description: | + The repository `mlr3targets` presents a skeleton that shows how to conduct a benchmark in {mlr3} using the workflow package {targets}. +author: + - name: Patrick Schratz +date: 2022-05-08 +categories: + - R + - tutorial +output: + distill::distill_article: + self_contained: false +--- + + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = FALSE) +``` + +The [mlr3-learndrake](https://github.com/mlr-org/mlr3-learndrake) repository has been deprecated and (finally) been ported to it's successor {targets}. + +The new [mlr3-targets](https://github.com/mlr-org/mlr3-targets) repository shows exemplary how {mlr3} and {targets} can be used jointly. +The example implements a benchmark of two learners across two (example) tasks by making use of "dynamic branching" in {targets}. +It also showcases the use of an opinionated project structure for {targets} projects and demonstrates how custom functions can be used within {targets} projects. + +The SVM learner in the project makes use of a custom "trafo" function to transform the hyperparameter search space. + +The power of {targets} gets visible once changes are applied to the project. +For example, adding an additional task to the project (e.g. `sonar` via `tidyr::crossing(task = c("iris", "spam", "sonar")))` in `06-benchmark.R`) and invoking `tar_make()` again will only build the models for the newly added task and skip already existing ones. + +Here's the output from `tar_make()` for the described scenario. +Existing branches of the `bm_*` targets are skipped (e.g. `bm_6f2e35d0`) while missing ones are built (`bm_be2cba98`) and merged into the main target `bm` at the end. + +```r +✔ skip branch bm_8067dbd2 +• start branch bm_ad7f3ff3 +• built branch bm_ad7f3ff3 +✔ skip branch bm_0f8f184b +✔ skip branch bm_16624f9e +• start branch bm_d1764c21 +• built branch bm_d1764c21 +✔ skip branch bm_6f2e35d0 +✔ skip branch bm_335412b5 +• start branch bm_5b82da98 +• built branch bm_5b82da98 +✔ skip branch bm_5fdc62fd +✔ skip branch bm_c02dd27e +• start branch bm_be2cba98 +• built branch bm_be2cba98 +✔ skip branch bm_da5f38fa +• built pattern bm +``` + +For more examples related to {targets}, consult its excellent online documentation at https://books.ropensci.org/targets. diff --git a/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.html b/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.html new file mode 100644 index 00000000..b448c11e --- /dev/null +++ b/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.html @@ -0,0 +1,1557 @@ + + + + + + + + + + + + + + + + + + + + + mlr3-targets: how to use {mlr3} and {targets} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

mlr3-targets: how to use {mlr3} and {targets}

+ +
+
R
+
tutorial
+
+ +

The repository mlr3targets presents a skeleton that +shows how to conduct a benchmark in {mlr3} using the workflow package +{targets}.

+
+ +
+ Patrick Schratz + +
2022-05-08 +
+ +
+

The mlr3-learndrake +repository has been deprecated and (finally) been ported to it’s +successor {targets}.

+

The new mlr3-targets +repository shows exemplary how {mlr3} and {targets} can be used jointly. +The example implements a benchmark of two learners across two (example) +tasks by making use of “dynamic branching” in {targets}. It also +showcases the use of an opinionated project structure for {targets} +projects and demonstrates how custom functions can be used within +{targets} projects.

+

The SVM learner in the project makes use of a custom “trafo” function +to transform the hyperparameter search space.

+

The power of {targets} gets visible once changes are applied to the +project. For example, adding an additional task to the project +(e.g. sonar via +tidyr::crossing(task = c("iris", "spam", "sonar"))) in +06-benchmark.R) and invoking tar_make() again +will only build the models for the newly added task and skip already +existing ones.

+

Here’s the output from tar_make() for the described +scenario. Existing branches of the bm_* targets are skipped +(e.g. bm_6f2e35d0) while missing ones are built +(bm_be2cba98) and merged into the main target +bm at the end.

+
✔ skip branch bm_8067dbd2
+• start branch bm_ad7f3ff3
+• built branch bm_ad7f3ff3
+✔ skip branch bm_0f8f184b
+✔ skip branch bm_16624f9e
+• start branch bm_d1764c21
+• built branch bm_d1764c21
+✔ skip branch bm_6f2e35d0
+✔ skip branch bm_335412b5
+• start branch bm_5b82da98
+• built branch bm_5b82da98
+✔ skip branch bm_5fdc62fd
+✔ skip branch bm_c02dd27e
+• start branch bm_be2cba98
+• built branch bm_be2cba98
+✔ skip branch bm_da5f38fa
+• built pattern bm
+

For more examples related to {targets}, consult its excellent online +documentation at https://books.ropensci.org/targets.

+
+ + +
+ +
+
+ + + + + +
+ + + + + + + From d0f936e4b56eb8c46e3445455f88e72c2a1339cc Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 18 May 2022 17:14:26 +0200 Subject: [PATCH 2/2] typo --- mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.Rmd b/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.Rmd index 54944913..ed037a81 100644 --- a/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.Rmd +++ b/mlr-org/_posts/2022-05-08-mlr3-targets/mlr3-targets.Rmd @@ -18,7 +18,7 @@ output: knitr::opts_chunk$set(echo = FALSE) ``` -The [mlr3-learndrake](https://github.com/mlr-org/mlr3-learndrake) repository has been deprecated and (finally) been ported to it's successor {targets}. +The [mlr3-learndrake](https://github.com/mlr-org/mlr3-learndrake) repository has been deprecated and (finally) been ported to its successor {targets}. The new [mlr3-targets](https://github.com/mlr-org/mlr3-targets) repository shows exemplary how {mlr3} and {targets} can be used jointly. The example implements a benchmark of two learners across two (example) tasks by making use of "dynamic branching" in {targets}.