RFI: Relative Feature Importance

RFIR Documentation

Relative Feature Importance

Description

RFI generalizes CFI and PFI with arbitrary conditioning sets and samplers.

Super classes

xplainfi::FeatureImportanceMethod -> xplainfi::PerturbationImportance -> RFI

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of the RFI class

Usage
RFI$new(
  task,
  learner,
  measure = NULL,
  resampling = NULL,
  features = NULL,
  groups = NULL,
  conditioning_set = NULL,
  relation = "difference",
  n_repeats = 30L,
  batch_size = NULL,
  sampler = NULL
)
Arguments
task, learner, measure, resampling, features, groups, relation, n_repeats, batch_size

Passed to PerturbationImportance.

conditioning_set

(character()) Set of features to condition on. Can be overridden in ⁠$compute()⁠. Default (character(0)) is equivalent to PFI. In CFI, this would be set to all features except that of interest.

sampler

(ConditionalSampler) Optional custom sampler. Defaults to ConditionalARFSampler.


Method compute()

Compute RFI scores

Usage
RFI$compute(
  conditioning_set = NULL,
  n_repeats = NULL,
  batch_size = NULL,
  store_models = TRUE,
  store_backends = TRUE
)
Arguments
conditioning_set

(character()) Set of features to condition on. If NULL, uses the stored parameter value.

n_repeats

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

batch_size

(integer(1) | NULL: NULL) Maximum number of rows to predict at once. If NULL, uses stored value.

store_models, store_backends

(logical(1): TRUE) Whether to store fitted models / data backends, passed to mlr3::resample internally for the initial fit of the learner. This may be required for certain measures and is recommended to leave enabled unless really necessary.


Method clone()

The objects of this class are cloneable with this method.

Usage
RFI$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

König G, Molnar C, Bischl B, Grosse-Wentrup M (2021). “Relative Feature Importance.” In 2020 25th International Conference on Pattern Recognition (ICPR), 9318–9325. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/ICPR48806.2021.9413090")}.

Examples

library(mlr3)
task = tgen("friedman1")$generate(n = 200)
rfi = RFI$new(
  task = task,
  learner = lrn("regr.rpart"),
  measure = msr("regr.mse"),
  conditioning_set = c("important1"),
  sampler = ConditionalGaussianSampler$new(task),
  n_repeats = 5
)
rfi$compute()
rfi$importance()

xplainfi documentation built on Feb. 27, 2026, 1:08 a.m.