getImportance {ecotrends}R Documentation

Get variable importance

Description

This function computes the permutation importance of each variable in each model, by shuffling each variable in turn (a given number of times) and computing the root mean squared difference between the actual model predictions and those obtained with the shuffled variable. Values are then normalized to a percentage by dividing each by the sum of all values and multiplying by 100. Note that "importance" is not a straightforward concept and it can be measured in many different ways. Permutation importance is a widely used and effective model-agnostic technique, which provides an intuitive measure of the contribution of each variable, particularly in complex and non-linear models.

Usage

getImportance(
  mods,
  nper = 10,
  verbosity = 2,
  plot = TRUE,
  palette = "Dark2",
  ...
)

Arguments

mods

output of getModels().

nper

integer value (default 10; increase for more accurate but computationally intensive results) indicating the number of permutations for shuffling each variable.

verbosity

integer value indicating the amount of messages to display. The default is 2, for the maximum number of messages available.

plot

logical value specifying whether to produce a line (spaghetti) plot of the mean importance of each variable along the periods. Note that this plot does not reflect the deviations around this mean, and that it may become hard to read if there are many variables or if their importances overlap.

palette

argument to pass to hcl.colors() specifying the colours for the lines (if plot=TRUE). The default is "Dark2"; run hcl.pals() for other options.

...

additional arguments that can be passed to base::plot(), e.g. 'main', 'xlab', 'ylab' or 'las'.

Value

A data frame with the permutation importance (expressed as percentage) of each variable in each model replicate for each period, along with the cross-replicate mean and standard deviation. If plot=TRUE (the default), also a spaghetti plot of mean variable importance per period.

Author(s)

A. Marcia Barbosa

See Also

varImportance in package predicts; bm_VariablesImportance in package biomod2

Examples

# Several data prep steps required.
# See https://github.com/AMBarbosa/ecotrends for a full worked example.

[Package ecotrends version 1.1 Index]