Skip to contents

Implementation of CFI using modular sampling approach

References

Blesch, Kristin, Koenen, Niklas, Kapar, Jan, Golchian, Pegah, Burk, Lukas, Loecher, Markus, Wright, N. M (2025). “Conditional Feature Importance with Generative Modeling Using Adversarial Random Forests.” Proceedings of the AAAI Conference on Artificial Intelligence, 39(15), 15596–15604. doi:10.1609/aaai.v39i15.33712 .

Methods

Inherited methods


Method new()

Creates a new instance of the CFI class

Usage

CFI$new(
  task,
  learner,
  measure,
  resampling = NULL,
  features = NULL,
  relation = "difference",
  iters_perm = 1L,
  sampler = NULL
)

Arguments

task, learner, measure, resampling, features

Passed to PerturbationImportance.

relation

(character(1)) How to relate perturbed scores to originals. Can be overridden in $compute().

iters_perm

(integer(1)) Number of sampling iterations. Can be overridden in $compute().

sampler

(ConditionalSampler) Optional custom sampler. Defaults to instantiationg ARFSampler internally with default parameters.


Method compute()

Compute CFI scores

Usage

CFI$compute(relation = NULL, iters_perm = NULL, store_backends = TRUE)

Arguments

relation

(character(1)) How to relate perturbed scores to originals. If NULL, uses stored value.

iters_perm

(integer(1)) Number of permutation iterations. If NULL, uses stored value.

store_backends

(logical(1)) Whether to store backends


Method clone()

The objects of this class are cloneable with this method.

Usage

CFI$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3)
task = tgen("2dnormals")$generate(n = 100)
cfi = CFI$new(
  task = task,
  learner = lrn("classif.ranger", num.trees = 50, predict_type = "prob"),
  measure = msr("classif.ce")
)
#>  No <ConditionalSampler> provided, using <ARFSampler> with default settings.
#>  No <Resampling> provided, using holdout resampling with default ratio.
cfi$compute()
#> Key: <feature>
#>    feature importance
#>     <char>      <num>
#> 1:      x1 0.12121212
#> 2:      x2 0.09090909