【发布时间】:2018-09-03 13:31:10
【问题描述】:
当使用step_regex 函数为模型构建配方时,它会为原始列中的某些模式创建额外的列。完成后有没有办法从配方中排除原始列?
例如在下面的示例中,产品包含原始description 列和step_regex 新创建的两个列。我想要一个与recipe 对象集成的解决方案,这样我就可以直接在caret::train 中使用它。
library(recipe)
data(covers)
rec <- recipe(~ description, covers) %>%
step_regex(description, pattern = "(rock|stony)", result = "rocks") %>%
step_regex(description, pattern = "ratake families")
rec2 <- prep(rec, training = covers)
with_dummies <- bake(rec2, newdata = covers)
【问题讨论】: