PredictionOrdinal: Prediction Object for Ordinal Regression

PredictionOrdinalR Documentation

Prediction Object for Ordinal Regression

Description

This object stores the predictions returned by a learner of class LearnerOrdinal.

Format

R6Class object inheriting from Prediction.

Usage

Inherits from Prediction

# Construction
p = PredictionOrdinal$new(task, response, prob)

# Members
p$predict_types
p$row_ids
p$truth

# S3 methods
as.data.table(p)

Arguments

  • task (Task): Task used for prediction. Used to extract row_ids and truth. Set to NULL to skip all argument checks during initialization. Slots p$row_ids and p$truth need to be set manually in this case.

  • response (factor() | ordered()): Vector of predicted class labels.

  • prob (matrix): Numeric matrix of rank probabilities with one column for each rank in task$class_names and one row for each observation in the test set.

Details

  • $new() initializes a new object of class Prediction.

  • $predict_types (character) stores the predict types available: a subset of c("response", "prob").

  • $response stores the predicted values.

  • row_ids stores the row IDs.

  • $truth stores the true rank vector.

  • The prediction object can be transformed to a simple data.table() with data.table::as.data.table.

Examples

library(mlr3)
task = mlr_tasks$get("winerating")
learner = mlr_learners$get("ordinal.clm")
p = learner$train(task)$predict(task)
head(as.data.table(p))

mlr-org/mlr3ordinal documentation built on Jan. 10, 2023, 10:04 a.m.