I have a mlr3 task
df <- data.frame(v1 = c("a", "b", "a"),
v2 = c(1, 2, 2),
data = c(3.15, 4.11, 3.56))
library(mlr3)
task <- TaskRegr$new("bmsp", df, target = "data")
How can I rename the feature "v1" values "a" to values "c" within pipeline?
The code:
library(mlr3)
library(mlr3pipelines)
df <- data.frame(v1 = c("a", "b", "a"),
v2 = c(1, 2, 2),
data = c(3.15, 4.11, 3.56))
library(mlr3)
task <- TaskRegr$new("bmsp", df, target = "data")
pop <- po("colapply",
applicator = function(x) ifelse(x == "a", "c", x))
pop$param_set$values$affect_columns = selector_name("v1")
pop$train(list(task))[[1]]$data()
Gives the output (see column v1, row 2):
data v1 v2
1 3.15 c 1
2 4.11 2 2
3 3.56 c 2
But need output
data v1 v2
1 3.15 c 1
2 4.11 b 2
3 3.56 c 2