Allows imputation of missing feature values through various techniques. Note that you have the possibility to re-impute a data set in the same way as the imputation was performed during training. This especially comes in handy during resampling when one wants to perform the same imputation on the test set as on the training set.
The function impute
performs the imputation on a data set and returns,
alongside with the imputed data set, an “ImputationDesc” object
which can contain “learned” coefficients and helpful data.
It can then be passed together with a new data set to reimpute.
The imputation techniques can be specified for certain features or for feature classes, see function arguments.
You can either provide an arbitrary object, use a built-in imputation method listed under imputations or create one yourself using makeImputeMethod.
impute( obj, target = character(0L), classes = list(), cols = list(), dummy.classes = character(0L), dummy.cols = character(0L), dummy.type = "factor", force.dummies = FALSE, impute.new.levels = TRUE, recode.factor.levels = TRUE )
obj | (data.frame | Task) |
---|---|
target | (character) |
classes | (named list) |
cols | (named list) |
dummy.classes | (character) |
dummy.cols | (character) |
dummy.type | ( |
force.dummies | ( |
impute.new.levels | ( |
recode.factor.levels | ( |
(list)
Imputed data.
ImputationDesc
)Description object.
The description object contains these slots
See argument.
Feature names (column names of data
).
Feature classes (storage type of data
).
Mapping of column names of factor features to their levels, including newly created ones during imputation.
Mapping of column names to imputation functions.
Mapping of column names to imputation functions.
logical(1)
)See argument.
logical(1)
)See argument.
Other impute:
imputations
,
makeImputeMethod()
,
makeImputeWrapper()
,
reimpute()
df = data.frame(x = c(1, 1, NA), y = factor(c("a", "a", "b")), z = 1:3) imputed = impute(df, target = character(0), cols = list(x = 99, y = imputeMode())) print(imputed$data)#> x y z #> 1 1 a 1 #> 2 1 a 2 #> 3 99 b 3#> x y z #> 1 99 a NA