Skip to contents

Implements marginal sampling for PFI, where the feature of interest is sampled independently of other features

Super class

xplainfi::FeatureSampler -> MarginalSampler

Methods


Method new()

Creates a new instance of the MarginalSampler class

Usage

MarginalSampler$new(task)

Arguments

task

(mlr3::Task) Task to sample from


Method sample()

Sample values for feature(s) by permutation (marginal distribution)

Usage

MarginalSampler$sample(feature, data)

Arguments

feature

(character) Feature name(s) to sample (can be single or multiple)

data

(data.table ) Data to permute the feature(s) in

Returns

Modified copy of the input data with the feature(s) permuted


Method print()

Print sampler

Usage

MarginalSampler$print(...)

Arguments

...

Passed to print()


Method clone()

The objects of this class are cloneable with this method.

Usage

MarginalSampler$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3)
task = tgen("2dnormals")$generate(n = 100)
sampler = MarginalSampler$new(task)
data = task$data()
sampled_data = sampler$sample("x1", data)