Skip to contents

Convert object to a PredictionDens.

Usage

as_prediction_dens(x, ...)

# S3 method for class 'PredictionDens'
as_prediction_dens(x, ...)

# S3 method for class 'data.frame'
as_prediction_dens(x, ...)

Arguments

x

(any)
Object to convert.

...

(any)
Additional arguments.

Examples

library(mlr3)
task = tsk("precip")
learner = lrn("dens.hist")
learner$train(task)
p = learner$predict(task)

# convert to a data.table
tab = as.data.table(p)

# convert back to a Prediction
as_prediction_dens(tab)
#> <PredictionDens> for 70 observations:
#>  row_ids         pdf       cdf
#>        1 0.001428571 0.9957143
#>        2 0.007142857 0.9478571
#>        3 0.005714286 0.0400000
#>      ---         ---       ---
#>       68 0.007142857 0.2507143
#>       69 0.012857143 0.1162857
#>       70 0.007142857 0.9800000
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      distr
#>  <Distribution>\n  Public:\n    alias: \n    cdf: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    clone: function (deep = FALSE) \n    confidence: function (alpha = 0.95, sides = "both", median = FALSE) \n    correlation: function () \n    decorators: active binding\n    description: NULL\n    dmax: active binding\n    dmin: active binding\n    getParameterValue: function (id, error = "warn") \n    inf: active binding\n    initialize: function (name = NULL, short_name = NULL, type, support = NULL, \n    iqr: function () \n    kurtosisType: active binding\n    liesInSupport: function (x, all = TRUE, bound = FALSE) \n    liesInType: function (x, all = TRUE, bound = FALSE) \n    median: function (na.rm = NULL, ...) \n    name: Histogram Estimator\n    parameters: function (id = NULL) \n    pdf: function (..., log = FALSE, simplify = TRUE, data = NULL) \n    prec: function () \n    print: function (n = 2, ...) \n    properties: active binding\n    quantile: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    rand: function (n, simplify = TRUE) \n    setParameterValue: function (..., lst = list(...), error = "warn", resolveConflicts = FALSE) \n    short_name: Histogram\n    skewnessType: active binding\n    stdev: function () \n    strprint: function (n = 2) \n    summary: function (full = TRUE, ...) \n    sup: active binding\n    support: active binding\n    symmetry: active binding\n    traits: active binding\n    type: active binding\n    valueSupport: active binding\n    variateForm: active binding\n    workingSupport: function () \n  Private:\n    .cdf: function (x, self = <environment>, ...) \n    .decorators: NULL\n    .isCdf: 1\n    .isPdf: 1\n    .isQuantile: 0\n    .isRand: 0\n    .log: FALSE\n    .parameters: NULL\n    .pdf: function (x, self = <environment>, ...) \n    .properties: list\n    .traits: list\n    .updateDecorators: function (decs) \n    .variates: 1
#>  <Distribution>\n  Public:\n    alias: \n    cdf: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    clone: function (deep = FALSE) \n    confidence: function (alpha = 0.95, sides = "both", median = FALSE) \n    correlation: function () \n    decorators: active binding\n    description: NULL\n    dmax: active binding\n    dmin: active binding\n    getParameterValue: function (id, error = "warn") \n    inf: active binding\n    initialize: function (name = NULL, short_name = NULL, type, support = NULL, \n    iqr: function () \n    kurtosisType: active binding\n    liesInSupport: function (x, all = TRUE, bound = FALSE) \n    liesInType: function (x, all = TRUE, bound = FALSE) \n    median: function (na.rm = NULL, ...) \n    name: Histogram Estimator\n    parameters: function (id = NULL) \n    pdf: function (..., log = FALSE, simplify = TRUE, data = NULL) \n    prec: function () \n    print: function (n = 2, ...) \n    properties: active binding\n    quantile: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    rand: function (n, simplify = TRUE) \n    setParameterValue: function (..., lst = list(...), error = "warn", resolveConflicts = FALSE) \n    short_name: Histogram\n    skewnessType: active binding\n    stdev: function () \n    strprint: function (n = 2) \n    summary: function (full = TRUE, ...) \n    sup: active binding\n    support: active binding\n    symmetry: active binding\n    traits: active binding\n    type: active binding\n    valueSupport: active binding\n    variateForm: active binding\n    workingSupport: function () \n  Private:\n    .cdf: function (x, self = <environment>, ...) \n    .decorators: NULL\n    .isCdf: 1\n    .isPdf: 1\n    .isQuantile: 0\n    .isRand: 0\n    .log: FALSE\n    .parameters: NULL\n    .pdf: function (x, self = <environment>, ...) \n    .properties: list\n    .traits: list\n    .updateDecorators: function (decs) \n    .variates: 1
#>  <Distribution>\n  Public:\n    alias: \n    cdf: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    clone: function (deep = FALSE) \n    confidence: function (alpha = 0.95, sides = "both", median = FALSE) \n    correlation: function () \n    decorators: active binding\n    description: NULL\n    dmax: active binding\n    dmin: active binding\n    getParameterValue: function (id, error = "warn") \n    inf: active binding\n    initialize: function (name = NULL, short_name = NULL, type, support = NULL, \n    iqr: function () \n    kurtosisType: active binding\n    liesInSupport: function (x, all = TRUE, bound = FALSE) \n    liesInType: function (x, all = TRUE, bound = FALSE) \n    median: function (na.rm = NULL, ...) \n    name: Histogram Estimator\n    parameters: function (id = NULL) \n    pdf: function (..., log = FALSE, simplify = TRUE, data = NULL) \n    prec: function () \n    print: function (n = 2, ...) \n    properties: active binding\n    quantile: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    rand: function (n, simplify = TRUE) \n    setParameterValue: function (..., lst = list(...), error = "warn", resolveConflicts = FALSE) \n    short_name: Histogram\n    skewnessType: active binding\n    stdev: function () \n    strprint: function (n = 2) \n    summary: function (full = TRUE, ...) \n    sup: active binding\n    support: active binding\n    symmetry: active binding\n    traits: active binding\n    type: active binding\n    valueSupport: active binding\n    variateForm: active binding\n    workingSupport: function () \n  Private:\n    .cdf: function (x, self = <environment>, ...) \n    .decorators: NULL\n    .isCdf: 1\n    .isPdf: 1\n    .isQuantile: 0\n    .isRand: 0\n    .log: FALSE\n    .parameters: NULL\n    .pdf: function (x, self = <environment>, ...) \n    .properties: list\n    .traits: list\n    .updateDecorators: function (decs) \n    .variates: 1
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ---
#>  <Distribution>\n  Public:\n    alias: \n    cdf: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    clone: function (deep = FALSE) \n    confidence: function (alpha = 0.95, sides = "both", median = FALSE) \n    correlation: function () \n    decorators: active binding\n    description: NULL\n    dmax: active binding\n    dmin: active binding\n    getParameterValue: function (id, error = "warn") \n    inf: active binding\n    initialize: function (name = NULL, short_name = NULL, type, support = NULL, \n    iqr: function () \n    kurtosisType: active binding\n    liesInSupport: function (x, all = TRUE, bound = FALSE) \n    liesInType: function (x, all = TRUE, bound = FALSE) \n    median: function (na.rm = NULL, ...) \n    name: Histogram Estimator\n    parameters: function (id = NULL) \n    pdf: function (..., log = FALSE, simplify = TRUE, data = NULL) \n    prec: function () \n    print: function (n = 2, ...) \n    properties: active binding\n    quantile: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    rand: function (n, simplify = TRUE) \n    setParameterValue: function (..., lst = list(...), error = "warn", resolveConflicts = FALSE) \n    short_name: Histogram\n    skewnessType: active binding\n    stdev: function () \n    strprint: function (n = 2) \n    summary: function (full = TRUE, ...) \n    sup: active binding\n    support: active binding\n    symmetry: active binding\n    traits: active binding\n    type: active binding\n    valueSupport: active binding\n    variateForm: active binding\n    workingSupport: function () \n  Private:\n    .cdf: function (x, self = <environment>, ...) \n    .decorators: NULL\n    .isCdf: 1\n    .isPdf: 1\n    .isQuantile: 0\n    .isRand: 0\n    .log: FALSE\n    .parameters: NULL\n    .pdf: function (x, self = <environment>, ...) \n    .properties: list\n    .traits: list\n    .updateDecorators: function (decs) \n    .variates: 1
#>  <Distribution>\n  Public:\n    alias: \n    cdf: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    clone: function (deep = FALSE) \n    confidence: function (alpha = 0.95, sides = "both", median = FALSE) \n    correlation: function () \n    decorators: active binding\n    description: NULL\n    dmax: active binding\n    dmin: active binding\n    getParameterValue: function (id, error = "warn") \n    inf: active binding\n    initialize: function (name = NULL, short_name = NULL, type, support = NULL, \n    iqr: function () \n    kurtosisType: active binding\n    liesInSupport: function (x, all = TRUE, bound = FALSE) \n    liesInType: function (x, all = TRUE, bound = FALSE) \n    median: function (na.rm = NULL, ...) \n    name: Histogram Estimator\n    parameters: function (id = NULL) \n    pdf: function (..., log = FALSE, simplify = TRUE, data = NULL) \n    prec: function () \n    print: function (n = 2, ...) \n    properties: active binding\n    quantile: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    rand: function (n, simplify = TRUE) \n    setParameterValue: function (..., lst = list(...), error = "warn", resolveConflicts = FALSE) \n    short_name: Histogram\n    skewnessType: active binding\n    stdev: function () \n    strprint: function (n = 2) \n    summary: function (full = TRUE, ...) \n    sup: active binding\n    support: active binding\n    symmetry: active binding\n    traits: active binding\n    type: active binding\n    valueSupport: active binding\n    variateForm: active binding\n    workingSupport: function () \n  Private:\n    .cdf: function (x, self = <environment>, ...) \n    .decorators: NULL\n    .isCdf: 1\n    .isPdf: 1\n    .isQuantile: 0\n    .isRand: 0\n    .log: FALSE\n    .parameters: NULL\n    .pdf: function (x, self = <environment>, ...) \n    .properties: list\n    .traits: list\n    .updateDecorators: function (decs) \n    .variates: 1
#>  <Distribution>\n  Public:\n    alias: \n    cdf: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    clone: function (deep = FALSE) \n    confidence: function (alpha = 0.95, sides = "both", median = FALSE) \n    correlation: function () \n    decorators: active binding\n    description: NULL\n    dmax: active binding\n    dmin: active binding\n    getParameterValue: function (id, error = "warn") \n    inf: active binding\n    initialize: function (name = NULL, short_name = NULL, type, support = NULL, \n    iqr: function () \n    kurtosisType: active binding\n    liesInSupport: function (x, all = TRUE, bound = FALSE) \n    liesInType: function (x, all = TRUE, bound = FALSE) \n    median: function (na.rm = NULL, ...) \n    name: Histogram Estimator\n    parameters: function (id = NULL) \n    pdf: function (..., log = FALSE, simplify = TRUE, data = NULL) \n    prec: function () \n    print: function (n = 2, ...) \n    properties: active binding\n    quantile: function (..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE, \n    rand: function (n, simplify = TRUE) \n    setParameterValue: function (..., lst = list(...), error = "warn", resolveConflicts = FALSE) \n    short_name: Histogram\n    skewnessType: active binding\n    stdev: function () \n    strprint: function (n = 2) \n    summary: function (full = TRUE, ...) \n    sup: active binding\n    support: active binding\n    symmetry: active binding\n    traits: active binding\n    type: active binding\n    valueSupport: active binding\n    variateForm: active binding\n    workingSupport: function () \n  Private:\n    .cdf: function (x, self = <environment>, ...) \n    .decorators: NULL\n    .isCdf: 1\n    .isPdf: 1\n    .isQuantile: 0\n    .isRand: 0\n    .log: FALSE\n    .parameters: NULL\n    .pdf: function (x, self = <environment>, ...) \n    .properties: list\n    .traits: list\n    .updateDecorators: function (decs) \n    .variates: 1