mrFlashlight | R Documentation |
A wrapper function around flashlight::flashlight()
to run multi-response
model-agnostic interpretable machine learning analyses. The output can be
interrogated using the core functionality of flashlight: see
vignette("flashlight", package = "flashlight")
.
mrFlashlight(mrIMLobj, response = "multi", index = 1, predict_function = NULL)
mrIMLobj |
A list object output by |
response |
A character string indicating the type of response:
|
index |
A numeric value used when |
predict_function |
A function specifying a user-defined prediction function (optional). |
A flashlight or multi-flashlight object.
library(tidymodels)
library(flashlight)
data <- MRFcov::Bird.parasites
Y <- data %>%
select(-scale.prop.zos) %>%
select(order(everything()))
X <- data %>%
select(scale.prop.zos)
model_rf <- rand_forest(
trees = 50, # 50 trees are set for brevity. Aim to start with 1000
mode = "classification",
mtry = tune(),
min_n = tune()
) %>%
set_engine("randomForest")
mrIML_rf <- mrIMLpredicts(
X = X,
Y = Y,
X1 = Y,
Model = model_rf,
prop = 0.7,
k = 2,
racing = FALSE
)
fl <- mrFlashlight(
mrIML_rf,
response = "multi",
index = 1
)
# Performance comparison
fl %>%
light_performance(
metrics = list(`ROC AUC` = MetricsWeighted::AUC)
) %>%
plot() +
ylim(0, 1)
# Partial dependence curves
fl %>%
light_profile(data = cbind(X, Y), "scale.prop.zos") %>%
plot()
# Two-way partial dependence
fl %>%
light_profile2d(c("scale.prop.zos", "Plas")) %>%
plot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.