Density plots overlaid with ICE curves
g_density_ice.Rd
Create density plot for the data, overlaid with ICE curves at quantiles of the variable(s) of interest.
Arguments
- object
Object of class sculpture (rough, detailed)
- new_data
Data to make quantiles on
- var_name
String specifying which variable to generate ICE
- var_label
String (optional) specifying variable label (x label of the plot)
- qtiles
Quantiles to generate ICE curves
- task
Prediction task type (regression or classification)
- var_names
Vector of strings specifying which variables to generate ICE
- var_labels
Named vector of strings specifying variable labels.
Details
g_density_ice_plot()
creates a density plot for a single variable.
g_density_ice_plot_list()
creates a list of density plots for multiple variables.
These functions should be amenable to any 1st-order model without interaction terms,
however not implemented yet, such as handling predict()
function output
for binary endpoint
Examples
if (FALSE) {
df <- mtcars
df$cyl <- as.factor(df$cyl)
model <- lm(hp ~ ., data = df)
model_predict <- function(x) predict(model, newdata = x)
covariates <- setdiff(colnames(df), "hp")
pm <- sample_marginals(df[covariates], n = 50, seed = 5)
rs <- sculpt_rough(
dat = pm,
model_predict_fun = model_predict,
n_ice = 5,
seed = 1,
verbose = 0
)
g_density_ice_plot(rs, new_data = pm, var_name = "mpg")
g_list <- g_density_ice_plot_list(
rs, new_data = pm, var_names = c("mpg", "cyl", "disp", "drat")
)
grid::grid.draw(gridExtra::arrangeGrob(grobs = g_list))
}