| MarginalPermutationSampler | R Documentation |
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.
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.
xplainfi::FeatureSampler -> xplainfi::MarginalSampler -> MarginalPermutationSampler
new()Creates a new instance of the MarginalPermutationSampler class.
MarginalPermutationSampler$new(task)
task(mlr3::Task) Task to sample from.
clone()The objects of this class are cloneable with this method.
MarginalPermutationSampler$clone(deep = FALSE)
deepWhether to make a deep clone.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.