featureImportance: Feature Importance

Description Usage Arguments

View source: R/featureImportance.R

Description

Measures the feature importance by drop in performance.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
featureImportance(
  object,
  data,
  features = NULL,
  target = NULL,
  n.feat.perm = 50,
  replace.ids = NULL,
  local = FALSE,
  measures,
  predict.fun = NULL,
  importance.fun = function(permuted, unpermuted) return(unpermuted - permuted),
  ...
)

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

[list of character]
A list where each element contains the names of at least one feature for which the permutation importance should be computed. If a list element contains two or more features, they will be permuted block-wise (without breaking the relationship between those features).

target

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

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.

replace.ids

[numeric]
Vector of observation IDs from 'data'. If NULL then permuting the features is used to compute the importance, otherwise the feature values of the IDs are used. Default is NULL.

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.

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).

importance.fun

[function]
Function with signature function(permuted, unpermuted) which defines how permuted and unpermuted are aggregated to a feature importance measure. The function takes the result of measurePerformance as input for permuted and unpermuted. The default NULL internally uses unpermuted - permuted which refers to the drop in performance if the measure is to be maximized (i.e., if higher values of the measure refer to better performance).

...

Not used.


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