Implements conditional sampling using Knockoffs.
Details
The KnockoffSampler samples Knockoffs based on the task data.
This class allows arbitrary knockoff_fun, which also means that no input checking
against supported feature types can be done. Use KnockoffGaussianSampler for the
Gaussian knockoff sampler for numeric features.
Alternative knockoff samplers include knockoff_seq() from the seqknockoff package
available on GitHub: https://github.com/kormama1/seqknockoff.
Knockoffs are related to the ConditionalSampler familty, with key differences:
They do not allow specifying a conditioning_set
References
Watson D, Wright M (2021). “Testing Conditional Independence in Supervised Learning Algorithms.” Machine Learning, 110(8), 2107–2129. doi:10.1007/s10994-021-06030-6 .
Blesch K, Watson D, Wright M (2023). “Conditional Feature Importance for Mixed Data.” AStA Advances in Statistical Analysis, 108(2), 259–278. doi:10.1007/s10182-023-00477-9 .
Super class
xplainfi::FeatureSampler -> KnockoffSampler
Methods
Method new()
Creates a new instance of the KnockoffSampler class.
Usage
KnockoffSampler$new(
task,
knockoff_fun = function(x) knockoff::create.second_order(as.matrix(x)),
iters = 1
)Arguments
task(mlr3::Task) Task to sample from
knockoff_fun(
function) Function used to create knockoff matrix. Default are second-order Gaussian knockoffs (knockoff::create.second_order())iters(
integer(1):1) Number of repetitions theknockoff_funis applied to create multiplex_tildeinstances per observation.
Method sample()
Sample from stored task using knockoff values. Replaces specified feature(s) with their knockoff counterparts from the pre-generated knockoff matrix.
Arguments
feature(
character) Feature(s) to sample.row_ids(
integer()|NULL) Row IDs to use. IfNULL, uses all rows.