Calculate measures of the relative importance of predictors in a model.
varimp(object, method = c("model", "permute"), scale = TRUE, ...)model fit result.
character string specifying the calculation of variable
importance as model-specific ("model") or permutation-base
("permute"). If model-specific importance is specified but not
defined, the permutation-based method will be used instead with its default
values (below). To change the default permutation values, set
method = "permute". Permutation-based variable importance is
defined as the relative change in model predictive performances between
datasets with and without permuted values for the associated variable
(Fisher et al. 2019).
logical indicating whether importance measures should be scaled to range from 0 to 100.
arguments passed to model-specific or permutation-based variable
importance functions. These include the following arguments and default
values for method = "permute".
select = NULLexpression indicating predictor variables for
which to compute variable importance (see subset
for syntax) [default: all].
samples = 1number of times to permute the values of each variable. Larger numbers of samples decrease variability in the estimates at the expense of increased computation time.
size = NULLnumber of observations to sample without replacement at each round of variable permutations [default: all]. Subsampling of observations will decrease computation time.
prop = NULLproportion of observations to sample at each round of permutations [default: all].
metric = NULLmetric function or function name with which to calculate performance. If not specified, the first applicable default metric from the performance functions is used.
compare = c("-", "/")character specifying the relative
change to compute in comparing model predictive performances between
datasets with and without permuted values. The choices are difference
("-") and ratio ("/").
stats = MachineShop::settings("stats.VarImp")function, function name, or vector of these with which to compute summary statistics on the set of variable importance values from the permuted datasets.
na.rm = TRUElogical indicating whether to exclude missing variable importance values from the calculation of summary statistics.
VarImp class object.
Fisher, A., Rudin, C., & Dominici, F. (2019). All models are wrong, but many are useful: Learning a variable's importance by studying an entire class of prediction models simultaneously. Journal of Machine Learning Research, 20, 1-81.
# NOT RUN {
## Requires prior installation of suggested package gbm to run
## Survival response example
library(survival)
gbm_fit <- fit(Surv(time, status) ~ ., data = veteran, model = GBMModel)
(vi <- varimp(gbm_fit))
plot(vi)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab