Skip to content

Commit 4c5d0c6

Browse files
authored
- Allow NA as task type #106
2 parents a9b8538 + 36ad439 commit 4c5d0c6

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

R/Filter.R

+8-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Filter = R6Class("Filter",
4949
#' Identifier for the filter.
5050
#' @param task_type (`character()`)\cr
5151
#' Types of the task the filter can operator on. E.g., `"classif"` or
52-
#' `"regr"`.
52+
#' `"regr"`. Can be set to `NA` to allow all task types.
5353
#' @param param_set ([paradox::ParamSet])\cr
5454
#' Set of hyperparameters.
5555
#' @param feature_types (`character()`)\cr
@@ -73,8 +73,10 @@ Filter = R6Class("Filter",
7373
packages = character(), man = NA_character_) {
7474

7575
self$id = assert_string(id)
76-
self$task_type = assert_subset(task_type, mlr_reflections$task_types$type,
77-
empty.ok = FALSE)
76+
if (!test_scalar_na(task_type)) {
77+
assert_subset(task_type, mlr_reflections$task_types$type, empty.ok = FALSE)
78+
}
79+
self$task_type = task_type
7880
self$task_properties = assert_subset(
7981
task_properties,
8082
unlist(mlr_reflections$task_properties, use.names = FALSE))
@@ -138,7 +140,9 @@ Filter = R6Class("Filter",
138140
task = assert_task(as_task(task),
139141
feature_types = self$feature_types,
140142
task_properties = self$task_properties)
141-
assert_choice(task$task_type, self$task_type)
143+
if (!test_scalar_na(self$task_type)) {
144+
assert_choice(task$task_type, self$task_type)
145+
}
142146
fn = task$feature_names
143147

144148
if (task$nrow == 0L) {

R/FilterVariance.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ FilterVariance = R6Class("FilterVariance",
3535

3636
super$initialize(
3737
id = "variance",
38-
task_type = c("classif", "regr"),
38+
task_type = NA_character_,
3939
param_set = param_set,
4040
packages = "stats",
4141
feature_types = c("integer", "numeric"),

man-roxygen/field_task_type.R

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#' @field task_type (`character(1)`)\cr
22
#' Task type, e.g. `"classif"` or `"regr"`.
3+
#' Can be set to `NA` to allow all task types.
34
#'
45
#' For a complete list of possible task types (depending on the loaded packages),
56
#' see [`mlr_reflections$task_types$type`][mlr_reflections].

man/Filter.Rd

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)