Base class generalizing refit-based variable importance measures.
Default corresponds to leaving out each feature n_repeats times, which
corresponds to LOCO (Leave One Covariate Out).
Public fields
direction(
character(1)) Either "leave-out" or "leave-in".design(
logical()) Feature selection design matrix whereTRUEequals "left in" andFALSE"left out". Columns correspond totask$feature_namesand the number of rows corresponds tolength(features) * n_repeats. The base matrix is created by wvim_design_matrix and then replicatedn_repeatstimes before.instance(
FSelectInstanceBatchSingleCrit) Themlr3fselectfeature selection instance containing also the archive of all evaluations, possible useful for future use. Only stored ifstore_instanceisTRUE.
Methods
Method compute()
Computes leave-out or leave-in feature importance.
wvim_design_matrix(task$feature_names, "leave-out") corresponds to LOCO.
Arguments
store_models, store_backends(
logical(1):TRUE) Whether to store fitted models / data backends, passed to mlr3::resample internally backends in resample result. Required for some measures, but may increase memory footprint.store_instance(
logical(1):FALSE) Whether to store the mlr3fselect::mlr3fselect instance in$instance.
Examples
library(mlr3)
library(mlr3learners)
task <- sim_dgp_correlated(n = 500)
# Group correlated features together, independent features separately
groups <- list(
correlated = c("x1", "x2"),
independent = c("x3", "x4")
)
wvim <- WVIM$new(
task = task,
learner = lrn("regr.ranger", num.trees = 10),
groups = groups
)
#> ℹ No <Measure> provided, using `measure = msr("regr.mse")`
#> ℹ No <Resampling> provided, using `resampling = rsmp("holdout", ratio = 2/3)`
#> (test set size: 167)
wvim$compute()
wvim$importance()
#> Key: <feature>
#> feature importance
#> <char> <num>
#> 1: correlated 4.973365
#> 2: independent 1.020356