Skip to contents

SAGE with marginal sampling (features are marginalized independently). This is the standard SAGE implementation.

Super classes

xplainfi::FeatureImportanceMethod -> xplainfi::SAGE -> MarginalSAGE

Methods

Inherited methods


Method new()

Creates a new instance of the MarginalSAGE class.

Usage

MarginalSAGE$new(
  task,
  learner,
  measure,
  resampling = NULL,
  features = NULL,
  n_permutations = 10L,
  reference_data = NULL,
  max_reference_size = NULL
)

Arguments

task, learner, measure, resampling, features

Passed to SAGE.

n_permutations

(integer(1)) Number of permutations to sample.

reference_data

(data.table) Optional reference dataset.

max_reference_size

(integer(1)) Maximum size of reference dataset.


Method clone()

The objects of this class are cloneable with this method.

Usage

MarginalSAGE$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3)
task = tgen("friedman1")$generate(n = 100)
sage = MarginalSAGE$new(
  task = task,
  learner = lrn("regr.ranger", num.trees = 50),
  measure = msr("regr.mse"),
  n_permutations = 3L
)
#>  No <Resampling> provided, using holdout resampling with default ratio.
sage$compute()
#> Key: <feature>
#>          feature  importance
#>           <char>       <num>
#>  1:   important1  2.96326057
#>  2:   important2  2.90667497
#>  3:   important3  0.57062042
#>  4:   important4  7.20769278
#>  5:   important5  1.12671607
#>  6: unimportant1 -0.24742440
#>  7: unimportant2  0.20349454
#>  8: unimportant3  0.08402295
#>  9: unimportant4 -0.32247028
#> 10: unimportant5  0.06865530

# Use batching for memory efficiency with large datasets
sage$compute(batch_size = 1000)
#> Key: <feature>
#>          feature  importance
#>           <char>       <num>
#>  1:   important1  2.96326057
#>  2:   important2  2.90667497
#>  3:   important3  0.57062042
#>  4:   important4  7.20769278
#>  5:   important5  1.12671607
#>  6: unimportant1 -0.24742440
#>  7: unimportant2  0.20349454
#>  8: unimportant3  0.08402295
#>  9: unimportant4 -0.32247028
#> 10: unimportant5  0.06865530