Skip to contents

Computes either LOCO or LOCI depending on whether feature of interest is designated to be left out (LOCO) or left in (LOCI)

Usage

compute_loc(learner, task, train_ids, test_ids, features, measure, direction)

Arguments

learner

(mlr3::Learner)

task

(mlr3::Task)

train_ids, test_ids

(integer()) Row IDs for train- and test splits.

features

(character()) Feature names of interest.

direction

(character(1)) Either "leave-in" or "leave-out".

Value

A data.table with columns feature and <measure$id>_post.

Examples

library(mlr3)

learner = lrn("classif.rpart")
task = tsk("breast_cancer")
measure = msr("classif.ce")
split = partition(task)
train_ids = split$train
test_ids = split$test
# Computing scores for all features
features = task$feature_names

# LOCO
compute_loc(
  learner, 
  task, 
  train_ids = split$train, 
  test_ids = split$test, 
  features, 
  measure, 
  direction = "leave-out"
)
#> Error in compute_loc(learner, task, train_ids = split$train, test_ids = split$test,     features, measure, direction = "leave-out"): could not find function "compute_loc"
# LOCI
compute_loc(
  learner, 
  task, 
  train_ids = split$train, 
  test_ids = split$test, 
  features, 
  measure, 
  direction = "leave-in"
)
#> Error in compute_loc(learner, task, train_ids = split$train, test_ids = split$test,     features, measure, direction = "leave-in"): could not find function "compute_loc"