Search code examples
mlr3

Is it possible to obtain predictions on the training data from resample results?


After executing the code below, it is possible to obtain predictions on the testing partition by using rr$predictions()[[1]]. But is it possible to obtain the predictions on the training partition?

task = tsk("penguins")
learner = lrn("classif.rpart")
resampling = rsmp("holdout")
rr = resample(task, learner, resampling)

Thanks!


Solution

  • You need to set predict_sets field of learner to both train and test, like this:

    learner$predict_sets=c("test", "train")
    

    Keep everything else the same and get train set predictions with

    rr$prediction("train")