|
5 | 5 | #' @format [`R6Class`] object inheriting from [`PipeOpTaskPreprocSimple`]/[`PipeOpTaskPreproc`]/[`PipeOp`]. |
6 | 6 | #' |
7 | 7 | #' @description |
8 | | -#' Encodes columns of type `factor`, `character` and `ordered`. |
| 8 | +#' Encodes columns of type `factor` and `ordered`. |
9 | 9 | #' |
10 | 10 | #' Possible encodings are `"one-hot"` encoding, as well as encoding according to `stats::contr.helmert()`, `stats::contr.poly()`, |
11 | 11 | #' `stats::contr.sum()` and `stats::contr.treatment()`. |
|
14 | 14 | #' |
15 | 15 | #' Use the [`PipeOpTaskPreproc`] `$affect_columns` functionality to only encode a subset of columns, or only encode columns of a certain type. |
16 | 16 | #' |
| 17 | +#' `character`-type features can be encoded by converting them `factor` features first, using [`ppl("convert_types", "character", "factor")`][mlr_graphs_convert_types]. |
| 18 | +#' |
17 | 19 | #' @section Construction: |
18 | 20 | #' ``` |
19 | 21 | #' PipeOpEncode$new(id = "encode", param_vals = list()) |
|
26 | 28 | #' @section Input and Output Channels: |
27 | 29 | #' Input and output channels are inherited from [`PipeOpTaskPreproc`]. |
28 | 30 | #' |
29 | | -#' The output is the input [`Task`][mlr3::Task] with all affected `factor`, `character` or `ordered` parameters encoded according to the `method` |
| 31 | +#' The output is the input [`Task`][mlr3::Task] with all affected `factor` and `ordered` parameters encoded according to the `method` |
30 | 32 | #' parameter. |
31 | 33 | #' |
32 | 34 | #' @section State: |
|
78 | 80 | #' |
79 | 81 | #' poe$param_set$values$method = "sum" |
80 | 82 | #' poe$train(list(task))[[1]]$data() |
| 83 | +#' |
| 84 | +#' # converting character-columns |
| 85 | +#' data_chr = data.table::data.table(x = factor(letters[1:3]), y = letters[1:3]) |
| 86 | +#' task_chr = TaskClassif$new("task_chr", data_chr, "x") |
| 87 | +#' |
| 88 | +#' goe = ppl("convert_types", "character", "factor") %>>% po("encode") |
| 89 | +#' |
| 90 | +#' goe$train(task_chr)[[1]]$data() |
81 | 91 | PipeOpEncode = R6Class("PipeOpEncode", |
82 | 92 | inherit = PipeOpTaskPreprocSimple, |
83 | 93 | public = list( |
|
0 commit comments