This object stores the predictions returned by a learner of class LearnerClassif. If probabilities are provided via construction and response is missing, the response is calculated from the probabilities: the class label with the highest probability is chosen. In case of ties, a random class label of the tied labels picked.
task_type is set to
p = PredictionClassif$new(task = NULL, response = NULL, prob = NULL)
task :: TaskClassif
Task for which the predictions are made. Used to extract the row ids and the true labels. Must be subsetted to test set.
Numeric matrix of class probabilities with one column for each class and one row for each observation in the test set.
Note that it is allowed to initialize this object without any arguments in order to allow to manually construct Prediction objects in a piecemeal fashion. Required are "row_ids", "truth", and "predict_type". Depending on the value of "predict_types", also "response" and "prob" must be set.
Vector of true labels.
Vector of predicted labels.
Vector of predict types this object stores.
task = mlr_tasks$get("iris") learner = mlr_learners$get("classif.rpart") learner$predict_type = "prob" e = Experiment$new(task, learner)$train()$predict()#> INFO [mlr3] Training learner 'rpart' on task 'iris' ... #> INFO [mlr3] Predicting with model of learner 'rpart' on task 'iris' ...p = e$prediction p$predict_types#>  "response" "prob"#> row_id response truth prob.setosa prob.versicolor prob.virginica #> 1: 1 setosa setosa 1 0 0 #> 2: 2 setosa setosa 1 0 0 #> 3: 3 setosa setosa 1 0 0 #> 4: 4 setosa setosa 1 0 0 #> 5: 5 setosa setosa 1 0 0 #> 6: 6 setosa setosa 1 0 0