Impute features by sampling from non-missing training data.


R6Class object inheriting from PipeOpImpute/PipeOp.


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

  • 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 PipeOpImputeSample.

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


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

The $state$model is a named list of training data with missings removed.


The parameters are the parameters inherited from PipeOpImpute.


Uses the sample() function. Features that are entirely NA are imputed as the values given by vector() of their type.


Only methods inherited from PipeOpImpute/PipeOp.

See also


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("imputesample") 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