# NOT RUN {
library("mlr3")
task = tsk("pima")
task$missings()
po = po("imputelearner", lrn("regr.rpart"))
new_task = po$train(list(task = task))[[1]]
new_task$missings()
# '$state' of the "regr.rpart" Learner, trained to predict the 'mass' column:
po$state$model$mass
library("mlr3learners")
# to use the "regr.kknn" Learner, prefix it with its own imputation method!
# The "imputehist" PipeOp is used to train "regr.kknn"; predictions of this
# trained Learner are then used to impute the missing values in the Task.
po = po("imputelearner",
po("imputehist") %>>% lrn("regr.kknn")
)
new_task = po$train(list(task = task))[[1]]
new_task$missings()
# }
Run the code above in your browser using DataLab