Prediction | R Documentation |
This is the abstract base class for task objects like PredictionClassif or PredictionRegr.
Prediction objects store the following information:
The row ids of the test set
The corresponding true (observed) response.
The corresponding predicted response.
Additional predictions based on the class and predict_type
.
E.g., the class probabilities for classification or the estimated standard error for regression.
Note that this object is usually constructed via a derived classes, e.g. PredictionClassif or PredictionRegr.
as.data.table(rr)
Prediction -> data.table::data.table()
Converts the data to a data.table::data.table()
.
c(..., keep_duplicates = TRUE)
(Prediction, Prediction, ...) -> Prediction
Combines multiple Prediction
s to a single Prediction
.
If keep_duplicates
is FALSE
and there are duplicated row ids,
the data of the former passed objects get overwritten by the data of the later passed objects.
data
(named list()
)
Internal data structure.
task_type
(character(1)
)
Required type of the Task.
task_properties
(character()
)
Required properties of the Task.
predict_types
(character()
)
Set of predict types this object stores.
man
(character(1)
)
String in the format [pkg]::[topic]
pointing to a manual page for this object.
Defaults to NA
, but can be set by child classes.
row_ids
(integer()
)
Vector of row ids for which predictions are stored.
truth
(any)
True (observed) outcome.
missing
(integer()
)
Returns row_ids
for which the predictions are missing or incomplete.
format()
Helper for print outputs.
Prediction$format(...)
...
(ignored).
print()
Printer.
Prediction$print(...)
...
(ignored).
help()
Opens the corresponding help page referenced by field $man
.
Prediction$help()
score()
Calculates the performance for all provided measures
Task and Learner may be NULL
for most measures, but some measures need to extract information
from these objects.
Note that the predict_sets
of the measures
are ignored by this method,
instead all predictions are used.
Prediction$score( measures = NULL, task = NULL, learner = NULL, train_set = NULL )
measures
(Measure | list of Measure)
Measure(s) to calculate.
task
(Task).
learner
(Learner).
train_set
(integer()
).
Prediction.
obs_loss()
Calculates the observation-wise loss via the loss function set in the
Measure's field obs_loss
.
Returns a data.table()
with the columns row_ids
, truth
, response
and
one additional numeric column for each measure, named with the respective measure id.
If there is no observation-wise loss function for the measure, the column is filled with
NA
values.
Note that some measures such as RMSE, do have an $obs_loss
, but they require an
additional transformation after aggregation, in this example taking the square-root.
Prediction$obs_loss(measures = NULL)
measures
(Measure | list of Measure)
Measure(s) to calculate.
filter()
Filters the Prediction, keeping only predictions for the provided row_ids. This changes the object in-place, you need to create a clone to preserve the original Prediction.
Prediction$filter(row_ids)
row_ids
integer()
Row indices.
self
, modified.
clone()
The objects of this class are cloneable with this method.
Prediction$clone(deep = FALSE)
deep
Whether to make a deep clone.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
Package mlr3viz for some generic visualizations.
Extension packages for additional task types:
mlr3proba for probabilistic supervised regression and survival analysis.
mlr3cluster for unsupervised clustering.
Other Prediction:
PredictionClassif
,
PredictionRegr
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.