我遵循了mlr3 关于使用管道对数据进行插补的文档。但是,如果一列是 NA,我训练的模式不允许预测
你知道为什么它不起作用吗?
训练步
library(mlr3)
library(mlr3learners)
library(mlr3pipelines)
data("mtcars", package = "datasets")
data = mtcars[, 1:3]
str(data)
task_mtcars = TaskRegr$new(id="cars", backend = data, target = "mpg")
imp_missind = po("missind")
imp_num = po("imputehist", param_vals =list(affect_columns = selector_type("numeric")))
scale = po("scale")
learner = lrn('regr.ranger')
graph = po("copy", 2) %>>%
gunion(list(imp_num %>>% scale,imp_missind)) %>>%
po("featureunion") %>>%
po(learner)
graph$plot()
graphlearner = GraphLearner$new(graph)
预测步数
data = task_mtcars$data()[12:12,]
data[1:1, cyl:=NA]
predict(graphlearner, data)
错误是
Error: Missing data in columns: cyl.