View source: R/vimpute_registry.R
| register_vimpute_method | R Documentation |
vimpute()vimpute() resolves its method argument through a package-level method
registry. The built-in methods ("ranger", "xgboost", "regularized",
"robust", "gam", "robgam", "restricted") are pre-registered; this function adds
(or, with overwrite = TRUE, replaces) a user-defined method backed by any
pair of mlr3 learners – e.g. regr.rpart/classif.rpart from mlr3
itself, or learners from mlr3extralearners such as lightgbm – without
modifying VIM. After registration the new name can be used anywhere the
built-in method names work: as a global method, in a per-variable method
list, and in method-keyed learner_params.
register_vimpute_method(
name,
learner,
packages = character(),
setup = NULL,
defaults = NULL,
search_space = NULL,
supports_formula = FALSE,
fallback = "robust",
validate = NULL,
overwrite = FALSE
)
name |
Single character string: the method name to be used in
|
learner |
Named list with elements |
packages |
Character vector of packages that must be installed when the
method is used (checked with |
setup |
|
defaults |
|
search_space |
|
supports_formula |
Logical: can the method be used with the |
fallback |
Single method name used when |
validate |
|
overwrite |
Logical: replace an existing registration of the same name? Built-in methods can never be replaced. |
Uncertainty handling for registered methods: PMM (uncert = "pmm", the
default, and pmm = TRUE) and uncert = "midastouch" work with any
method because they only use the method's predictions.
uncert = "normalerror"/"resid" and boot = TRUE derive residuals from
training predictions when the model object does not expose them.
Invisibly, the registered method name.
vimpute_methods(), unregister_vimpute_method(), vimpute()
Other vimpute method registry:
unregister_vimpute_method(),
vimpute_methods()
# a CART method backed by mlr3's rpart learners -- one call, no VIM patching
register_vimpute_method("cart",
learner = list(regr = "regr.rpart", classif = "classif.rpart"),
packages = "rpart")
"cart" %in% vimpute_methods()
data(sleep)
res <- vimpute(sleep[, c("Sleep", "Dream", "Span")], method = "cart",
sequential = FALSE)
unregister_vimpute_method("cart")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.