| PredictionTorch | R Documentation |
The Prediction object returned by learners that were trained on a
TaskTorch.
Because a TaskTorch can represent very different learning problems, this class does not
prescribe much about how truth, response, prob and se are stored.
This is defined by the task's prediction encoder, where you need to ensure that the first
dimension indexes the observations.
Within that, an element may be an atomic vector, a matrix(), an array() of any
dimensionality, a data.table or a lazy_tensor.
truth is whatever task$truth() returned – a vector for one target, a data.table for
several, a lazy_tensor for a lazy tensor column, and nothing at all for a task without a
target.
When a prediction is converted to a data.table, which is e.g. used for the printer,
the conversion depends on the type of the object.
A prob matrix spreads into one column per class, the way it does for a classification
prediction.
Everything else that is wider than one value per observation becomes a single column whose cells
hold that observation's own array, printed as its shape – <array[3]> for a response matrix
with three columns, <array[3x224x224]> for a prob with a class dimension and two spatial
ones.
Only a response with a single value per observation can report a missing prediction, so
$missing can only be TRUE for scalars and is always FALSE for parially missing predictions.
mlr3::Prediction -> PredictionTorch
response(any)
The predicted response.
prob(any)
The predicted probabilities.
se(any)
The standard errors of the prediction.
lazy_tensor(lazy_tensor or data.table of them)
The output of the network, for the predict type "lazy_tensor".
PredictionTorch$new()Creates a new instance of this R6 class.
PredictionTorch$new( task = NULL, row_ids = task$row_ids, truth = if (!is.null(task)) task$truth(row_ids), response = NULL, prob = NULL, se = NULL, lazy_tensor = NULL, weights = NULL, check = TRUE )
task(TaskTorch)
The task that was predicted on. Used to extract the default row_ids and the truth.
row_ids(integer())
The row ids of the predicted observations.
truth(any)
The ground truth, i.e. what task$truth() returned.
response(any)
The predicted response.
prob(any)
The predicted probabilities.
se(any)
The standard errors of the prediction.
lazy_tensor(lazy_tensor or data.table of them)
The output of the network, see the predict type "lazy_tensor" of LearnerTorch.
A network with more than one head produces one column per head.
weights(numeric() or NULL)
The measure weights of the predicted observations, i.e. the weights_measure column of the
task. mlr3 fills this in, so it rarely has to be passed by hand.
check(logical(1))
Whether to check the consistency of the prediction data.
PredictionTorch$clone()The objects of this class are cloneable with this method.
PredictionTorch$clone(deep = FALSE)
deepWhether to make a deep clone.
d = data.frame(x = rnorm(10), y1 = rnorm(10), y2 = rnorm(10))
task = as_task_torch(d, target = c("y1", "y2"))
PredictionTorch$new(task, response = as.matrix(d[, c("y1", "y2")]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.