Skip to content

Commit

Permalink
fix: anticipate row roles change in mlr3
Browse files Browse the repository at this point in the history
  • Loading branch information
sebffischer committed Feb 16, 2024
1 parent 0eb9f48 commit 896cc98
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 29 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/test-task-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# r cmd check workflow of the mlr3 ecosystem v0.1.0
# https://github.com/mlr-org/actions
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

name: r-cmd-check-paradox

jobs:
r-cmd-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'devel'}
- {os: ubuntu-latest, r: 'release'}

steps:
- uses: actions/checkout@v3

- name: mlr3
run: 'echo -e "Remotes:\n mlr-org/mlr3@feat/train-predict" >> DESCRIPTION'

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
- uses: r-lib/actions/check-r-package@v2
47 changes: 47 additions & 0 deletions .github/workflows/test-task-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# r cmd check workflow of the mlr3 ecosystem v0.1.0
# https://github.com/mlr-org/actions
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

name: r-cmd-check-paradox

jobs:
r-cmd-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'devel'}
- {os: ubuntu-latest, r: 'release'}

steps:
- uses: actions/checkout@v3

- name: mlr3
run: 'echo -e "Remotes:\n mlr-org/mlr3@feat/train-predict" >> DESCRIPTION'

- name: mlr3pipelines
run: 'echo -e "Remotes:\n mlr-org/mlr3pipelines@feat/test-rows" >> DESCRIPTION'

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
- uses: r-lib/actions/check-r-package@v2
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Config/testthat/parallel: true
Encoding: UTF-8
NeedsCompilation: no
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Collate:
'ArchiveTuning.R'
'AutoTuner.R'
Expand Down
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ import(mlr3)
import(mlr3misc)
import(paradox)
importFrom(R6,R6Class)
importFrom(bbotk,mlr_terminators)
importFrom(bbotk,trm)
importFrom(bbotk,trms)
importFrom(mlr3misc,clbk)
importFrom(mlr3misc,clbks)
importFrom(mlr3misc,mlr_callbacks)
importFrom(utils,bibentry)
2 changes: 1 addition & 1 deletion R/TunerIrace.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ target_runner_tuning = function(experiment, exec.target.runner, scenario, target
configuration
})
# fix logicals
lgl_params = as.data.table(tuning_instance$search_space)[class == "ParamLgl", id]
lgl_params = as.data.table(tuning_instance$search_space)[class == "ParamLgl", get("id")]
if (length(lgl_params)) xdt[, (lgl_params) := lapply(.SD, as.logical), .SDcols = lgl_params]

# provide experiment instances to objective
Expand Down
7 changes: 1 addition & 6 deletions R/mlr_callbacks.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,9 @@ load_callback_backup = function() {
#' callbacks = clbk("mlr3tuning.measures", measures = msr("classif.acc"))
#' )
#'
#' # score the configurations on the holdout set
#' task = tsk("pima")
#' splits = partition(task, ratio = 0.8)
#' task$row_roles$use = splits$train
#' task$row_roles$holdout = splits$test
#'
#' learner = lrn("classif.rpart", cp = to_tune(1e-04, 1e-1, logscale = TRUE))
#' learner$predict_sets = c("test", "holdout")
#'
#' instance = tune(
#' tuner = tnr("random_search", batch_size = 2),
Expand All @@ -168,7 +163,7 @@ load_callback_backup = function() {
#' measures = msr("classif.ce"),
#' term_evals = 4,
#' callbacks = clbk("mlr3tuning.measures", measures = msr("classif.ce",
#' predict_sets = "holdout", id = "classif.ce_holdout"))
#' predict_sets = "test", id = "classif.ce_holdout"))
#' )
NULL

Expand Down
6 changes: 5 additions & 1 deletion inst/testthat/helper_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,9 @@ MAKE_GL = function() {
g$add_pipeop(op_ds)
g$add_pipeop(op_lrn)
g$add_edge("subsample", "classif.rpart")
GraphLearner$new(g)
gl = GraphLearner$new(g)
# FIXME: this is needed because graphlearner sets its properties to all available properties,
# which will be fixed in the next pipelines release
gl$properties = setdiff(gl$properties, "uses_test_task")
gl
}
7 changes: 1 addition & 6 deletions man/mlr3tuning.measures.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_tuners_cmaes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_tuners_design_points.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_tuners_gensa.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_tuners_grid_search.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_tuners_irace.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_tuners_nloptr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_tuners_random_search.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/testthat/test_AutoTuner.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ test_that("AutoTuner get_base_learner method works", {
learner = as_learner(pipeline_robustify() %>>% lrn("classif.rpart"))
learner$param_set$values$classif.rpart.cp = to_tune(1e-04, 1e-1, logscale = TRUE)
learner$id = "graphlearner.classif.rpart"
# FIXME: this is needed because graphlearner sets its properties to all available properties,
# which will be fixed in the next pipelines release
learner$properties = setdiff(learner$properties, "uses_test_task")

at = auto_tuner(
tuner = tnr("random_search"),
Expand Down

0 comments on commit 896cc98

Please sign in to comment.