Learn R Programming

xplainfi (version 1.0.0)

check_groups: Check group specification

Description

Check group specification

Usage

check_groups(groups, all_features)

Value

The input list group, with each element now named.

Arguments

groups

(list) A (named) list of groups

all_features

(character()) All available feature names from the task.

Examples

Run this code
task <- sim_dgp_interactions(n = 100)
task$feature_names

# Intended use
groups1 = list(effects = c("x1", "x2", "x3"), noise = c("noise1", "noise2"))
check_groups(groups1, task$feature_names)

# Names are auto-generated where needed
check_groups(list(a = "x1",  c("x2", "x1")), task$feature_names)

# Examples for cases that throw errors:

# Unexpected features
groups2 = list(effects = c("x1", "foo", "bar", "x1"))
try(check_groups(groups2, task$feature_names))
# Too deeply nested
groups3 = list(effects = c("x1", "x2", "x3"), noise = c("noise1", list(c("noise2"))))
try(check_groups(groups2, task$feature_names))

Run the code above in your browser using DataLab