Skip to contents

Abstract base class for marginal sampling strategies that do not condition on other features. Marginal samplers sample from P(X_S), the marginal distribution of features S, ignoring any dependencies with other features.

Details

This class provides a common interface for different marginal sampling approaches:

  • MarginalPermutationSampler: Shuffles features independently within the dataset

  • MarginalReferenceSampler: Samples complete rows from reference data

Both approaches sample from the marginal distribution P(X_S), but differ in how they preserve or break within-row dependencies:

  • Permutation breaks ALL dependencies (both with target and between features)

  • Reference sampling preserves WITHIN-row dependencies but breaks dependencies with test data

Comparison with ConditionalSampler:

  • MarginalSampler: Samples from \(P(X_S)\) - no conditioning

  • ConditionalSampler: Samples from \(P(X_S | X_{-S})\)- conditions on other features

This base class implements the public $sample() and $sample_newdata() methods, delegating to private .sample_marginal() which subclasses must implement.

Super class

FeatureSampler -> MarginalSampler

Methods

Inherited methods


MarginalSampler$sample()

Sample features from their marginal distribution.

Usage

MarginalSampler$sample(feature, row_ids = NULL)

Arguments

feature

(character()) Feature name(s) to sample.

row_ids

(integer() | NULL) Row IDs from task to use.

Returns

Modified copy with sampled feature(s).


MarginalSampler$sample_newdata()

Sample from external data.

Usage

MarginalSampler$sample_newdata(feature, newdata)

Arguments

feature

(character()) Feature(s) to sample.

newdata

(data.table) External data to use.

Returns

Modified copy with sampled feature(s).


MarginalSampler$clone()

The objects of this class are cloneable with this method.

Usage

MarginalSampler$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.