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 |
number.partitions |
The exact number of partitions required.
Either |
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 |
rp.method |
One of |
tree.control |
Control parameters for the RP algorithm. One of |
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