View source: R/mrPdPlotBootstrap.R
mrPdPlotBootstrap | R Documentation |
This function extracts and plots the bootrapped partial dependence functions
calculated by mrBootstrap()
for each response variable.
mrPdPlotBootstrap(
mrIML_obj,
mrBootstrap_obj,
vi_obj = NULL,
target,
global_top_var = 2
)
mrIML_obj |
A list object returned by |
mrBootstrap_obj |
A list object returned by |
vi_obj |
A list object returned by |
target |
The target variable for generating plots. |
global_top_var |
The number of top variables to consider (default: 2). |
A list with two elements:
[[1]]
: A data frame of the partial dependence grid for each response model,
predictor variable, and bootstrap.
[[2]]
: A list of partial dependence plots for each predictor variable in
the target
response model.
library(tidymodels)
data <- MRFcov::Bird.parasites
Y <- data %>%
select(-scale.prop.zos) %>%
dplyr::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
)
mrIML_rf_boot <- mrIML_rf %>%
mrBootstrap(num_bootstrap = 5)
mrIML_rf_PD <- mrPdPlotBootstrap(
mrIML_rf,
mrIML_rf_boot,
target = "Plas",
global_top_var = 4
)
head(mrIML_rf_PD[[1]])
mrIML_rf_PD[[2]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.