An example with iris. We have some data, called tr.
df = iris
set.seed(1)
sp = sample(nrow(iris), 0.7*nrow(iris))
tr = df[sp,]
newdata = df[-sp,]
We build a model in mlr3 with the data we have:
tsk = TaskClassif$new(id="A", backend=tr, target="Species")
lrn = mlr_learners$get("classif.rpart")
train_set <- sample(tsk$nrow, 0.8*tsk$nrow)
test_set <- setdiff(seq_len(tsk$nrow), train_set)
# train the model
lrn$train(tsk, row_ids = train_set)
# predict data
pred <- lrn$predict(tsk, row_ids = test_set)
Now I want to predict the newdata with the model I built, but I only find row_ids as an argument to predict. The newdata dataset has no row_ids in tsk. I know that I can incorporate these data into the model and retrain. But my question is: Is there any way to predict without retraining the tsk?
Thank you!