Impute numerical features by their mean.

Format

R6Class object inheriting from PipeOpImpute/PipeOp.

Construction

PipeOpImputeMean$new(id = "imputemean", param_vals = list())
  • id :: character(1)
    Identifier of resulting object, default "imputemean".

  • param_vals :: named list
    List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction. Default list().

Input and Output Channels

Input and output channels are inherited from PipeOpImputeMean.

The output is the input Task with all affected numeric features missing values imputed by (column-wise) mean.

State

The $state is a named list with the $state elements inherited from PipeOpImpute.

The $state$model is a named list of numeric(1) indicating the mean of the respective feature.

Parameters

The parameters are the parameters inherited from PipeOpImpute.

Internals

Uses the mean() function. Features that are entirely NA are imputed as 0.

Methods

Only methods inherited from PipeOpImpute/PipeOp.

See also

Examples

library("mlr3") task = tsk("pima") task$missings()
#> diabetes age glucose insulin mass pedigree pregnant pressure #> 0 0 5 374 11 0 0 35 #> triceps #> 227
po = po("imputemean") new_task = po$train(list(task = task))[[1]] new_task$missings()
#> diabetes age pedigree pregnant glucose insulin mass pressure #> 0 0 0 0 0 0 0 0 #> triceps #> 0
po$state$model
#> $age #> [1] 33.24089 #> #> $glucose #> [1] 121.6868 #> #> $insulin #> [1] 155.5482 #> #> $mass #> [1] 32.45746 #> #> $pedigree #> [1] 0.4718763 #> #> $pregnant #> [1] 3.845052 #> #> $pressure #> [1] 72.40518 #> #> $triceps #> [1] 29.15342 #>