I would like to have all the predictions of a random forest from the package {ranger} stored in an ml3 Prediction Object, and then use the predictions of the individual trees as features for another learner.
The following code then follows to the following error message in R.
Code:
library("mlr3")
library("mlr3learners")
task = tsk("iris")
learner = lrn("classif.ranger", predict.all = TRUE)
# Train
train_set = sample(task$nrow, 0.8 * task$nrow)
test_set = setdiff(seq_len(task$nrow), train_set)
learner$train(task, row_ids = train_set)
# Predition
prediction = learner$predict(task, row_ids = test_set)
print(prediction)
Error:
Error in check_prediction_data.PredictionDataClassif(pdata) :
Assertion on 'as_factor(pdata$response, levels = lvls)' failed: Must have length 30, but has length 15000.
Can someone help me to solve this issue?