Skip to content

Commit

Permalink
check with new paradox (#95)
Browse files Browse the repository at this point in the history
* check with new paradox

* new paradox

* a required parameter can not have a default.

* new paradox syntax

* more checks

* trigger actions

* dev cmd check with paradox master

* news entry
  • Loading branch information
mb706 authored Feb 29, 2024
1 parent ca800e0 commit 55fd30d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/dev-cmd-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
config:
- {os: ubuntu-latest, r: 'release', dev-package: 'mlr-org/bbotk'}
- {os: ubuntu-latest, r: 'release', dev-package: 'mlr-org/mlr3'}
- {os: ubuntu-latest, r: 'release', dev-package: "mlr-org/mlr3learners', 'mlr-org/mlr3pipelines', 'mlr-org/bbotk', 'mlr-org/paradox"}

steps:
- uses: actions/checkout@v3
Expand All @@ -48,7 +49,7 @@ jobs:
needs: check

- name: Install dev versions
run: pak::pkg_install('${{ matrix.config.dev-package }}')
run: pak::pkg_install(c('${{ matrix.config.dev-package }}'))
shell: Rscript {0}

- uses: mxschmitt/action-tmate@v3
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* fix: Include `FSelector` in hash of `AutoFSelector`.
* refactor: Change default batch size of `FSelectorRandomSearch` to 10.
* feat: Add `batch_size` parameter to `FSelectorExhaustiveSearch` to reduce memory consumption.
* Compatibility with upcoming paradox release.

# mlr3fselect 0.11.0

Expand Down
2 changes: 1 addition & 1 deletion R/FSelectorExhaustiveSearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ FSelectorExhaustiveSearch = R6Class("FSelectorExhaustiveSearch",
initialize = function() {
ps = ps(
max_features = p_int(lower = 1L),
batch_size = p_int(lower = 1L, default = 10L, tags = "required")
batch_size = p_int(lower = 1L, tags = "required")
)
ps$values = list(batch_size = 10L)

Expand Down
2 changes: 1 addition & 1 deletion R/FSelectorRandomSearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ FSelectorRandomSearch = R6Class("FSelectorRandomSearch",
initialize = function() {
ps = ps(
max_features = p_int(lower = 1L),
batch_size = p_int(lower = 1L, default = 10L, tags = "required")
batch_size = p_int(lower = 1L, tags = "required")
)
ps$values = list(batch_size = 10L)

Expand Down
5 changes: 4 additions & 1 deletion R/FSelectorShadowVariableSearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ FSelectorShadowVariableSearch = R6Class("FSelectorShadowVariableSearch",
task$cbind(data)

# add shadow variables to domain
inst$objective$domain = ParamSet$new(map(inst$objective$task$feature_names, function(s) ParamLgl$new(id = s)))
fnames = inst$objective$task$feature_names
params = rep(list(p_lgl()), length(inst$objective$task$feature_names))
names(params) = fnames
inst$objective$domain = do.call(ps, params)

# add shadow variables to search_space
inst$archive$search_space = inst$objective$domain
Expand Down
18 changes: 14 additions & 4 deletions R/helper.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
task_to_domain = function(task) {
ParamSet$new(map(task$feature_names, function(s) ParamLgl$new(id = s)))
params = rep(list(p_lgl()), length(task$feature_names))
names(params) = task$feature_names
do.call(ps, params)
}

measures_to_codomain = function(measures) {
Codomain$new(map(as_measures(measures), function(s) {
ParamDbl$new(id = s$id, tags = ifelse(s$minimize, "minimize", "maximize"))
}))
measures = as_measures(measures)
domains = map(measures, function(s) {
if ("set_id" %in% names(ps())) {
# old paradox
get("ParamDbl")$new(id = s$id, tags = ifelse(s$minimize, "minimize", "maximize"))
} else {
p_dbl(tags = ifelse(s$minimize, "minimize", "maximize"))
}
})
names(domains) = ids(measures)
Codomain$new(domains)
}

0 comments on commit 55fd30d

Please sign in to comment.