Skip to content

Commit

Permalink
- Allow NA as task type #106
Browse files Browse the repository at this point in the history
  • Loading branch information
pat-s authored Nov 18, 2021
2 parents a9b8538 + 36ad439 commit 4c5d0c6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions R/Filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Filter = R6Class("Filter",
#' Identifier for the filter.
#' @param task_type (`character()`)\cr
#' Types of the task the filter can operator on. E.g., `"classif"` or
#' `"regr"`.
#' `"regr"`. Can be set to `NA` to allow all task types.
#' @param param_set ([paradox::ParamSet])\cr
#' Set of hyperparameters.
#' @param feature_types (`character()`)\cr
Expand All @@ -73,8 +73,10 @@ Filter = R6Class("Filter",
packages = character(), man = NA_character_) {

self$id = assert_string(id)
self$task_type = assert_subset(task_type, mlr_reflections$task_types$type,
empty.ok = FALSE)
if (!test_scalar_na(task_type)) {
assert_subset(task_type, mlr_reflections$task_types$type, empty.ok = FALSE)
}
self$task_type = task_type
self$task_properties = assert_subset(
task_properties,
unlist(mlr_reflections$task_properties, use.names = FALSE))
Expand Down Expand Up @@ -138,7 +140,9 @@ Filter = R6Class("Filter",
task = assert_task(as_task(task),
feature_types = self$feature_types,
task_properties = self$task_properties)
assert_choice(task$task_type, self$task_type)
if (!test_scalar_na(self$task_type)) {
assert_choice(task$task_type, self$task_type)
}
fn = task$feature_names

if (task$nrow == 0L) {
Expand Down
2 changes: 1 addition & 1 deletion R/FilterVariance.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ FilterVariance = R6Class("FilterVariance",

super$initialize(
id = "variance",
task_type = c("classif", "regr"),
task_type = NA_character_,
param_set = param_set,
packages = "stats",
feature_types = c("integer", "numeric"),
Expand Down
1 change: 1 addition & 0 deletions man-roxygen/field_task_type.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' @field task_type (`character(1)`)\cr
#' Task type, e.g. `"classif"` or `"regr"`.
#' Can be set to `NA` to allow all task types.
#'
#' For a complete list of possible task types (depending on the loaded packages),
#' see [`mlr_reflections$task_types$type`][mlr_reflections].
3 changes: 2 additions & 1 deletion man/Filter.Rd

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

0 comments on commit 4c5d0c6

Please sign in to comment.