came {fmeffects}R Documentation

Computes a partitioning for a ForwardMarginalEffect

Description

This is a wrapper function that creates the correct subclass of Partitioning. It computes feature subspaces for semi-global interpretations of FMEs via recursive partitioning (RP).

Usage

came(
  effects,
  number.partitions = NULL,
  max.sd = Inf,
  rp.method = "ctree",
  tree.control = NULL
)

Arguments

effects

A ForwardMarginalEffect object with FMEs computed.

number.partitions

The exact number of partitions required. Either number.partitions or max.sd can be specified.

max.sd

The maximum standard deviation required in each partition. Among multiple partitionings with this criterion identified, the one with lowest number of partitions is selected. Either number.partitions or max.sd can be specified.

rp.method

One of "ctree" or "rpart". The RP algorithm used for growing the decision tree. Defaults to "ctree".

tree.control

Control parameters for the RP algorithm. One of "ctree.control(...)" or "rpart.control(...)".

Value

Partitioning Object with identified feature subspaces.

References

Scholbeck, C.A., Casalicchio, G., Molnar, C. et al. Marginal effects for non-linear prediction functions. Data Min Knowl Disc (2024). https://doi.org/10.1007/s10618-023-00993-x

Examples

# Train a model and compute FMEs:

library(mlr3verse)
library(ranger)
data(bikes, package = "fmeffects")
task = as_task_regr(x = bikes, id = "bikes", target = "count")
forest = lrn("regr.ranger")$train(task)
effects = fme(model = forest, data = bikes, features = list("temp" = 1), ep.method = "envelope")

# Find a partitioning with exactly 3 subspaces:
subspaces = came(effects, number.partitions = 3)

# Find a partitioning with a maximum standard deviation of 20, use `rpart`:
library(rpart)
subspaces = came(effects, max.sd = 200, rp.method = "rpart")

# Analyze results:
summary(subspaces)
plot(subspaces)

# Extract results:
subspaces$results
subspaces$tree

[Package fmeffects version 0.1.3 Index]