% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Prediction.R
\name{Prediction}
\alias{Prediction}
\title{Abstract Prediction Object}
\description{
This is the abstract base class for task objects like \link{PredictionClassif} or \link{PredictionRegr}.

Prediction objects store the following information:
\enumerate{
\item The row ids of the test set
\item The corresponding true (observed) response.
\item The corresponding predicted response.
\item Additional predictions based on the class and \code{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. \link{PredictionClassif} or \link{PredictionRegr}.
}
\section{S3 Methods}{

\itemize{
\item \code{as.data.table(rr)}\cr
\link{Prediction} -> \code{\link[data.table:data.table]{data.table::data.table()}}\cr
Converts the data to a \code{\link[data.table:data.table]{data.table::data.table()}}.
\item \code{c(..., keep_duplicates = TRUE)}\cr
(\link{Prediction}, \link{Prediction}, ...) -> \link{Prediction}\cr
Combines multiple \code{Prediction}s to a single \code{Prediction}.
If \code{keep_duplicates} is \code{FALSE} and there are duplicated row ids,
the data of the former passed objects get overwritten by the data of the later passed objects.
}
}

\seealso{
\itemize{
\item Chapter in the \href{https://mlr3book.mlr-org.com/}{mlr3book}:
\url{https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html}
\item Package \CRANpkg{mlr3viz} for some generic visualizations.
\item Extension packages for additional task types:
\itemize{
\item \CRANpkg{mlr3proba} for probabilistic supervised regression and survival analysis.
\item \CRANpkg{mlr3cluster} for unsupervised clustering.
}
}

Other Prediction: 
\code{\link{PredictionClassif}},
\code{\link{PredictionRegr}}
}
\concept{Prediction}
\section{Public fields}{
\if{html}{\out{<div class="r6-fields">}}
\describe{
\item{\code{data}}{(named \code{list()})\cr
Internal data structure.}

\item{\code{task_type}}{(\code{character(1)})\cr
Required type of the \link{Task}.}

\item{\code{task_properties}}{(\code{character()})\cr
Required properties of the \link{Task}.}

\item{\code{predict_types}}{(\code{character()})\cr
Set of predict types this object stores.}

\item{\code{man}}{(\code{character(1)})\cr
String in the format \verb{[pkg]::[topic]} pointing to a manual page for this object.
Defaults to \code{NA}, but can be set by child classes.}
}
\if{html}{\out{</div>}}
}
\section{Active bindings}{
\if{html}{\out{<div class="r6-active-bindings">}}
\describe{
\item{\code{row_ids}}{(\code{integer()})\cr
Vector of row ids for which predictions are stored.}

\item{\code{truth}}{(any)\cr
True (observed) outcome.}

\item{\code{missing}}{(\code{integer()})\cr
Returns \code{row_ids} for which the predictions are missing or incomplete.}
}
\if{html}{\out{</div>}}
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-Prediction-format}{\code{Prediction$format()}}
\item \href{#method-Prediction-print}{\code{Prediction$print()}}
\item \href{#method-Prediction-help}{\code{Prediction$help()}}
\item \href{#method-Prediction-score}{\code{Prediction$score()}}
\item \href{#method-Prediction-obs_loss}{\code{Prediction$obs_loss()}}
\item \href{#method-Prediction-filter}{\code{Prediction$filter()}}
\item \href{#method-Prediction-clone}{\code{Prediction$clone()}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Prediction-format"></a>}}
\if{latex}{\out{\hypertarget{method-Prediction-format}{}}}
\subsection{Method \code{format()}}{
Helper for print outputs.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Prediction$format(...)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{...}}{(ignored).}
}
\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Prediction-print"></a>}}
\if{latex}{\out{\hypertarget{method-Prediction-print}{}}}
\subsection{Method \code{print()}}{
Printer.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Prediction$print(...)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{...}}{(ignored).}
}
\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Prediction-help"></a>}}
\if{latex}{\out{\hypertarget{method-Prediction-help}{}}}
\subsection{Method \code{help()}}{
Opens the corresponding help page referenced by field \verb{$man}.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Prediction$help()}\if{html}{\out{</div>}}
}

}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Prediction-score"></a>}}
\if{latex}{\out{\hypertarget{method-Prediction-score}{}}}
\subsection{Method \code{score()}}{
Calculates the performance for all provided measures
\link{Task} and \link{Learner} may be \code{NULL} for most measures, but some measures need to extract information
from these objects.
Note that the \code{predict_sets} of the \code{measures} are ignored by this method,
instead all predictions are used.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Prediction$score(
  measures = NULL,
  task = NULL,
  learner = NULL,
  train_set = NULL
)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{measures}}{(\link{Measure} | list of \link{Measure})\cr
Measure(s) to calculate.}

\item{\code{task}}{(\link{Task}).}

\item{\code{learner}}{(\link{Learner}).}

\item{\code{train_set}}{(\code{integer()}).}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
\link{Prediction}.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Prediction-obs_loss"></a>}}
\if{latex}{\out{\hypertarget{method-Prediction-obs_loss}{}}}
\subsection{Method \code{obs_loss()}}{
Calculates the observation-wise loss via the loss function set in the
\link{Measure}'s field \code{obs_loss}.
Returns a \code{data.table()} with the columns \code{row_ids}, \code{truth}, \code{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
\code{NA} values.
Note that some measures such as RMSE, do have an \verb{$obs_loss}, but they require an
additional transformation after aggregation, in this example taking the square-root.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Prediction$obs_loss(measures = NULL)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{measures}}{(\link{Measure} | list of \link{Measure})\cr
Measure(s) to calculate.}
}
\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Prediction-filter"></a>}}
\if{latex}{\out{\hypertarget{method-Prediction-filter}{}}}
\subsection{Method \code{filter()}}{
Filters the \link{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 \link{Prediction}.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Prediction$filter(row_ids)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{row_ids}}{\code{integer()}\cr
Row indices.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
\code{self}, modified.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Prediction-clone"></a>}}
\if{latex}{\out{\hypertarget{method-Prediction-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Prediction$clone(deep = FALSE)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{deep}}{Whether to make a deep clone.}
}
\if{html}{\out{</div>}}
}
}
}
