library(cheem)
## Regression setup
dat <- amesHousing2018_NorthAmes
X <- dat[, 1:9]
Y <- dat$SalePrice
clas <- dat$SubclassMS
## Precomputed predictions and shap attribution
str(ames_rf_pred)
str(ames_rf_shap)
## Cheem
ames_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas,
label = "Ames, random forest, treeshap")
## Save for use with shiny app (expects an rds file)
if(FALSE){ ## Don't accidentally save.
saveRDS(ames_chm, "./chm_ames_rf_tshap.rds")
run_app() ## Select the saved rds file from the data dropdown.
}
## Cheem visuals
if(interactive()){
prim <- 1
comp <- 2
global_view(ames_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_chm, basis = bas, manip_var = mv)
animate_plotly(ggt)
}
Run the code above in your browser using DataLab