# \donttest{
library(distillML)
library(Rforestry)
set.seed(491)
data <- iris
test_ind <- sample(1:nrow(data), nrow(data)%/%5)
train_reg <- data[-test_ind,]
test_reg <- data[test_ind,]
forest <- forestry(x=data[,-1],
y=data[,1])
forest_predictor <- Predictor$new(model = forest, data=train_reg,
y="Sepal.Length", task = "regression")
forest_interpret <- Interpreter$new(predictor = forest_predictor)
# Both initializations of a surrogate class result in the same surrogate model
surrogate.model <- distill(forest_interpret)
surrogate.model <- distill(forest_interpret,
center.mean = TRUE,
features = 1:length(forest_interpret$features),
cv = FALSE,
snap.grid = TRUE,
snap.train = TRUE)
# }
Run the code above in your browser using DataLab