# 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
Run the code above in your browser using DataLab