Skip to contents

Calls graphics::hist() and the result is coerced to a distr6::Distribution.

Dictionary

This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():

LearnerDensHistogram$new()
mlr_learners$get("dens.hist")
lrn("dens.hist")

Meta Information

  • Type: "dens"

  • Predict Types: pdf, cdf, distr

  • Feature Types: integer, numeric

  • Properties: -

  • Packages: mlr3 mlr3proba distr6

Super classes

mlr3::Learner -> mlr3proba::LearnerDens -> LearnerDensHistogram

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerDensHistogram$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner
learner = lrn("dens.hist")
print(learner)
#> 
#> ── <LearnerDensHistogram> (dens.hist): Histogram Density Estimator ─────────────
#> • Model: -
#> • Parameters: list()
#> • Packages: mlr3, mlr3proba, and distr6
#> • Predict Types: [pdf], cdf, and distr
#> • Feature Types: integer and numeric
#> • Encapsulation: none (fallback: -)
#> • Properties:
#> • Other settings: use_weights = 'error'

# Define a Task
task = tsk("faithful")

# Create train and test set
ids = partition(task)

# Train the learner on the training ids
learner$train(task, row_ids = ids$train)

print(learner$model)
#> $distr
#> Histogram() 
#> 
#> $hist
#> $breaks
#> [1] 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
#> 
#> $counts
#> [1] 37 31  1  7 18 53 32  3
#> 
#> $density
#> [1] 0.40659341 0.34065934 0.01098901 0.07692308 0.19780220 0.58241758 0.35164835
#> [8] 0.03296703
#> 
#> $mids
#> [1] 1.75 2.25 2.75 3.25 3.75 4.25 4.75 5.25
#> 
#> $xname
#> [1] "dat"
#> 
#> $equidist
#> [1] TRUE
#> 
#> attr(,"class")
#> [1] "histogram"
#> 
#> attr(,"class")
#> [1] "dens.hist"

# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)

# Score the predictions
predictions$score()
#> dens.logloss 
#>     1.170993