Skip to contents

PFI Class

PFI Class

Details

Calculates Permutation Feature Importance (PFI) scores.

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage

PFI$new(
  task,
  learner,
  measure,
  resampling = NULL,
  features = NULL,
  iters_perm = 1L
)

Arguments

task, learner, measure, resampling, features

Passed to FeatureImportanceLearner for construction.

iters_perm

(integer(1): 1L) Number of permutations to compute for each feature. Permutations are repeated within each resampling fold.


Method compute()

A short description...

Usage

PFI$compute(relation = c("difference", "ratio"), store_backends = TRUE)

Arguments

relation

(character(1)) Calculate "difference" (default) or "ratio" of original scores and scores after permutation

store_backends

(logical(1): TRUE) Passed to mlr3::resample to store backends in resample result. Required for some measures, but may increase memory footprint.


Method clone()

The objects of this class are cloneable with this method.

Usage

PFI$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


library(mlr3)

pfi = PFI$new(
  task = tsk("zoo"),
  learner = lrn("classif.rpart"),
  measure = msr("classif.ce")
)

pfi$compute()
#> Key: <feature>
#>      feature importance
#>       <char>      <num>
#>  1: airborne 0.00000000
#>  2:  aquatic 0.00000000
#>  3: backbone 0.00000000
#>  4: breathes 0.00000000
#>  5:  catsize 0.00000000
#>  6: domestic 0.00000000
#>  7:     eggs 0.00000000
#>  8: feathers 0.14705882
#>  9:     fins 0.08823529
#> 10:     hair 0.00000000
#> 11:     legs 0.00000000
#> 12:     milk 0.47058824
#> 13: predator 0.00000000
#> 14:     tail 0.00000000
#> 15:  toothed 0.00000000
#> 16: venomous 0.00000000