This object wraps the predictions returned by a learner of class LearnerRegr, i.e.
the predicted response and standard error.
Additionally, probability distributions implemented in package distr6 are supported.
See also
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:
Prediction,
PredictionClassif
Super class
mlr3::Prediction -> PredictionRegr
Active bindings
response(
numeric())
Access the stored predicted response.se(
numeric())
Access the stored standard error.quantiles(
matrix())
Matrix of predicted quantiles. Observations are in rows, quantile (in ascending order) in columns.distr(
VectorDistribution)
Access the stored vector distribution. Requires packagedistr6(in repository https://raphaels1.r-universe.dev) .
Methods
Method new()
Creates a new instance of this R6 class.
Usage
PredictionRegr$new(
task = NULL,
row_ids = task$row_ids,
truth = task$truth(),
response = NULL,
se = NULL,
quantiles = NULL,
distr = NULL,
weights = NULL,
check = TRUE,
extra = NULL
)Arguments
task(TaskRegr)
Task, used to extract defaults forrow_idsandtruth.row_ids(
integer())
Row ids of the predicted observations, i.e. the row ids of the test set.truth(
numeric())
True (observed) response.response(
numeric())
Vector of numeric response values. One element for each observation in the test set.se(
numeric())
Numeric vector of predicted standard errors. One element for each observation in the test set.quantiles(
matrix())
Numeric matrix of predicted quantiles. One row per observation, one column per quantile.distr(
VectorDistribution)VectorDistributionfrom package distr6 (in repository https://raphaels1.r-universe.dev). Each individual distribution in the vector represents the random variable 'survival time' for an individual observation.weights(
numeric())
Vector of measure weights for each observation. Should be constructed from theTask'sweights_measurecolumn.check(
logical(1))
IfTRUE, performs some argument checks and predict type conversions.extra(
list())
List of extra data to be stored in the prediction object.
Examples
task = tsk("california_housing")
learner = lrn("regr.featureless", predict_type = "se")
p = learner$train(task)$predict(task)
p$predict_types
#> [1] "response" "se"
head(as.data.table(p))
#> row_ids truth response se
#> <int> <num> <num> <num>
#> 1: 1 452600 206855.8 115395.6
#> 2: 2 358500 206855.8 115395.6
#> 3: 3 352100 206855.8 115395.6
#> 4: 4 341300 206855.8 115395.6
#> 5: 5 342200 206855.8 115395.6
#> 6: 6 269700 206855.8 115395.6