shapleyImportance: Shapley Importance

Description Usage Arguments References

View source: R/shapleyImportance.R

Description

Computes the shapley importance of a feature.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
shapleyImportance(
  object,
  data,
  features,
  target = NULL,
  local = FALSE,
  bound.size = NULL,
  n.feat.perm = 50,
  n.shapley.perm = 120,
  measures,
  predict.fun = NULL,
  value.function = calculateValueFunctionImportance
)

Arguments

object

[any]
Either a WrappedModel or a ResampleResult. You can also provide any other trained model (however, this is experimental and you need to provide an appropriate predict.fun).

data

[data.frame]
The data whose features will be permuted in order to measure their importance. If object is of class ResampleResult, you should use the corresponding data on which the whole resampling was performed. In any other case, you might use some independent test data that was not used to fit the model (although you could also use the train data here).

features

[character]
The feature(s) for which the shapley importance should be computed.

target

[character(1)]
Only needed if object is not of class WrappedModel or ResampleResult. Name of the target feature to be predicted.

local

[logical(1)]
Should the performance (or the feature importance) be computed observation-wise? Note that not all measures support this (e.g. one can not compute the AUC for one observation). The default is FALSE.

bound.size

[numeric(1)]
Bound on the permutation size to compute the Shapley value (see Cohen et al. (2007)).

n.feat.perm

[numeric(1)]
The number of permutations of the feature(s) used to compute the feature importance. The default is 50. If set to NULL, the cartesian product is used.

n.shapley.perm

[numeric(1)]
The number of permutations that should be used for the shapley value (for computational reasons the maximum allowed value is 8192). If n.shapley.perm >= number of all unique permutatios, all unique permutations will be used. Use n.shapley.perm = NULL to use all unique permutations (or the maximum allowed value of 8192) Default is 120.

measures

[Measure | list of Measure | function | list of function]
Performance measure(s) used to measure the model performance. Can also be a named list of function with signature function(y, pred), where y and pred are vectors containing the true and the predicted values of the target.

predict.fun

[function]
Only needed if object is not of class WrappedModel or ResampleResult. The signature must be function(object, newdata) and the function should always return a vector of predictions. The default NULL internally uses predict(object, newdata = newdata).

value.function

[function]
Function that defines the value function which is used to compute the shapley value.

References

Cohen, S., Dror, G., & Ruppin, E. (2007). Feature selection via coalitional game theory. Neural Computation, 19(7), 1939-1961.


giuseppec/featureImportance documentation built on June 1, 2021, 11:04 a.m.