cheem_ls {cheem} | R Documentation |
Preprocessing for use in shiny app
Description
Performs the preprocessing steps needs to supply the plot functions
global_view()
and radial_cheem_tour()
used in the shiny app.
The user need to supply the attributions and predictions. For help getting
started with this see vignette("getting-started-with-cheem")
.
Usage
cheem_ls(
x,
y = NULL,
attr_df,
pred = NULL,
class = NULL,
label = "label",
verbose = getOption("verbose")
)
Arguments
x |
The explanatory variables of the model. |
y |
The target variable of the model. |
attr_df |
A data frame or matrix of (n, p) local explanation attributions. |
pred |
A (n, 1) vector, the predictions from the associated model. |
class |
Optional, (n, 1) vector, a variable to group points by.
This can be the same as or different from |
label |
Optionally provide a character label to store reminder text for the type of model and local explanation used. Defaults to "label". |
verbose |
Logical, if start time and run duration should be printed. Defaults to getOption("verbose"). |
Value
A list of data.frames needed for the shiny
application.
See Also
global_view()
radial_cheem_tour()
radial_cheem_tour()
Other cheem preprocessing:
subset_cheem()
Examples
library(cheem)
## Classification setup
X <- spinifex::penguins_na.rm[, 1:4]
Y <- spinifex::penguins_na.rm$species
clas <- spinifex::penguins_na.rm$species
## Bring your own attributions and predictions,
## for help review the vignette or package down site;
if(FALSE){
vignette("getting-started-with-cheem")
browseURL("https://nspyrison.github.io/cheem/articles/getting-started-with-cheem.html")
}
## Cheem
peng_chm <- cheem_ls(X, Y, penguin_xgb_shap, penguin_xgb_pred, clas,
label = "Penguins, xgb, shapviz")
## Save for use with shiny app (expects an rds file)
if(FALSE){ ## Don't accidentally save.
saveRDS(peng_chm, "./chm_peng_xgb_shapviz.rds")
run_app() ## Select the saved rds file from the data dropdown.
}
## Cheem visuals
if(interactive()){
prim <- 1
comp <- 2
global_view(peng_chm, primary_obs = prim, comparison_obs = comp)
bas <- sug_basis(penguin_xgb_shap, prim, comp)
mv <- sug_manip_var(penguin_xgb_shap, primary_obs = prim, comp)
ggt <- radial_cheem_tour(peng_chm, basis = bas, manip_var = mv)
animate_plotly(ggt)
}
## Regression example
library(cheem)
## Regression setup
dat <- amesHousing2018_NorthAmes
X <- dat[, 1:9]
Y <- dat$SalePrice
clas <- dat$SubclassMS
#' ## Bring your own attributions and predictions,
## for help review the vignette or package down site;
if(FALSE){
vignette("getting-started-with-cheem")
browseURL("https://nspyrison.github.io/cheem/articles/getting-started-with-cheem.html")
}
## Cheem list
ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas,
label = "North Ames, RF, treeshap")
## Save for use with shiny app (expects an rds file)
if(FALSE){ ## Don't accidentally save.
saveRDS(ames_rf_chm, "./chm_NAmes_rf_tshap.rds")
run_app() ## Select the saved rds file from the data drop down.
}
## Cheem visuals
if(interactive()){
prim <- 1
comp <- 2
global_view(ames_rf_chm, primary_obs = prim, comparison_obs = comp)
bas <- sug_basis(ames_rf_shap, prim, comp)
mv <- sug_manip_var(ames_rf_shap, primary_obs = prim, comp)
ggt <- radial_cheem_tour(ames_rf_chm, basis = bas, manip_var = mv)
animate_plotly(ggt)
}