-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mlr3 targets post #41
Open
pat-s
wants to merge
3
commits into
main
Choose a base branch
from
mlr3targets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,612
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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}. | ||
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. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add one of these figures with red and green targets instead of the log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It tried but I couldn't get them large enough to be well visible in the post. Usually one does it with zooming but this is ofc not an option here.