Skip to content

Commit b6482d9

Browse files
committed
allow only numeric features
1 parent cd9b015 commit b6482d9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

R/FilterUnivariateCox.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@
1414
#' significance of the feature's impact on survival. The filter value is
1515
#' `-log10(p)` where `p` is the \eqn{p}-value. This transformation is necessary
1616
#' to ensure numerical stability for very small \eqn{p}-values. Also higher
17-
#' values denote more important features.
17+
#' values denote more important features. The filter works only for numeric
18+
#' features so please ensure that factor variables are properly encoded, e.g.
19+
#' using [PipeOpEncode][mlr3pipelines::PipeOpEncode].
1820
#'
1921
#' @family Filter
2022
#' @include Filter.R
2123
#' @template seealso_filter
2224
#' @export
2325
#' @examples
2426
#' if (requireNamespace("mlr3proba")) {
25-
#' task = tsk("rats")
27+
#' task = tsk("rats")$select(c("rx","litter"))
2628
#' filter = flt("univariatecox")
2729
#' filter$calculate(task)
2830
#' as.data.table(filter)
@@ -31,6 +33,9 @@
3133
#' if (mlr3misc::require_namespaces(c("mlr3pipelines", "mlr3proba"), quietly = TRUE)) {
3234
#' library("mlr3pipelines")
3335
#' task = tsk("rats")
36+
#' # encode `sex` which is a two-level factor
37+
#' enc = po("encode", method = "treatment")
38+
#' task = enc$train(list(task))[[1L]]
3439
#'
3540
#' # Note: `filter.cutoff` is selected randomly and should be tuned.
3641
#' # The significance level of `0.05` serves as a conventional threshold.
@@ -61,7 +66,7 @@ FilterUnivariateCox = R6Class("FilterUnivariateCox",
6166
id = "surv.univariatecox",
6267
packages = c("mlr3proba"),
6368
param_set = ps(),
64-
feature_types = c("integer", "numeric", "factor"),
69+
feature_types = c("integer", "numeric"),
6570
task_types = "surv",
6671
label = "Univariate Cox Survival Score",
6772
man = "mlr3filters::mlr_filters_univariatecox"

0 commit comments

Comments
 (0)