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)
}
Run the code above in your browser using DataLab