Skip to contents

Calls kernels implemented in distr6 and the result is coerced to a distr6::Distribution.

Details

The default bandwidth uses Silverman's rule-of-thumb for Gaussian kernels, however for non-Gaussian kernels it is recommended to use mlr3tuning to tune the bandwidth with cross-validation. Other density learners can be used for automated bandwidth selection. The default kernel is Epanechnikov (chosen to reduce dependencies).

Dictionary

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

LearnerDensKDE$new()
mlr_learners$get("dens.kde")
lrn("dens.kde")

Meta Information

  • Type: "dens"

  • Predict Types: pdf, distr

  • Feature Types: integer, numeric

  • Properties: missings

  • Packages: mlr3 mlr3proba distr6

References

Silverman, W. B (1986). Density Estimation for Statistics and Data Analysis. Chapman & Hall, London.

Super classes

mlr3::Learner -> mlr3proba::LearnerDens -> LearnerDensKDE

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

LearnerDensKDE$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner
learner = lrn("dens.kde")
print(learner)
#> 
#> ── <LearnerDensKDE> (dens.kde): Kernel Density Estimator ───────────────────────
#> • Model: -
#> • Parameters: kernel=Epan, bandwidth=silver
#> • Packages: mlr3, mlr3proba, and distr6
#> • Predict Types: [pdf] and distr
#> • Feature Types: integer and numeric
#> • Encapsulation: none (fallback: -)
#> • Properties: missings
#> • 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)
#> Epan_KDE() 

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

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