Skip to content

Commit

Permalink
Merge pull request #15 from tdhock/fix14
Browse files Browse the repository at this point in the history
Fix14
  • Loading branch information
tdhock authored Sep 6, 2024
2 parents f993066 + 87a0050 commit 9518d80
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mlr3resampling
Type: Package
Title: Resampling Algorithms for 'mlr3' Framework
Version: 2024.7.14
Version: 2024.9.6
Authors@R: c(
person("Toby", "Hocking",
email="toby.hocking@r-project.org",
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Changes in version 2024.9.6

- .onLoad, add subset to mlr3_reflections$task_col_roles for classif and regr.

Changes in version 2024.7.14

- fix typo newere in vignette.
Expand Down
4 changes: 3 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ register_mlr3 = function() {
if (Sys.getenv("IN_PKGDOWN") == "true") {
lg$set_threshold("warn") # nolint
}

x = utils::getFromNamespace("mlr_reflections", ns = "mlr3")
x$task_col_roles$classif = c(x$task_col_roles$classif, "subset")
x$task_col_roles$regr = c(x$task_col_roles$regr, "subset")
mlr3misc::register_namespace_callback(pkgname, "mlr3", register_mlr3)
}

Expand Down
24 changes: 19 additions & 5 deletions vignettes/Newer_resamplers.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,39 @@ table(group.tab <- task.dt$random_group)
```

The output above shows the number of rows in each random group.
Below we define a task using that group,
Below we define a task,

```{r}
reg.task <- mlr3::TaskRegr$new(
"sin", task.dt, target="y")
reg.task$col_roles$subset <- "random_group"
reg.task$col_roles$group <- "agroup"
reg.task$col_roles$stratum <- "random_group"
reg.task$col_roles$feature <- "x"
str(reg.task$col_roles)
```

Below we define the cross-validation object, and instantiate it, in
Note that if we assign the `subset` role at this point, we will get an
error, because this is not a standard mlr3 role.


```{r error=TRUE, purl=FALSE}
reg.task$col_roles$subset <- "random_group"
```

Below we define the cross-validation object, which loads the
mlr3resampling package, and then we assign the random group column to
be used as the `subset` role.

```{r}
same_other_sizes_cv <- mlr3resampling::ResamplingSameOtherSizesCV$new()
reg.task$col_roles$subset <- "random_group"
```

Below we instantiate the resampler, in
order to show details about how it works (but normally you should not
instantiate it yourself, as this will be done automatically inside the
call to `mlr3::benchmark`).

```{r}
same_other_sizes_cv <- mlr3resampling::ResamplingSameOtherSizesCV$new()
same_other_sizes_cv$instantiate(reg.task)
same_other_sizes_cv$instance$iteration.dt
```
Expand Down
1 change: 1 addition & 0 deletions vignettes/Older_resamplers.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
mlr3resampling::ResamplingSameOtherCV$new()
```

The goal of this vignette is to explain the older resamplers:
Expand Down

0 comments on commit 9518d80

Please sign in to comment.