MarginalPermutationSampler: Marginal Permutation Sampler

MarginalPermutationSamplerR Documentation

Marginal Permutation Sampler

Description

Implements marginal permutation-based sampling for Permutation Feature Importance (PFI). Each specified feature is randomly shuffled (permuted) independently, breaking the relationship between the feature and the target as well as between rows.

Details

The permutation sampler randomly shuffles feature values across observations:

  • Each feature is permuted independently within its column

  • The association between feature values and target values is broken

  • The association between feature values across rows is broken

  • The marginal distribution of each feature is preserved

Important distinction from SAGE's "marginal" approach:

  • MarginalPermutationSampler: Shuffles features independently, breaking row structure

  • MarginalSAGE: Uses reference data but keeps rows intact (features in coalition stay together)

This is the classic approach used in Permutation Feature Importance (PFI) and assumes features are independent.

Super classes

xplainfi::FeatureSampler -> xplainfi::MarginalSampler -> MarginalPermutationSampler

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of the MarginalPermutationSampler class.

Usage
MarginalPermutationSampler$new(task)
Arguments
task

(mlr3::Task) Task to sample from.


Method clone()

The objects of this class are cloneable with this method.

Usage
MarginalPermutationSampler$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

library(mlr3)
task = tgen("2dnormals")$generate(n = 10)
task$data()
sampler = MarginalPermutationSampler$new(task)

# Sample using row_ids from stored task
sampler$sample("x1")

# Or use external data
data = task$data()
sampler$sample_newdata("x1", newdata = data)

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