From 16fbce86c71c3715d4d4f0583c8e1f42e0ddd41f Mon Sep 17 00:00:00 2001
From: nspyrison
Date: Wed, 8 Nov 2023 19:26:50 +0000
Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20nspyriso?=
=?UTF-8?q?n/cheem@553984718f0b004ccc5214635808d0102d8136f0=20=F0=9F=9A=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
articles/getting-started-with-cheem.html | 4 +---
news/index.html | 1 +
pkgdown.yml | 2 +-
reference/cheem_ls.html | 7 -------
reference/global_view_df_1layer.html | 13 +------------
reference/rnorm_from.html | 14 +++++++-------
search.json | 2 +-
7 files changed, 12 insertions(+), 31 deletions(-)
diff --git a/articles/getting-started-with-cheem.html b/articles/getting-started-with-cheem.html
index 8091604..a9a1ff5 100644
--- a/articles/getting-started-with-cheem.html
+++ b/articles/getting-started-with-cheem.html
@@ -75,7 +75,7 @@
Nicholas
Spyrison
- 2023-11-07
+ 2023-11-08
Source: vignettes/getting-started-with-cheem.Rmd
getting-started-with-cheem.Rmd
@@ -160,7 +160,6 @@
-
-
label
Optionally provide a character label to store reminder
text for the type of model and local explanation used.
diff --git a/reference/global_view_df_1layer.html b/reference/global_view_df_1layer.html
index a8d23c9..71ad923 100644
--- a/reference/global_view_df_1layer.html
+++ b/reference/global_view_df_1layer.html
@@ -60,12 +60,7 @@
Usage
-
global_view_df_1layer (
- x ,
- class = NULL ,
- basis_type = c ( "pca" , "olda" ) ,
- label = "label"
-)
+
global_view_df_1layer ( x , class = NULL , label = "label" )
On this page
diff --git a/search.json b/search.json
index 1fab181..c7114e8 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"/articles/getting-started-with-cheem.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Getting started with cheem","text":"Non-linear models regularly result accurate prediction linear counterparts. However, number complexity terms make opaque interpretability. ability understand features (variables predictors) influence predictions important wide range audiences. Attempts bring interpretability complex models important aspect eXplainable Artificial Intelligence (XAI). Local explanations one tool used XAI. attempt approximate feature importance vicinity one instance (observation). say give approximation linear terms position one -sample --sample observation. analyst can explore models lead bad predictions can suggest insight issues data suggest models may robust misclassified extreme residuals. analyst may want explore support feature contributions explanations makes sense may completely unreliable. purpose sort analysis conducted interactive graphics analysis R package titled cheem.","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"preprocessing","dir":"Articles","previous_headings":"","what":"Preprocessing","title":"Getting started with cheem","text":"framework broadly applicable model compatible local explanation. illustrate xgboost::xgboost() model (xgb) tree SHAP local explanation shapviz::shapviz(). model attempts predict housing sales price 11 predictors 338 sale events one neighborhood 2018 Ames data. first things need prediction local explanation (embedded space). create xgb model, create predictions, find SHAP values observation. Note choice model, prediction, local explanation (embedding) choice analyst facilitated cheem. Now let’s prepare visualization spaces cheem::cheem_ls() call start analysis.","code":"## Download if not installed if(!require(cheem)) install.packages(\"cheem\", dependencies = TRUE) if(!require(treeshap)) install.packages(\"treeshap\", dependencies = TRUE) if(!require(shapviz)) install.packages(\"shapviz\", dependencies = TRUE) ## Load onto session library(cheem) library(xgboost) library(shapviz) ## Setup X <- amesHousing2018_NorthAmes[, 1:9] Y <- amesHousing2018_NorthAmes$SalePrice clas <- amesHousing2018_NorthAmes$SubclassMS ## Model and predict ames_train <- data.matrix(X) %>% xgb.DMatrix(label = Y) ames_xgb_fit <- xgboost(data = ames_train, max.depth = 3, nrounds = 25) ames_xgb_pred <- predict(ames_xgb_fit, newdata = ames_train) ames_xgb_pred %>% head() ## SHAP values shp <- shapviz(ames_xgb_fit, X_pred = ames_train, X = X) ## Keep just the [n, p] local explanations ames_xgb_shap <- shp$S ames_xgb_shap %>% head() ## Preprocessing for cheem analysis ames_chm <- cheem_ls(X, Y, class = clas, attr_df = ames_xgb_shap, pred = ames_xgb_pred, basis_type = c(\"pca\"), label = \"Ames, xgb, shap\") names(ames_chm)"},{"path":"/articles/getting-started-with-cheem.html","id":"cheem-viewer","dir":"Articles","previous_headings":"","what":"Cheem viewer","title":"Getting started with cheem","text":"extracted tree SHAP, feature importance measure vicinity observation. need identify instance interest explore; linked brushing available global view. vary contributions different features test support explanation radial tour","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"global-view","dir":"Articles","previous_headings":"Cheem viewer","what":"Global view","title":"Getting started with cheem","text":"get complete view lets look approximations data space, attribution space, model fits side--side linked brushing help plotly crosstalk. identified observation large Mahalanobis distance (data space) closest neighbor attribution space. global view want identify primary instance (PI) optionally comparison instance (CI) explore. Misclassified observations high residuals good targets exploration. One point sticks case. Instance 243 (shown *) Gentoo (purple) penguin, model predict Chinstrap penguin. Penguin 169 (shown x) reasonably close correctly predicted Gentoo. practice used linked brushing misclassification information guide search.","code":"prim <- 1 comp <- 17 global_view(ames_chm, primary_obs = prim, comparison_obs = comp, height_px = 240, width_px = 720, as_ggplot = TRUE, color = \"log_maha.data\")"},{"path":"/articles/getting-started-with-cheem.html","id":"radial-tour","dir":"Articles","previous_headings":"Cheem viewer","what":"Radial tour","title":"Getting started with cheem","text":"lot unpack . normalized distribution feature attribution instances shown parallel coordinates lines. selected PI CI shown dashed dotted line respectively. first thing notice attribution PI close ’s (incorrect) prediction Chinstrap (orange) terms bill length (bl) flipper length (fl). terms bill depth body mass (bd bm) like observed species Gentoo (purple). select flipper length feature manipulate. Starting attribution projection, instance already looks like observed Gentoo predicted Chinstrap. However, frame 8, basis full contribution flipper length look like predicted Chinstrap. Looking parallel coordinate lines basis visual can see flipper length large gap PI CI, lets check original variables digest. profile, two features distinguished PI CI. instance nested Chinstrap penguins. makes instance particularly hard random forest model classify decision tree can make partition one value (horizontal vertical lines ).","code":"## Normalized attribution basis of the PI bas <- sug_basis(ames_xgb_shap, rownum = prim) ## Default feature to manipulate: #### the feature with largest separation between PI and CI attribution mv <- sug_manip_var( ames_xgb_shap, primary_obs = prim, comparison_obs = comp) ## Make the radial tour ggt <- radial_cheem_tour( ames_chm, basis = bas, manip_var = mv, primary_obs = prim, comparison_obs = comp, angle = .15) ## Animate it animate_gganimate(ggt, fps = 6) #height = 2, width = 4.5, units = \"in\", res = 150 ## Or as a plotly html widget #animate_plotly(ggt, fps = 6) library(ggplot2) prim <- 1 ggplot(penguins_na.rm, aes(x = bill_length_mm, y = flipper_length_mm, colour = species, shape = species)) + geom_point() + ## Highlight PI, * geom_point(data = penguins_na.rm[prim, ], shape = 8, size = 5, alpha = 0.8) + ## Theme, scaling, color, and labels theme_bw() + theme(aspect.ratio = 1) + scale_color_brewer(palette = \"Dark2\") + labs(y = \"Flipper length [mm]\", x = \"Bill length [mm]\", color = \"Observed species\", shape = \"Observed species\")"},{"path":"/articles/getting-started-with-cheem.html","id":"shiny-application","dir":"Articles","previous_headings":"Cheem viewer","what":"Shiny application","title":"Getting started with cheem","text":"provide interactive shiny application. Interactive features made possible plotly, crosstalk, DT. preprocessed simulated modern datasets explore analysis . Alternatively, bring data saving return cheem_ls() rds file. Follow along example ?cheem_ls.","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Getting started with cheem","text":"Interpretability black-box models important maintain. Local explanation extend interpretability approximating feature importance vicinity one instance. purpose post-hoc analysis local explanations. First explore global, full instance context. explore support local explanation see seems plausible unreliable.","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"other-local-explanations-models","dir":"Articles","previous_headings":"","what":"Other local explanations (& models)","title":"Getting started with cheem","text":"cheem agnostic model local explanation, requires model local explanation. illustrated using random forest predict penguin species. demonstrates using attribution spaces different models.","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"shapviz-xgb-classification","dir":"Articles","previous_headings":"Other local explanations (& models)","what":"shapviz (& xgb classification)","title":"Getting started with cheem","text":"shapviz actively maintained hosted CRAN. compatible H2O, lgb, xgb models. https://github.com/ModelOriented/shapviz","code":"if(!require(shapviz)) install.packages(\"shapviz\") if(!require(xgboost)) install.packages(\"xgboost\") library(shapviz) library(xgboost) set.seed(3653) ## Setup X <- spinifex::penguins_na.rm[, 1:4] Y <- spinifex::penguins_na.rm$species clas <- spinifex::penguins_na.rm$species ## Model and predict peng_train <- data.matrix(X) %>% xgb.DMatrix(label = Y) peng_xgb_fit <- xgboost(data = peng_train, max.depth = 3, nrounds = 25) peng_xgb_pred <- predict(peng_xgb_fit, newdata = peng_train) ## SHAP peng_xgb_shap <- shapviz(peng_xgb_fit, X_pred = peng_train, X = X) ## Keep just the [n, p] local explanations peng_xgb_shap <- peng_xgb_shap$S"},{"path":"/articles/getting-started-with-cheem.html","id":"treeshap-randomforest-regression","dir":"Articles","previous_headings":"Other local explanations (& models)","what":"treeshap (& randomForest regression)","title":"Getting started with cheem","text":"treeshap available CRAN. compatible many tree-based models including gbm, lbm, rf, ranger, xgb models. https://github.com/ModelOriented/treeshap","code":"if(!require(treeshap)) install.packages(\"treeshap\") if(!require(randomForest)) install.packages(\"randomForest\") library(treeshap) library(randomForest) ## Setup X <- spinifex::wine[, -1:2] Y <- spinifex::wine$Alcohol clas <- spinifex::wine$Type ## Fit randomForest::randomForest wine_rf_fit <- randomForest::randomForest( X, Y, ntree = 125, mtry = ifelse(is_discrete(Y), sqrt(ncol(X)), ncol(X) / 3), nodesize = max(ifelse(is_discrete(Y), 1, 5), nrow(X) / 500)) wine_rf_pred <- predict(wine_rf_fit) ## treeshap::treeshap() wine_rf_tshap <- wine_rf_fit %>% treeshap::randomForest.unify(X) %>% treeshap::treeshap(X, interactions = FALSE, verbose = FALSE) ## Keep just the [n, p] local explanations wine_rf_tshap <- wine_rf_tshap$shaps"},{"path":"/articles/getting-started-with-cheem.html","id":"dalex-lm-regression","dir":"Articles","previous_headings":"Other local explanations (& models)","what":"DALEX (& LM regression)","title":"Getting started with cheem","text":"DALEX popular versatile XAI package available CRAN. compatible many models, uses original, slower variant SHAP local explanation. Expect long run times sizable data complex models. https://ema.drwhy.ai/shapley.html#SHAPRcode","code":"if(!require(DALEX)) install.packages(\"DALEX\") library(DALEX) ## Setup X <- dragons[, c(1:4, 6)] Y <- dragons$life_length clas <- dragons$colour ## Model and predict drag_lm_fit <- lm(data = data.frame(Y, X), Y ~ .) drag_lm_pred <- predict(drag_lm_fit) ## SHAP via DALEX, versatile but slow drag_lm_exp <- explain(drag_lm_fit, data = X, y = Y, label = \"Dragons, LM, SHAP\") ## DALEX::predict_parts_shap is flexible, but slow and one row at a time drag_lm_shap <- matrix(NA, nrow(X), ncol(X)) sapply(1:nrow(X), function(i){ pps <- predict_parts_shap(drag_lm_exp, new_observation = X[i, ]) ## Keep just the [n, p] local explanations drag_lm_shap[i, ] <<- tapply( pps$contribution, pps$variable, mean, na.rm = TRUE) %>% as.vector() }) drag_lm_shap <- as.data.frame(drag_lm_shap)"},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Nicholas Spyrison. Author, maintainer.","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Spyrison N (2023). cheem: Interactively Explore Local Explanations Radial Tour. R package version 0.4.0.0, https://nspyrison.github.io/cheem/, https://github.com/nspyrison/cheem/.","code":"@Manual{, title = {cheem: Interactively Explore Local Explanations with the Radial Tour}, author = {Nicholas Spyrison}, year = {2023}, note = {R package version 0.4.0.0, https://nspyrison.github.io/cheem/}, url = {https://github.com/nspyrison/cheem/}, }"},{"path":"/index.html","id":"cheem","dir":"","previous_headings":"","what":"Interactively Explore Local Explanations with the Radial Tour","title":"Interactively Explore Local Explanations with the Radial Tour","text":"Interactively explore data- local explanation- spaces residual side--side. explore support selected observation’s local explanation radial tour.","code":""},{"path":"/index.html","id":"context","dir":"","previous_headings":"","what":"Context","title":"Interactively Explore Local Explanations with the Radial Tour","text":"Local explanations approximate linear variable importance non-linear model vicinity one instance(observation). , point-measure variable’s importance model particular location data-space. cheem extracts local explanation every observation dataset, given model. Given model, extract local explanation every observation data set. View data- explanation-spaces side--side interactive shiny application. explored selected point comparison using explanation 1D projection basis. radial tour explores structure explanation projection.","code":""},{"path":"/index.html","id":"getting-started","dir":"","previous_headings":"","what":"Getting started","title":"Interactively Explore Local Explanations with the Radial Tour","text":"","code":"## Download the package install.packages(\"cheem\", dependencies = TRUE) ## May need to restart the R session so RSudio has the correct file structure rstudioapi::restartSession() ## Load cheem into session library(cheem) ## Try the app run_app() ## Processing your data; follow the examples in cheem_ls() ?cheem_ls"},{"path":"/index.html","id":"global-view","dir":"","previous_headings":"","what":"Global view","title":"Interactively Explore Local Explanations with the Radial Tour","text":"global view shows data-, attribution-spaces, residual plot side--side linked brushing hover tooltip. exploring global view, identify primary comparison observation compare. classification task, typically misclassified point selected compared nearby correctly classified one. regression, can compare point extreme residual nearby point accurately predicted.","code":""},{"path":"/index.html","id":"radial-cheem-tour","dir":"","previous_headings":"","what":"Radial cheem tour","title":"Interactively Explore Local Explanations with the Radial Tour","text":"attribution primary observation becomes 1D basis tour. variable largest difference primary comparison point’s bases selected manipulation variable. variable whose contribution change drives change projection basis. , testing local explanation. testing variable sensitivity structure identified local explanation, can better evaluate good explanation ; sensitive prediction change variable contributions.","code":""},{"path":"/index.html","id":"original-application","dir":"","previous_headings":"","what":"Original application","title":"Interactively Explore Local Explanations with the Radial Tour","text":"started looking model-agnostic local explanation tree SHAP applied random forests. made choice concern runtime (treeshap uses alternative algorithm reduced computational complexity thus achieves much faster run time extracting full SHAP matrix preprocessing step). namesake, Cheem, stems original application tree-based models DALEX ecosystem; Cheem fictional race tree-based humanoids consistency Dr. /Dr. theme.","code":""},{"path":"/index.html","id":"sources","dir":"","previous_headings":"","what":"Sources","title":"Interactively Explore Local Explanations with the Radial Tour","text":"Explanatory Model Analysis (ebook) DALEX CRAN page spinifex CRAN page","code":""},{"path":"/index.html","id":"package-build-workflow","dir":"","previous_headings":"","what":"Package build workflow","title":"Interactively Explore Local Explanations with the Radial Tour","text":"devtools::document() ## documentation changes pkgdown::build_site() ## packagedown site changes (documentation, vignettes, readme) message(“Manually : Build tab > Install Restart”) ## build package rhub::check_for_cran() ## check package devtools::submit_cran() ## Submit CRAN","code":""},{"path":"/reference/amesHousing2018.html","id":null,"dir":"Reference","previous_headings":"","what":"Ames housing data 2018 — amesHousing2018","title":"Ames housing data 2018 — amesHousing2018","text":"House sales prices Ames, Iowa, USA 2006 2010. complete numeric observations remain.","code":""},{"path":"/reference/amesHousing2018.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ames housing data 2018 — amesHousing2018","text":"","code":"amesHousing2018 amesHousing2018_raw amesHousing2018_NorthAmes"},{"path":"/reference/amesHousing2018.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Ames housing data 2018 — amesHousing2018","text":"complete data.frame 2291 rows 18 numeric variables, SalesPrice, response variable, 3 class variables object class data.frame 2930 rows 82 columns. object class data.frame 338 rows 11 columns.","code":""},{"path":"/reference/amesHousing2018.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Ames housing data 2018 — amesHousing2018","text":"De Cock, D. (2011). \"Ames, Iowa: Alternative Boston Housing Data End Semester Regression Project,\" Journal Statistics Education, Volume 19, Number 3. http://jse.amstat.org/v19n3/decock/DataDocumentation.txt http://jse.amstat.org/v19n3/decock.pdf Kaggle, Ames Housing Dataset https://www.kaggle.com/prevek18/ames-housing-dataset Replicating dataset:","code":"if(FALSE) ## Don't accidentally open the URL. browseURL(\"https://www.kaggle.com/prevek18/ames-housing-dataset\") ames <- readr::read_csv(\"./buildignore/AmesHousing.csv\") amesHousing2018_raw <- data.frame(ames) ## save(amesHousing2018_raw, file = \"./data/amesHousing2018_raw.rda\") ## Complete rows and numeric variables ames1 <- ames[, unlist(lapply(ames, is.numeric))] ames1$Bathrooms <- ames1$`Full Bath` + ames1$`Half Bath` ames1 <- ames1[, c(1:18, 38, 19:37)] col_idx <- !(colnames(ames1) %in% c( \"Order\", \"Mas Vnr Area\", \"BsmtFin SF 1\", \"BsmtFin SF 2\", \"Bsmt Full Bath\", \"Bsmt Half Bath\", \"Fireplaces\", \"Wood Deck SF\", \"Open Porch SF\", \"Enclosed Porch\", \"3Ssn Porch\", \"Screen Porch\", \"Pool Area\", \"Misc Val\", \"2nd Flr SF\", \"Low Qual Fin SF\", \"Full Bath\", \"Half Bath\", \"Kitchen AbvGr\")) row_idx <- !is.na(ames1$\"Garage Yr Blt\") & !is.na(ames1$\"Lot Frontage\") & !is.na(ames1$\"Bsmt Unf SF\") & !is.na(ames1$\"Total Bsmt SF\") ames2 <- as.data.frame(ames1[row_idx, col_idx]) ## Looking for character classes to keep: ames_char <- ames[, unlist(lapply(ames, is.character))] ames_clas <- as.data.frame(lapply(ames_char, factor))[, -1] ames_clasint <- data.frame(lapply(ames_clas, as.integer)) col_idx_char <- which(names(ames_clas) %in% c(\"MS.SubClass\", \"MS.Zoning\", \"Neighborhood\")) classes <- ames_clas[row_idx, col_idx_char] amesHousing2018 <- cbind(ames2, classes) names(amesHousing2018) <- c( \"LotFrontage\", \"LotArea\",\"OverallQual\", \"OverallCond\", \"YearBuild\", \"YearRemod\", \"BsmtUnfArea\", \"TotBsmtArea\", \"1stFlrArea\", \"LivingArea\", \"Bathrms\", \"Bedrms\", \"TotRms\", \"GarageYrBlt\", \"GarageCars\", \"GarageArea\", \"MoSold\", \"YrSold\", \"SalePrice\", \"SubclassMS\", \"ZoneMS\", \"Neighborhd\") ## save(amesHousing2018, file = \"./data/amesHousing2018.rda\") .thin_col_idx <- names(amesHousing2018) %in% c( \"LotArea\", \"OverallQual\", \"YearBuild\", \"LivingArea\", \"Bathrms\", \"Bedrms\", \"TotRms\", \"GarageYrBlt\", \"GarageArea\", \"SalePrice\", \"SubclassMS\") amesHousing2018_thin <- amesHousing2018[, .thin_col_idx] ## subset to north ames, and only 5 largest subclasses r_idx <- amesHousing2018$Neighborhd == \"NAmes\" & amesHousing2018$SubclassMS %in% c(\"020\", \"050\", \"080\", \"090\", \"060\") amesHousing2018_NorthAmes <- amesHousing2018_thin[r_idx, ] amesHousing2018_NorthAmes$SubclassMS <- factor( amesHousing2018_NorthAmes$SubclassMS, unique(amesHousing2018_NorthAmes$SubclassMS)) if(F){ ## Don't accidentally save save(amesHousing2018_NorthAmes, file = \"./data/amesHousing2018_NorthAmes.rda\")"},{"path":"/reference/amesHousing2018.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Ames housing data 2018 — amesHousing2018","text":"amesHousing2018 Complete data.frame, n = 2291, 18 numeric variable (including 2 temporal: MoSold, YrSold ), response variable SalePrice, 3 class factors. amesHousing2018_NorthAmes simplified subsample, just North Ames (largest neighborhood). Complete data.frame, n = 338, 9 numeric variables, response variable SalePrice, 1 class factor SubclassMS, zoning subclass. amesHousing2018_raw Original data Kaggle, 2930 rows 82 variables. Sparse rows (639) sparse/defaulted columns (64) removed. data dictionary provided Kaggle, amesHousing2018 variables inferred : LotFrontage, Length front (street facing) side lot yards (0.914m) LotArea, Area lot square yards (0.836m^2) OverallQual, Overall quality (house?), integer (1, 10) OverallCond, Overall condition (lot?), integer (1, 10) YearBuild, year house originally built BsmtUnfArea, Unfinished basement area, square yards (0.836m^2) TotBsmtArea, Total basement area, square yards (0.836m^2) 1stFlrArea, First (ground) floor living area square yards (0.836m^2) LivingArea, Total living area square yards (0.836m^2) Bathrms, number bathrooms Bedrms, number bedrooms TotRms, total number rooms GarageYrBlt, year garage build GarageCars, number car spaces garage GarageArea, area garage square yards (0.836m^2) MoSold, number month house sale YrSold, number year house sale SalePrice, sale house USD (year sale?) SubclassMS, Factor subclass construction zone, 16 levels SubclassMS, Factor major class construction zone, 7 levels Neighborhd, Factor neighborhood Ames, IA, 28 levels","code":""},{"path":"/reference/amesHousing2018.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Ames housing data 2018 — amesHousing2018","text":"","code":"library(cheem) ## Regression setup: dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## Cheem list ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas, label = \"North Ames, RF, SHAP\") ## Cheem visuals if(interactive()){ prim <- 1 comp <- 2 global_view(ames_rf_chm, primary_obs = prim, comparison_obs = comp) bas <- sug_basis(ames_rf_chm, prim, comp) mv <- sug_manip_var(ames_rf_chm, primary_obs = prim, comp) ggt <- radial_cheem_tour(ames_rf_chm, basis = bas, manip_var = mv) animate_plotly(ggt) } ## 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. }"},{"path":"/reference/ames_rf_pred.html","id":null,"dir":"Reference","previous_headings":"","what":"Ames random forest model predictions and shap values — ames_rf_pred","title":"Ames random forest model predictions and shap values — ames_rf_pred","text":"Predictions treeshap attribution random forest model North Ames house sales data regressing Sales Price house lot variables.","code":""},{"path":"/reference/ames_rf_pred.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ames random forest model predictions and shap values — ames_rf_pred","text":"","code":"ames_rf_pred ames_rf_shap"},{"path":"/reference/ames_rf_pred.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Ames random forest model predictions and shap values — ames_rf_pred","text":"ames_rf_pred n=338 length vector prediction random forest model predicting numeric House Sales North Ames. ames_rf_shap (338 x 9) data frame treeshap SHAP attribution random forest model observation. Replicating object class data.frame 338 rows 9 columns.","code":"library(cheem) library(randomForest) library(treeshap) set.seed(135) ## Regression setup dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## Model and treeSHAP ames_rf_fit <- randomForest::randomForest( X, Y, ntree = 125, mtry = ifelse(is_discrete(Y), sqrt(ncol(X)), ncol(X) / 3), nodesize = max(ifelse(is_discrete(Y), 1, 5), nrow(X) / 500)) ames_rf_pred <- predict(ames_rf_fit, X) ames_rf_shap <- treeshap::treeshap( treeshap::randomForest.unify(ames_rf_fit, X), X, FALSE, FALSE) ames_rf_shap <- ames_rf_shap$shaps if(F){ ## Don't accidentally save save(ames_rf_pred, file = \"./data/ames_rf_pred.rda\") save(ames_rf_shap, file = \"./data/ames_rf_shap.rda\") #usethis::use_data(ames_rf_pred) #usethis::use_data(ames_rf_shap) }"},{"path":"/reference/ames_rf_pred.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Ames random forest model predictions and shap values — ames_rf_pred","text":"","code":"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) #> Named num [1:338] 203193 116048 167320 223589 139029 ... #> - attr(*, \"names\")= chr [1:338] \"1\" \"2\" \"3\" \"4\" ... str(ames_rf_shap) #> 'data.frame':\t338 obs. of 9 variables: #> $ LotArea : num 27231 -374 14749 1687 -1036 ... #> $ OverallQual: num 6828 -5011 6182 22641 -3156 ... #> $ YearBuild : num 1881 294 -438 4182 2677 ... #> $ LivingArea : num 13490 -16765 4160 28335 -3640 ... #> $ Bathrms : num -824 -1310 1621 10436 -996 ... #> $ Bedrms : num 528 -1363 360 744 672 ... #> $ TotRms : num 1866 -3193 124 5314 1135 ... #> $ GarageYrBlt: num 2847 -937 -559 791 1462 ... #> $ GarageArea : num 5312 672 -2915 5423 -2125 ... ## 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) }"},{"path":"/reference/as_logical_index.html","id":null,"dir":"Reference","previous_headings":"","what":"Assure a full length logical index — as_logical_index","title":"Assure a full length logical index — as_logical_index","text":"Suggests alpha opacity plot function number observation.","code":""},{"path":"/reference/as_logical_index.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assure a full length logical index — as_logical_index","text":"","code":"as_logical_index(index, n)"},{"path":"/reference/as_logical_index.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assure a full length logical index — as_logical_index","text":"index vector, typically numeric row index data coerce logical index. n Single numeric, number rows data use replicate return length.","code":""},{"path":"/reference/as_logical_index.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assure a full length logical index — as_logical_index","text":"logical index length n.","code":""},{"path":[]},{"path":"/reference/as_logical_index.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assure a full length logical index — as_logical_index","text":"","code":"library(cheem) ## Coerce a numeric index to logical as_logical_index(c(1, 4:10, 15), nrow(mtcars)) #> [1] TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE #> [13] FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE #> [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE ## Logical indexs are unchanged as_logical_index(mtcars$mpg > 30, nrow(mtcars)) #> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE #> [13] FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE #> [25] FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE"},{"path":"/reference/cheem.html","id":null,"dir":"Reference","previous_headings":"","what":"cheem — cheem","title":"cheem — cheem","text":"Consider arbitrary black-box model. Local explanations class point-measures variable importance model one location explanatory variables. package cheem extracts local attribution observations first creates 2D approximated space comparing data- attribution-spaces. primary comparison observation selected attribution primary used 1D basis manual tour. tour changes contribution variable deviates expected value. viewing positions primary comparison points, analyst can scrutinize explanation identify variable attribution leading misclassification large residual.","code":""},{"path":"/reference/cheem.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"cheem — cheem","text":"GitHub: https://github.com/nspyrison/cheem","code":""},{"path":[]},{"path":"/reference/cheem.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"cheem — cheem","text":"Maintainer: Nicholas Spyrison spyrison@gmail.com (ORCID)","code":""},{"path":"/reference/cheem_ls.html","id":null,"dir":"Reference","previous_headings":"","what":"Preprocessing for use in shiny app — cheem_ls","title":"Preprocessing for use in shiny app — cheem_ls","text":"Performs preprocessing steps needs supply plot functions global_view() radial_cheem_tour() used shiny app. user need supply attributions predictions. help getting started see vignette(\"getting-started--cheem\").","code":""},{"path":"/reference/cheem_ls.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Preprocessing for use in shiny app — cheem_ls","text":"","code":"cheem_ls( x, y = NULL, attr_df, pred = NULL, class = NULL, basis_type = c(\"pca\", \"olda\"), label = \"label\", verbose = getOption(\"verbose\") )"},{"path":"/reference/cheem_ls.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Preprocessing for use in shiny app — cheem_ls","text":"x explanatory variables model. y target variable model. attr_df data frame matrix (n, p) local explanation attributions. pred (n, 1) vector, predictions associated model. class Optional, (n, 1) vector, variable group points . can different y, target variable. basis_type type basis used approximate data attribution space . Defaults \"pca\". Expects \"pca\" \"olda\" (requires class). label Optionally provide character label store reminder text type model local explanation used. Defaults \"label\". verbose Logical, start time run duration printed. Defaults getOption(\"verbose\").","code":""},{"path":"/reference/cheem_ls.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Preprocessing for use in shiny app — cheem_ls","text":"list data.frames needed shiny application.","code":""},{"path":[]},{"path":"/reference/cheem_ls.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Preprocessing for use in shiny app — cheem_ls","text":"","code":"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) }"},{"path":"/reference/chocolates.html","id":null,"dir":"Reference","previous_headings":"","what":"Chocolates dataset — chocolates","title":"Chocolates dataset — chocolates","text":"chocolates data compiled students Iowa State University STAT503 (circa 2015) taught Dianne Cook. Nutrition label information chocolates listed manufacturer websites. numbers normalized equivalent 100g serving. Units measurement listed variable name.","code":""},{"path":"/reference/chocolates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Chocolates dataset — chocolates","text":"","code":"chocolates"},{"path":"/reference/chocolates.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Chocolates dataset — chocolates","text":"complete data.frame 88 observations 10 numeric variables, name chocolate, manufacturer, country, type chocolate. Name, name chocolate MFR, chocolate manufacturer Country, country manufacturer incorporated. Type, type chocolate according website, either 'Dark' 'Milk\" Calories, number calories per 100 grams CalFat, calories fat per 100 grams TotFat_g, grams total fat per 100 grams SatFat_g, grams saturated fat per 100 grams Chol_mg, milligrams cholesterol per 100 grams Na_mg, milligrams sodium (salt) per 100 grams Carbs_g, grams carbohydrates per 100 grams Fiber_g, grams fiber per 100 grams Sugars_g, grams sugar per 100 grams Protein_g, grams sugar per 100 grams","code":""},{"path":"/reference/chocolates.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Chocolates dataset — chocolates","text":"Monash University, Introduction Machine Learning course https://iml.numbat.space/ Replicating dataset:","code":"if(FALSE) ## Don't accidentally open the URL. browseURL(\"https://iml.numbat.space/\") ## Accessed Jan 2022 chocolates <- readr::read_csv(\"https://iml.numbat.space/data/chocolates.csv\") chocolates <- data.frame(chocolates) chocolates[, 2] <- factor(chocolates[, 2]) chocolates[, 3] <- factor(chocolates[, 3]) chocolates[, 4] <- factor(chocolates[, 4]) if(F){ ## Don't accidentally save save(chocolates, file = \"./data/chocolates.rda\")"},{"path":"/reference/chocolates.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Chocolates dataset — chocolates","text":"","code":"library(cheem) ## Classification setup X <- chocolates[, 5:14] Y <- chocolates$Type clas <- chocolates$Type ## Cheem choc_chm <- cheem_ls(X, Y, chocolates_svm_shap, chocolates_svm_pred, clas, label = \"Chocolates, LM, shap\") ## Save for use with shiny app (expects an rds file) if(FALSE){ ## Don't accidentally save. saveRDS(choc_chm, \"./chm_chocolates_svm_shap.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) }"},{"path":"/reference/chocolates_svm_pred.html","id":null,"dir":"Reference","previous_headings":"","what":"Chocolate svm model predictions and shap values — chocolates_svm_pred","title":"Chocolate svm model predictions and shap values — chocolates_svm_pred","text":"Predictions DALEX shap attribution svm model Chocolate data classifying type chocolate (light/dark).","code":""},{"path":"/reference/chocolates_svm_pred.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Chocolate svm model predictions and shap values — chocolates_svm_pred","text":"","code":"chocolates_svm_pred chocolates_svm_shap"},{"path":"/reference/chocolates_svm_pred.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Chocolate svm model predictions and shap values — chocolates_svm_pred","text":"chocolate_svm_pred n=88 length vector prediction svm model predicting number factor level species penguin. chocolate_svm_shap (88 x 10) data frame DALEX SHAP attribution svm model observation. Replicating object class data.frame 88 rows 10 columns.","code":"library(cheem) library(e1071) library(DALEX) set.seed(135) ## Classification setup X <- chocolates[, 5:14] Y <- chocolates$Type clas <- chocolates$Type ## Model and predict choc_svm_fit <- svm( formula = Y ~ ., data = data.frame(Y, X), type = 'C-classification', kernel = 'linear', probability = TRUE) chocolates_svm_pred <- predict(choc_svm_fit, data.frame(Y, X)) ## SHAP via DALEX, versatile but slow choc_svm_exp <- explain(choc_svm_fit, data = X, y = Y, label = \"Chocolates, svm\") ## Note that cheem expects a full [n, p] attribution space ## Shap takes about ~30-40 sec for me chocolates_svm_shap <- matrix(NA, nrow(X), ncol(X)) ## init a df of the same structure sapply(1:nrow(X), function(i){ pps <- predict_parts_shap(choc_svm_exp, new_observation = X[i, ]) ## Keep just the [n, p] local explanations chocolates_svm_shap[i, ] <<- tapply( pps$contribution, pps$variable, mean, na.rm = TRUE) %>% as.vector() }) chocolates_svm_shap <- as.data.frame(chocolates_svm_shap) if(F){ ## Don't accidentally save save(chocolates_svm_pred, file = \"./data/chocolates_svm_pred.rda\") save(chocolates_svm_shap, file = \"./data/chocolates_svm_shap.rda\") #usethis::use_data(chocolates_svm_pred) #usethis::use_data(chocolates_svm_shap) }"},{"path":"/reference/chocolates_svm_pred.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Chocolate svm model predictions and shap values — chocolates_svm_pred","text":"","code":"library(cheem) ## Classification setup X <- chocolates[, 5:14] Y <- chocolates$Type clas <- chocolates$Type ## Precomputed predictions and shap attribution str(chocolates_svm_pred) #> Factor w/ 2 levels \"Dark\",\"Milk\": 1 1 1 1 1 1 1 1 2 1 ... #> - attr(*, \"names\")= chr [1:88] \"1\" \"2\" \"3\" \"4\" ... str(chocolates_svm_shap) #> 'data.frame':\t88 obs. of 10 variables: #> $ V1 : num -0.03852 -0.05926 0.00136 -0.02551 -0.01845 ... #> $ V2 : num -0.005681 0.003371 -0.000133 0.000113 0.004603 ... #> $ V3 : num 0.01161 0.00343 -0.00449 0.0062 0.00262 ... #> $ V4 : num -0.0156 -0.0021 -0.0257 -0.0195 -0.0222 ... #> $ V5 : num -0.106 -0.112 -0.168 -0.258 -0.251 ... #> $ V6 : num -0.0573 -0.0513 -0.0797 0.0294 0.0565 ... #> $ V7 : num 0.014471 0.012275 -0.000944 0.039095 0.039942 ... #> $ V8 : num -0.01986 -0.03739 -0.00627 -0.00754 -0.02157 ... #> $ V9 : num -0.0735 -0.0265 0.016 -0.0373 -0.0275 ... #> $ V10: num -0.0396 -0.0596 0.0114 -0.0295 -0.0322 ... ## Cheem choc_chm <- cheem_ls(X, Y, chocolates_svm_shap, chocolates_svm_pred, clas, label = \"Chocolates, SVM, shap\") ## Save for use with shiny app (expects an rds file) if(FALSE){ ## Don't accidentally save. saveRDS(choc_chm, \"./cmh_chocolates_svm_shap.rds\") run_app() ## Select the saved rds file from the data dropdown. } ## Cheem visuals if(interactive()){ prim <- 1 comp <- 2 global_view(choc_chm, primary_obs = prim, comparison_obs = comp) bas <- sug_basis(chocolates_svm_shap, prim, comp) mv <- sug_manip_var(chocolates_svm_shap, primary_obs = prim, comp) ggt <- radial_cheem_tour(choc_chm, basis = bas, manip_var = mv) animate_plotly(ggt) }"},{"path":"/reference/color_scale_of.html","id":null,"dir":"Reference","previous_headings":"","what":"Suggest a color and fill scale. — color_scale_of","title":"Suggest a color and fill scale. — color_scale_of","text":"Whether vector diverges value, returns logical. Used help default scale_color ggplot2.","code":""},{"path":"/reference/color_scale_of.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Suggest a color and fill scale. — color_scale_of","text":"","code":"color_scale_of(x, mid_pt = 0, limits = NULL, ...)"},{"path":"/reference/color_scale_of.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Suggest a color and fill scale. — color_scale_of","text":"x vector scale color . mid_pt single number checking divergence . Defaults 0. limits vector min max values scale. Useful setting absolute range, (-1, 1) attribution/y correlation point. Points outside limits show default grey. Defaults NULL; range x. ... Optional arguments passed ggplot2::continuous_scale ggplot2::discrete_scale.","code":""},{"path":"/reference/color_scale_of.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Suggest a color and fill scale. — color_scale_of","text":"list containing scale_color, scale_fill; suggested color/fill scale ggplot.","code":""},{"path":[]},{"path":"/reference/color_scale_of.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Suggest a color and fill scale. — color_scale_of","text":"","code":"library(cheem) library(ggplot2) g <- ggplot(mtcars, aes(disp, mpg)) ## Discrete g + geom_point(aes(color = factor(vs))) + color_scale_of(mtcars$vs) ## Sequential increasing g + geom_point(aes(color = mpg)) + color_scale_of(mtcars$mpg) ## Dummy sequential decr g + geom_point(aes(color = -1 *mpg)) + color_scale_of(-1 * mtcars$mpg) ## Dummy diverging g + geom_point(aes(color = mpg - median(mpg))) + color_scale_of(mtcars$mpg - median(mtcars$mpg)) ## Dummy limits g + geom_point(aes(color = mpg - median(mpg))) + color_scale_of(mtcars$mpg - median(mtcars$mpg), limits = c(-5, 5))"},{"path":"/reference/contains_nonnumeric.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if a vector contains non-numeric character — contains_nonnumeric","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"Returns logical, whether vector contains non-numeric characters. Typically used test row names hold non-index information.","code":""},{"path":"/reference/contains_nonnumeric.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"","code":"contains_nonnumeric(x)"},{"path":"/reference/contains_nonnumeric.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"x vector tested existence non-numeric characters.","code":""},{"path":"/reference/contains_nonnumeric.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"Logical, whether x contains non-numeric characters.","code":""},{"path":[]},{"path":"/reference/contains_nonnumeric.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"","code":"library(cheem) contains_nonnumeric(mtcars$mpg) #> [1] FALSE contains_nonnumeric(rownames(mtcars)) ## Meaningful info to use in tooltip #> [1] TRUE contains_nonnumeric(rownames(cars)) ## Assume no meaningful info to use in tooltip #> [1] FALSE"},{"path":"/reference/devMessage.html","id":null,"dir":"Reference","previous_headings":"","what":"Development message — devMessage","title":"Development message — devMessage","text":"Send message 4th chunk package version 9000.","code":""},{"path":"/reference/devMessage.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Development message — devMessage","text":"","code":"devMessage(text)"},{"path":"/reference/devMessage.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Development message — devMessage","text":"text character string message() package version 9000.","code":""},{"path":"/reference/global_view.html","id":null,"dir":"Reference","previous_headings":"","what":"Linked plotly display, global view of data and attribution space. — global_view","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"cheem_ls() list, create linked plotly global data- attribution- spaces. Typically consumed directly shiny app.","code":""},{"path":"/reference/global_view.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"","code":"global_view( cheem_ls, primary_obs = NULL, comparison_obs = NULL, color = c(\"default\", \"residual\", \"log_maha.data\", \"cor_attr_proj.y\"), height_px = 480, width_px = 1440, as_ggplot = FALSE )"},{"path":"/reference/global_view.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"cheem_ls return cheem_ls(), list data frames. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. Defaults NULL, highlighting applied. comparison_obs rownumber comparison observation. Point highlighted dotted line. Defaults NULL, highlighting applied. color name column cheem_ls$global_view_df map color. Expects c(\"default\", \"residual\", \"log_maha.data\", \"cor_attr_proj.y\"). Defaults \"default\"; predicted_class classification, dummy class regression. height_px height pixels returned plotly plot. Defaults 480, nothing as_ggplot TRUE. width_px width pixels returned plotly plot. Defaults 1440, nothing as_ggplot TRUE. as_ggplot Logical, TRUE returns plots passed plotly functions.","code":""},{"path":"/reference/global_view.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"plotly plot, interactive html widget global view, first two components basis data- attribution- spaces.","code":""},{"path":[]},{"path":"/reference/global_view.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"","code":"library(cheem) ## Regression setup: dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## global_view() ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas, label = \"North Ames, RF, SHAP\") if(interactive()){ global_view(ames_rf_chm, as_ggplot = TRUE) ## early return of ggplot global_view(ames_rf_chm) ## uses ggplot facets %>% plotly ## Different color mappings, especially for regression global_view(ames_rf_chm, color = \"residual\") global_view(ames_rf_chm, color = \"log_maha.data\") global_view(ames_rf_chm, color = \"cor_attr_proj.y\") } ## Also consumed by: ?run_app()"},{"path":"/reference/global_view_df_1layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","title":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","text":"Internal function consumed cheem workflow. Produces plot data.frame 1 layer. consumed downstream cheem_ls.","code":""},{"path":"/reference/global_view_df_1layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","text":"","code":"global_view_df_1layer( x, class = NULL, basis_type = c(\"pca\", \"olda\"), label = \"label\" )"},{"path":"/reference/global_view_df_1layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","text":"x explanatory variables model. class Optional, (n, 1) vector, variable group points . can different y, target variable. basis_type type basis used approximate data attribution space . Defaults \"pca\". Expects \"pca\" \"olda\" (requires class). label Optionally provide character label store reminder text type model local explanation used. Defaults \"label\".","code":""},{"path":"/reference/global_view_df_1layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","text":"data.frame, global linked plotly display.","code":""},{"path":"/reference/global_view_legwork.html","id":null,"dir":"Reference","previous_headings":"","what":"The legwork behind the scenes for the global view — global_view_legwork","title":"The legwork behind the scenes for the global view — global_view_legwork","text":"meant end user. internal legwork function keep repeating global_view code.","code":""},{"path":"/reference/global_view_legwork.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The legwork behind the scenes for the global view — global_view_legwork","text":"","code":"global_view_legwork( cheem_ls, primary_obs = NULL, comparison_obs = NULL, color = c(\"default\", \"residual\", \"log_maha.data\", \"cor_attr_proj.y\") )"},{"path":"/reference/global_view_legwork.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"The legwork behind the scenes for the global view — global_view_legwork","text":"cheem_ls return cheem_ls(), list data frames. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. Defaults NULL, highlighting applied. comparison_obs rownumber comparison observation. Point highlighted dotted line. Defaults NULL, highlighting applied. color name column cheem_ls$global_view_df map color. Expects c(\"default\", \"residual\", \"log_maha.data\", \"cor_attr_proj.y\"). Defaults \"default\"; predicted_class classification, dummy class regression.","code":""},{"path":"/reference/global_view_legwork.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"The legwork behind the scenes for the global view — global_view_legwork","text":"ggplot2 object, waiting rendered global_view global_view_subplots.","code":""},{"path":[]},{"path":"/reference/ifDev.html","id":null,"dir":"Reference","previous_headings":"","what":"Evaluate if development — ifDev","title":"Evaluate if development — ifDev","text":"Evaluate expression 4th chunk package version 9000.","code":""},{"path":"/reference/ifDev.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Evaluate if development — ifDev","text":"","code":"ifDev(expr)"},{"path":"/reference/ifDev.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Evaluate if development — ifDev","text":"expr character string message() package version 9000.","code":""},{"path":"/reference/is_discrete.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if a vector is discrete — is_discrete","title":"Check if a vector is discrete — is_discrete","text":"Whether vector discrete variable, returns logical. Typically used Y variable model.","code":""},{"path":"/reference/is_discrete.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if a vector is discrete — is_discrete","text":"","code":"is_discrete(x, na.rm = TRUE)"},{"path":"/reference/is_discrete.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if a vector is discrete — is_discrete","text":"x vector check discreteness . na.rm Whether remove NA values testing discreteness. Defaults TRUE.","code":""},{"path":"/reference/is_discrete.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check if a vector is discrete — is_discrete","text":"Logical, whether x discrete variable.","code":""},{"path":[]},{"path":"/reference/is_discrete.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Check if a vector is discrete — is_discrete","text":"","code":"library(cheem) is_discrete(mtcars$mpg) ## Numeric column, with more than 25 unique values. #> [1] FALSE is_discrete(mtcars$cyl) ## Numeric column, labeled as discrete, because less than 25 unique values #> [1] TRUE is_discrete(letters) ## Characters and factors labeled discrete. #> [1] TRUE"},{"path":"/reference/is_diverging.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if a vector diverges a value — is_diverging","title":"Check if a vector diverges a value — is_diverging","text":"Whether vector diverges value, returns logical. Used help default scale_color ggplot2.","code":""},{"path":"/reference/is_diverging.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if a vector diverges a value — is_diverging","text":"","code":"is_diverging(x, mid_pt = 0)"},{"path":"/reference/is_diverging.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if a vector diverges a value — is_diverging","text":"x vector check divergence . mid_pt single number checking divergence . Defaults 0.","code":""},{"path":"/reference/is_diverging.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check if a vector diverges a value — is_diverging","text":"Logical, whether x diverges mid_pt.","code":""},{"path":[]},{"path":"/reference/is_diverging.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Check if a vector diverges a value — is_diverging","text":"","code":"library(cheem) is_diverging(-10:10) #> [1] TRUE is_diverging(-10:-5) #> [1] FALSE is_diverging(mtcars$mpg, 25) #> [1] TRUE is_diverging(mtcars$mpg, 40) #> [1] FALSE"},{"path":"/reference/linear_tform.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear function to help set alpha opacity — linear_tform","title":"Linear function to help set alpha opacity — linear_tform","text":"Suggests alpha opacity plot function number observation.","code":""},{"path":"/reference/linear_tform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear function to help set alpha opacity — linear_tform","text":"","code":"linear_tform(n, appox_max_n = 5000, ceiling = 1, floor = 0.3)"},{"path":"/reference/linear_tform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear function to help set alpha opacity — linear_tform","text":"n Number observations plot. appox_max_n number observation reach floor opacity. ceiling highest number returned. Defaults 1. floor lowest number returned. Defaults 0.3.","code":""},{"path":"/reference/linear_tform.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear function to help set alpha opacity — linear_tform","text":"scalar numeric, suggested value set alpha opacity.","code":""},{"path":[]},{"path":"/reference/linear_tform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear function to help set alpha opacity — linear_tform","text":"","code":"library(cheem) ## Suggest an opacity to use in plotting: (my_alpha <- linear_tform(nrow(spinifex::penguins_na.rm))) #> [1] 0.95338 ## Visualize x <- 1:2000 plot(x, sapply(x, linear_tform), col = \"blue\")"},{"path":"/reference/logistic_tform.html","id":null,"dir":"Reference","previous_headings":"","what":"Logistic function to help set alpha opacity — logistic_tform","title":"Logistic function to help set alpha opacity — logistic_tform","text":"Suggests alpha opacity plot function number observation.","code":""},{"path":"/reference/logistic_tform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logistic function to help set alpha opacity — logistic_tform","text":"","code":"logistic_tform(n, mid_pt = 600, k_attenuation = 5, ceiling = 1, floor = 0.3)"},{"path":"/reference/logistic_tform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logistic function to help set alpha opacity — logistic_tform","text":"n Number observations plot. mid_pt Inflection point logistic curve. Defaults 600. k_attenuation steepness transition, larger sharper transition. Quite sensitive defaults 5. ceiling highest number returned. Defaults 1. floor lowest number returned. Defaults 0.3.","code":""},{"path":"/reference/logistic_tform.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logistic function to help set alpha opacity — logistic_tform","text":"scalar numeric, suggested value set alpha opacity.","code":""},{"path":[]},{"path":"/reference/logistic_tform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Logistic function to help set alpha opacity — logistic_tform","text":"","code":"library(cheem) ## Suggest an opacity to use in plotting: (my_alpha <- logistic_tform(nrow(spinifex::penguins_na.rm))) #> [1] 0.8541665 ## Visualize x <- 1:2000 plot(x, logistic_tform(x), col = \"blue\")"},{"path":"/reference/model_performance.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract higher level model performance statistics — model_performance","title":"Extract higher level model performance statistics — model_performance","text":"Internal function, used downstream cheem_ls.","code":""},{"path":"/reference/model_performance.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract higher level model performance statistics — model_performance","text":"","code":"model_performance(y, pred, label = \"label\")"},{"path":"/reference/model_performance.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract higher level model performance statistics — model_performance","text":"y Observed response, required ranger models. pred (n, 1) vector predicted values observation. Typically obtainable stats::predict(). Exact syntax arguments may change across model types. label Optionally provide character label store reminder text type model local explanation used. Defaults \"label\".","code":""},{"path":"/reference/model_performance.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract higher level model performance statistics — model_performance","text":"data.frame model performance statistics.","code":""},{"path":"/reference/penguin_xgb_pred.html","id":null,"dir":"Reference","previous_headings":"","what":"Penguins xgb model predictions and shap values — penguin_xgb_pred","title":"Penguins xgb model predictions and shap values — penguin_xgb_pred","text":"Predictions shapviz attribution xgb model Penguin data classifying penguin species.","code":""},{"path":"/reference/penguin_xgb_pred.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Penguins xgb model predictions and shap values — penguin_xgb_pred","text":"","code":"penguin_xgb_pred penguin_xgb_shap"},{"path":"/reference/penguin_xgb_pred.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Penguins xgb model predictions and shap values — penguin_xgb_pred","text":"penguin_xgb_pred n=333 length vector prediction xgb model predicting number factor level species penguin. penguin_xgb_shap (333 x 4) data frame shapviz SHAP attribution xgb model observation. Replicating object class matrix (inherits array) 333 rows 4 columns.","code":"library(cheem) library(xgboost) library(shapviz) set.seed(135) ## Classification setup X <- spinifex::penguins_na.rm[, 1:4] Y <- spinifex::penguins_na.rm$species clas <- spinifex::penguins_na.rm$species ## Model and predict peng_train <- data.matrix(X) %>% xgb.DMatrix(label = Y) peng_xgb_fit <- xgboost(data = peng_train, max.depth = 3, nrounds = 5) penguin_xgb_pred <- predict(peng_xgb_fit, newdata = peng_train) ## shapviz penguin_xgb_shap <- shapviz(peng_xgb_fit, X_pred = peng_train, X = X) penguin_xgb_shap <- penguin_xgb_shap$S if(F){ ## Don't accidentally save save(penguin_xgb_pred, file = \"./data/penguin_xgb_pred.rda\") save(penguin_xgb_shap, file = \"./data/penguin_xgb_shap.rda\") #usethis::use_data(penguin_xgb_pred) #usethis::use_data(penguin_xgb_shap) }"},{"path":"/reference/penguin_xgb_pred.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Penguins xgb model predictions and shap values — penguin_xgb_pred","text":"","code":"library(cheem) ## Classification setup X <- spinifex::penguins_na.rm[, 1:4] Y <- spinifex::penguins_na.rm$species clas <- spinifex::penguins_na.rm$species ## Precomputed predictions and shap attribtion str(penguin_xgb_pred) #> num [1:333] 0.923 0.923 0.923 0.923 0.923 ... str(penguin_xgb_shap) #> num [1:333, 1:4] -0.242 -0.206 -0.242 -0.242 -0.226 ... #> - attr(*, \"dimnames\")=List of 2 #> ..$ : NULL #> ..$ : chr [1:4] \"bill_length_mm\" \"bill_depth_mm\" \"flipper_length_mm\" \"body_mass_g\" ## 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) }"},{"path":"/reference/problem_type.html","id":null,"dir":"Reference","previous_headings":"","what":"The type of model for a given Y variable — problem_type","title":"The type of model for a given Y variable — problem_type","text":"Whether Y \"classification\", \"regression\" ill-defined problem. Returns character: \"classification\", \"regression\", error strange classes. Minor redundancy is_discrete, though explicit. useful DALEX::explain(type) also expects \"classification\" \"regression\".","code":""},{"path":"/reference/problem_type.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The type of model for a given Y variable — problem_type","text":"","code":"problem_type(y)"},{"path":"/reference/problem_type.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"The type of model for a given Y variable — problem_type","text":"y Response variable modeled","code":""},{"path":"/reference/problem_type.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"The type of model for a given Y variable — problem_type","text":"Character either c(\"classification\", \"regression\") specifying assumed model task based discreteness y.","code":""},{"path":[]},{"path":"/reference/problem_type.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"The type of model for a given Y variable — problem_type","text":"","code":"library(cheem) problem_type(mtcars$mpg) ## Numeric, many values #> [1] \"regression\" problem_type(mtcars$cyl) ## Numeric column, labeled as discrete, because less than 25 unique values #> [1] \"classification\" problem_type(letters) ## Character to classification #> [1] \"classification\" problem_type(factor(letters)) ## Factor to classification #> [1] \"classification\""},{"path":"/reference/proto_basis1d_distribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"spinifex proto_*-like function, adds distribution orthonormalized row values specified local explanation attr_df. draw basis bars; use conjunction proto_basis1d().","code":""},{"path":"/reference/proto_basis1d_distribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"","code":"proto_basis1d_distribution( attr_df, primary_obs = NULL, comparison_obs = NULL, position = c(\"top1d\", \"floor1d\", \"bottom1d\", \"off\"), group_by = as.factor(FALSE), pcp_shape = c(3, 142, 124), do_add_pcp_segments = TRUE, inc_var_nms = NULL, row_index = NULL )"},{"path":"/reference/proto_basis1d_distribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"attr_df data frame, attributions local explanation. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. Defaults NULL, highlighting. comparison_obs rownumber comparison observation. Point highlighted dotted line. Defaults NULL, highlighting. position position basis, one : c(\"top1d\", \"floor1d\", \"bottom1d\", \"\"). Defaults \"top1d\"; basis density curves. group_by Vector group densities . Originally predicted class. pcp_shape number shape character add. Expects 3, 142, 124, '+', '|' plotly, '|' gganimate, respectively. Defaults 3, '+' either output. do_add_pcp_segments Logical, whether add add faint parallel coordinate lines 1D basis. Defaults TRUE. inc_var_nms character vector, names variables keep. Defaults NULL, variables kept. row_index numeric logical vector, index rows keep. Defaults NULL, rows kept.","code":""},{"path":"/reference/proto_basis1d_distribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"ggplot object distribution local explanation's attributions.","code":""},{"path":[]},{"path":"/reference/proto_basis1d_distribution.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"","code":"library(cheem) library(spinifex) #> Loading required package: tourr #> -------------------------------------------------------- #> spinifex --- version 0.3.6 #> Please share bugs, suggestions, and feature requests at: #> https://github.com/nspyrison/spinifex/issues/ #> -------------------------------------------------------- ## Regression setup dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## Basis, manipulation var, manual tour path, & predictions to fix to y-axis bas <- sug_basis(ames_rf_shap, 1) mv <- sug_manip_var(ames_rf_shap, 1, 2) mt_path <- manual_tour(bas, mv) ## Also consumed by: ?radial_cheem_tour() ## Compose and animate the tour ggt <- ggtour(mt_path, scale_sd(X), angle = .3) + append_fixed_y(fixed_y = scale_sd(Y)) + proto_point(list(color = clas, shape = clas)) + proto_basis1d_distribution( attr_df = ames_rf_shap, primary_obs = 1, comparison_obs = 2, position = \"top1d\", group_by = clas) + proto_basis1d(position = \"bottom1d\") + proto_origin() if(interactive()){ animate_plotly(ggt) }"},{"path":"/reference/radial_cheem_tour.html","id":null,"dir":"Reference","previous_headings":"","what":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"Create linked plotlyof global data- attribution- spaces. Typically consumed directly shiny app.","code":""},{"path":"/reference/radial_cheem_tour.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"","code":"radial_cheem_tour( cheem_ls, basis, manip_var, primary_obs = NULL, comparison_obs = NULL, do_add_pcp_segments = TRUE, pcp_shape = c(3, 142, 124), angle = 0.15, row_index = NULL, inc_var_nms = NULL, do_center_frame = TRUE, do_add_residual = FALSE )"},{"path":"/reference/radial_cheem_tour.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"cheem_ls return cheem_ls(), list data frames. basis 1D projection basis, typically return sug_basis(). manip_var , number manipulation variable. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. Defaults NULL, primary observation highlighted. comparison_obs rownumber comparison observation. Point highlighted dotted line. Defaults NULL, comparison observation highlighted. do_add_pcp_segments Logical, whether add parallel coordinate line segments basis display. pcp_shape number shape character add. Expects 3, 142, 124, '+', '|' plotly, '|' gganimate, respectively. Defaults 3, '+' either output. angle step size interpolated frames, radians. Defaults .15. row_index Numeric index selected observations. Defaults TRUE; 1:n. inc_var_nms vector names variables include projection. do_center_frame Whether scale standard deviations away mean within frame . Defaults TRUE, helping keep animation centered. do_add_residual Whether add facet fixed y residual. may cause issues animation. Defaults FALSE.","code":""},{"path":"/reference/radial_cheem_tour.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"ggtour (ggplot2 object frame info) animation frames radial tour manipulating contribution selected tour. Animated spinifex::animate_* functions.","code":""},{"path":[]},{"path":"/reference/radial_cheem_tour.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"","code":"library(cheem) ## Regression setup: dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## radial_cheem_tour() ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas, label = \"North Ames, RF, SHAP\") bas <- sug_basis(ames_rf_shap, 1) mv <- sug_manip_var(ames_rf_shap, 1, 2) ggt <- radial_cheem_tour(ames_rf_chm, basis = bas, manip_var = mv) if(interactive()){ ## As a plotly html widget spinifex::animate_plotly(ggt) ## As a gganimation spinifex::animate_gganimate(ggt, render = gganimate::av_renderer()) } ## Also used in: ?run_app()"},{"path":"/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. magrittr %>%","code":""},{"path":"/reference/rnorm_from.html","id":null,"dir":"Reference","previous_headings":"","what":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"Creates new observation data given specific means shapes. typically applied cluster subset data. ie draw cluster '', assign cluster 'b'.","code":""},{"path":"/reference/rnorm_from.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"","code":"rnorm_from( data, n_obs = 1, var_coeff = 1, method = c(\"pearson\", \"kendall\", \"spearman\") )"},{"path":"/reference/rnorm_from.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"data data.frame matrix sample . n_obs Number new observations draw. Defaults 1. var_coeff Variance coefficient, closer 0 make points near median, 1 makes points away median. Defaults 1. method method covariance matrix. Expects \"person\" (continuous numeric), \"kendall\" \"spearman\" (latter two ranked based ordinal).","code":""},{"path":"/reference/rnorm_from.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"data.frame, sampled observations given means covariance data based column names kept.","code":""},{"path":[]},{"path":"/reference/rnorm_from.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"","code":"library(cheem) sub <- mtcars[mtcars$cyl == 6, ] ## Draw 3 new observations in the shape of 6 cylinder vehicles, with reduced variance. rnorm_from(data = sub, n_obs = 3, var_coeff = .5) #> mpg cyl disp hp drat wt qsec vs #> 1 19.78306 6.000001 177.8682 104.4534 3.270509 3.333161 19.11867 1.31563966 #> 2 19.75139 6.000002 155.8263 117.0648 3.911951 3.103370 17.57296 0.84168517 #> 3 20.10663 5.999998 141.3895 123.7779 5.580033 2.721980 15.81320 -0.04755403 #> am gear carb #> 1 -0.3156397 3.694493 2.899315 #> 2 0.1583117 4.341102 4.812502 #> 3 1.0475575 4.801690 6.956150"},{"path":"/reference/run_app.html","id":null,"dir":"Reference","previous_headings":"","what":"Runs a shiny app demonstrating manual tours — run_app","title":"Runs a shiny app demonstrating manual tours — run_app","text":"Runs local shiny app demonstrates manual tour comparable traditional techniques static projections multivariate data sets.","code":""},{"path":"/reference/run_app.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Runs a shiny app demonstrating manual tours — run_app","text":"","code":"run_app(app_nm = \"cheem\", ...)"},{"path":"/reference/run_app.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Runs a shiny app demonstrating manual tours — run_app","text":"app_nm Name shiny app run. Expects \"cheem_initial\". ... arguments passed shiny::runApp(). display.mode = \"showcase\".","code":""},{"path":"/reference/run_app.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Runs a shiny app demonstrating manual tours — run_app","text":"Runs locally hosted shiny app.","code":""},{"path":[]},{"path":"/reference/run_app.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Runs a shiny app demonstrating manual tours — run_app","text":"","code":"## Only run this example in interactive R sessions if(interactive()){ ## Runs the app run_app(\"cheem\") ## Run with app code displayed run_app(app_nm = \"cheem\", display.mode = \"showcase\") }"},{"path":"/reference/subset_cheem.html","id":null,"dir":"Reference","previous_headings":"","what":"Subset a cheem list — subset_cheem","title":"Subset a cheem list — subset_cheem","text":"Given numerical index rownumbers original data, subset correct elements cheem list.","code":""},{"path":"/reference/subset_cheem.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subset a cheem list — subset_cheem","text":"","code":"subset_cheem(cheem_ls, rownumbers = 1:500)"},{"path":"/reference/subset_cheem.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subset a cheem list — subset_cheem","text":"cheem_ls return cheem_ls() call. rownumbers vector numeric index rownumbers keep. use logical index, pass (), eg. idx <- (mtcars$mpg > 30).","code":""},{"path":"/reference/subset_cheem.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subset a cheem list — subset_cheem","text":"subset supplied cheem_ls.","code":""},{"path":[]},{"path":"/reference/subset_cheem.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subset a cheem list — subset_cheem","text":"","code":"library(cheem) ## Classification setup X <- spinifex::penguins_na.rm[, 1:4] Y <- spinifex::penguins_na.rm$species clas <- spinifex::penguins_na.rm$species ## Cheem peng_chm <- cheem_ls(X, Y, penguin_xgb_shap, penguin_xgb_pred, clas, label = \"Penguins, xgb, shapviz\") lapply(peng_chm, NROW) #> $type #> [1] 1 #> #> $model_performance #> [1] 1 #> #> $attr_df #> [1] 333 #> #> $global_view_df #> [1] 999 #> #> $global_view_basis_ls #> [1] 2 #> #> $decode_df #> [1] 333 #> ## subset a cheem list num_idx <- which(spinifex::penguins_na.rm$flipper_length_mm > 185) peng_chm_sub <- subset_cheem(peng_chm, num_idx) lapply(peng_chm_sub, NROW) #> $type #> [1] 1 #> #> $model_performance #> [1] 1 #> #> $attr_df #> [1] 294 #> #> $global_view_df #> [1] 882 #> #> $global_view_basis_ls #> [1] 2 #> #> $decode_df #> [1] 294 #> ## Notice that $global_view_df and $decode_df have fewer rows."},{"path":"/reference/sug_basis.html","id":null,"dir":"Reference","previous_headings":"","what":"Suggest a 1D Basis — sug_basis","title":"Suggest a 1D Basis — sug_basis","text":"Extract formats 1D attribution basis provided local explanation.","code":""},{"path":"/reference/sug_basis.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Suggest a 1D Basis — sug_basis","text":"","code":"sug_basis(attr_df, rownum)"},{"path":"/reference/sug_basis.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Suggest a 1D Basis — sug_basis","text":"attr_df data frame local explanation attributions. rownum rownumber observation. Typically primary comparison observations.","code":""},{"path":"/reference/sug_basis.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Suggest a 1D Basis — sug_basis","text":"matrix 1D basis.","code":""},{"path":[]},{"path":"/reference/sug_basis.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Suggest a 1D Basis — sug_basis","text":"","code":"library(cheem) ## Attribution basis of the primary instance sug_basis(ames_rf_shap, rownum = 1) #> data.frame #> LotArea 0.85497616 #> OverallQual 0.21436882 #> YearBuild 0.05907171 #> LivingArea 0.42354666 #> Bathrms -0.02586855 #> Bedrms 0.01659048 #> TotRms 0.05857403 #> GarageYrBlt 0.08939046 #> GarageArea 0.16677691 ## This can be used to find a basis to start the radial tour. # ?radial_cheem_tour ## Regression setup: dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## radial_cheem_tour() ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas, label = \"North Ames, RF, SHAP\") bas <- sug_basis(ames_rf_shap, 1) mv <- sug_manip_var(ames_rf_shap, 1, 2) ggt <- radial_cheem_tour(ames_rf_chm, basis = bas, manip_var = mv) if(interactive()){ ## As a plotly html widget spinifex::animate_plotly(ggt) ## As a gganimation spinifex::animate_gganimate(ggt, render = gganimate::av_renderer()) } ## radial_cheem_tour is also used in: ?run_app()"},{"path":"/reference/sug_manip_var.html","id":null,"dir":"Reference","previous_headings":"","what":"Suggest a manipulation variable — sug_manip_var","title":"Suggest a manipulation variable — sug_manip_var","text":"Suggest number variable largest difference attribution primary comparison observations.","code":""},{"path":"/reference/sug_manip_var.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Suggest a manipulation variable — sug_manip_var","text":"","code":"sug_manip_var(attr_df, primary_obs, comparison_obs)"},{"path":"/reference/sug_manip_var.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Suggest a manipulation variable — sug_manip_var","text":"attr_df data frame local explanation attributions. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. comparison_obs rownumber comparison observation. Point highlighted dotted line.","code":""},{"path":"/reference/sug_manip_var.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Suggest a manipulation variable — sug_manip_var","text":"single number variable largest difference attribution (basis) variables.","code":""},{"path":[]},{"path":"/reference/sug_manip_var.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Suggest a manipulation variable — sug_manip_var","text":"","code":"library(cheem) ## Regression setup dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## Suggest the number of a variable to manipulate sug_manip_var(ames_rf_shap, primary_obs = 1, comparison_obs = 2) #> [1] 4 ## This can be used to find a basis to start the radial tour. # ?radial_cheem_tour"},{"path":"/news/index.html","id":"cheem-v040","dir":"Changelog","previous_headings":"","what":"cheem v0.4.0","title":"cheem v0.4.0","text":"Repaired packagedown site! Fixed news packagedown site. Shiny app go buttons rather waiting every input change. Shiny app text, plot dimensions, text cleaned . Classification tour now uses horizontal layout. Cleaned text facet panels global_tour() radial_cheem_tour(). Recreate saved classification model, fit well work illustrations. Set seed consistently. model attribution shifted bit, replicable going forward. Minor documentation code clean clarifications.","code":""},{"path":"/news/index.html","id":"cheem-v030--generalized-for-any-attribution","dir":"Changelog","previous_headings":"","what":"cheem v0.3.0 – Generalized for any attribution","title":"cheem v0.3.0 – Generalized for any attribution","text":"CRAN release: 2023-05-08 Rebase functions expecting unified treeshap::shap() generalized data frame matrix format arbitrary attribution spaces. Rework vignette examples reflect change. Added precomputed predictions attributions Ames, Chocolates, Penguins datasets. allows users run attribution-agnostic functions without dependencies. Add subset_cheem(), convenience function subsetting cheem lists construction. Removed plotly subplot variations visuals: global_view_subplots(), radial_cheem_tour_subplots(). development variations never used shiny app. Minor function renames parsimony consistency.","code":""},{"path":"/news/index.html","id":"cheem-v020-cran-releases-here-on-out","dir":"Changelog","previous_headings":"","what":"cheem v0.2.0 (CRAN releases here on out)","title":"cheem v0.2.0 (CRAN releases here on out)","text":"CRAN release: 2022-03-14","code":""},{"path":"/news/index.html","id":"app-related-changes-0-2-0","dir":"Changelog","previous_headings":"","what":"App related changes","title":"cheem v0.2.0 (CRAN releases here on out)","text":"Added vignette: Getting started cheem. Added pkgdown site: https://nspyrison.github.io/cheem/. Added global model performance metrics shiny app. global_view(), added yhaty panel (residual plot/confusion matrix). global_view(), added color options: log_maha.data cor_attr.y. cheem_radial_tour(), added regression case panel additional fixed y residual. app radial tour inputs, added inclusion variable, subsetting variables used radial tour. plotly::subplot() variants global_view() & cheem_radial_tour(). Added AmesHousing data, chocolates, new toy simulated datasets (shiny app ). Reduced shiny app wording.","code":""},{"path":"/news/index.html","id":"internal--utilities-0-2-0","dir":"Changelog","previous_headings":"","what":"Internal & utilities","title":"cheem v0.2.0 (CRAN releases here on out)","text":"Major rebase cheem_ls(). Added linear/logistic_tform() suggest alpha function number observations.","code":""},{"path":"/news/index.html","id":"sourcing-treeshap-0-2-0","dir":"Changelog","previous_headings":"","what":"Sourcing treeshap","title":"cheem v0.2.0 (CRAN releases here on out)","text":"drat repository hosting treeshap work debian window rhub platforms; Minimally ported functions cpp source files @author & @source. Changed examples consistency smaller code base support. v0.3.0, cheem generalized local variable attributions, concern.","code":""},{"path":[]},{"path":"/news/index.html","id":"primary-preprocessing-functions-0-1-0","dir":"Changelog","previous_headings":"","what":"Primary preprocessing functions","title":"cheem v0.1.0 (GitHub only, commit 283da4)","text":"default_rf() create randomForest::randomForest() conservative defaults. attr_df_treeshap() create treeshap::treeshap() local explanations observation. cheem_ls() create cheem list prepared tables use run_app().","code":""},{"path":"/news/index.html","id":"primary-visual-functions-0-1-0","dir":"Changelog","previous_headings":"","what":"Primary visual functions","title":"cheem v0.1.0 (GitHub only, commit 283da4)","text":"run_app() shiny app consuming following two: global_view() linked ‘plotly’ approximations data- attribution-spaces model information. cheem_radial_tour() create spinifex::ggtour specified radial tour. Consumed animate_plotly, animate_gganimate, filmstrip.","code":""}]
+[{"path":"/articles/getting-started-with-cheem.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Getting started with cheem","text":"Non-linear models regularly result accurate prediction linear counterparts. However, number complexity terms make opaque interpretability. ability understand features (variables predictors) influence predictions important wide range audiences. Attempts bring interpretability complex models important aspect eXplainable Artificial Intelligence (XAI). Local explanations one tool used XAI. attempt approximate feature importance vicinity one instance (observation). say give approximation linear terms position one -sample --sample observation. analyst can explore models lead bad predictions can suggest insight issues data suggest models may robust misclassified extreme residuals. analyst may want explore support feature contributions explanations makes sense may completely unreliable. purpose sort analysis conducted interactive graphics analysis R package titled cheem.","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"preprocessing","dir":"Articles","previous_headings":"","what":"Preprocessing","title":"Getting started with cheem","text":"framework broadly applicable model compatible local explanation. illustrate xgboost::xgboost() model (xgb) tree SHAP local explanation shapviz::shapviz(). model attempts predict housing sales price 11 predictors 338 sale events one neighborhood 2018 Ames data. first things need prediction local explanation (embedded space). create xgb model, create predictions, find SHAP values observation. Note choice model, prediction, local explanation (embedding) choice analyst facilitated cheem. Now let’s prepare visualization spaces cheem::cheem_ls() call start analysis.","code":"## Download if not installed if(!require(cheem)) install.packages(\"cheem\", dependencies = TRUE) if(!require(treeshap)) install.packages(\"treeshap\", dependencies = TRUE) if(!require(shapviz)) install.packages(\"shapviz\", dependencies = TRUE) ## Load onto session library(cheem) library(xgboost) library(shapviz) ## Setup X <- amesHousing2018_NorthAmes[, 1:9] Y <- amesHousing2018_NorthAmes$SalePrice clas <- amesHousing2018_NorthAmes$SubclassMS ## Model and predict ames_train <- data.matrix(X) %>% xgb.DMatrix(label = Y) ames_xgb_fit <- xgboost(data = ames_train, max.depth = 3, nrounds = 25) ames_xgb_pred <- predict(ames_xgb_fit, newdata = ames_train) ames_xgb_pred %>% head() ## SHAP values shp <- shapviz(ames_xgb_fit, X_pred = ames_train, X = X) ## Keep just the [n, p] local explanations ames_xgb_shap <- shp$S ames_xgb_shap %>% head() ## Preprocessing for cheem analysis ames_chm <- cheem_ls(X, Y, class = clas, attr_df = ames_xgb_shap, pred = ames_xgb_pred, label = \"Ames, xgb, shap\") names(ames_chm)"},{"path":"/articles/getting-started-with-cheem.html","id":"cheem-viewer","dir":"Articles","previous_headings":"","what":"Cheem viewer","title":"Getting started with cheem","text":"extracted tree SHAP, feature importance measure vicinity observation. need identify instance interest explore; linked brushing available global view. vary contributions different features test support explanation radial tour","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"global-view","dir":"Articles","previous_headings":"Cheem viewer","what":"Global view","title":"Getting started with cheem","text":"get complete view lets look approximations data space, attribution space, model fits side--side linked brushing help plotly crosstalk. identified observation large Mahalanobis distance (data space) closest neighbor attribution space. global view want identify primary instance (PI) optionally comparison instance (CI) explore. Misclassified observations high residuals good targets exploration. One point sticks case. Instance 243 (shown *) Gentoo (purple) penguin, model predict Chinstrap penguin. Penguin 169 (shown x) reasonably close correctly predicted Gentoo. practice used linked brushing misclassification information guide search.","code":"prim <- 1 comp <- 17 global_view(ames_chm, primary_obs = prim, comparison_obs = comp, height_px = 240, width_px = 720, as_ggplot = TRUE, color = \"log_maha.data\")"},{"path":"/articles/getting-started-with-cheem.html","id":"radial-tour","dir":"Articles","previous_headings":"Cheem viewer","what":"Radial tour","title":"Getting started with cheem","text":"lot unpack . normalized distribution feature attribution instances shown parallel coordinates lines. selected PI CI shown dashed dotted line respectively. first thing notice attribution PI close ’s (incorrect) prediction Chinstrap (orange) terms bill length (bl) flipper length (fl). terms bill depth body mass (bd bm) like observed species Gentoo (purple). select flipper length feature manipulate. Starting attribution projection, instance already looks like observed Gentoo predicted Chinstrap. However, frame 8, basis full contribution flipper length look like predicted Chinstrap. Looking parallel coordinate lines basis visual can see flipper length large gap PI CI, lets check original variables digest. profile, two features distinguished PI CI. instance nested Chinstrap penguins. makes instance particularly hard random forest model classify decision tree can make partition one value (horizontal vertical lines ).","code":"## Normalized attribution basis of the PI bas <- sug_basis(ames_xgb_shap, rownum = prim) ## Default feature to manipulate: #### the feature with largest separation between PI and CI attribution mv <- sug_manip_var( ames_xgb_shap, primary_obs = prim, comparison_obs = comp) ## Make the radial tour ggt <- radial_cheem_tour( ames_chm, basis = bas, manip_var = mv, primary_obs = prim, comparison_obs = comp, angle = .15) ## Animate it animate_gganimate(ggt, fps = 6) #height = 2, width = 4.5, units = \"in\", res = 150 ## Or as a plotly html widget #animate_plotly(ggt, fps = 6) library(ggplot2) prim <- 1 ggplot(penguins_na.rm, aes(x = bill_length_mm, y = flipper_length_mm, colour = species, shape = species)) + geom_point() + ## Highlight PI, * geom_point(data = penguins_na.rm[prim, ], shape = 8, size = 5, alpha = 0.8) + ## Theme, scaling, color, and labels theme_bw() + theme(aspect.ratio = 1) + scale_color_brewer(palette = \"Dark2\") + labs(y = \"Flipper length [mm]\", x = \"Bill length [mm]\", color = \"Observed species\", shape = \"Observed species\")"},{"path":"/articles/getting-started-with-cheem.html","id":"shiny-application","dir":"Articles","previous_headings":"Cheem viewer","what":"Shiny application","title":"Getting started with cheem","text":"provide interactive shiny application. Interactive features made possible plotly, crosstalk, DT. preprocessed simulated modern datasets explore analysis . Alternatively, bring data saving return cheem_ls() rds file. Follow along example ?cheem_ls.","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Getting started with cheem","text":"Interpretability black-box models important maintain. Local explanation extend interpretability approximating feature importance vicinity one instance. purpose post-hoc analysis local explanations. First explore global, full instance context. explore support local explanation see seems plausible unreliable.","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"other-local-explanations-models","dir":"Articles","previous_headings":"","what":"Other local explanations (& models)","title":"Getting started with cheem","text":"cheem agnostic model local explanation, requires model local explanation. illustrated using random forest predict penguin species. demonstrates using attribution spaces different models.","code":""},{"path":"/articles/getting-started-with-cheem.html","id":"shapviz-xgb-classification","dir":"Articles","previous_headings":"Other local explanations (& models)","what":"shapviz (& xgb classification)","title":"Getting started with cheem","text":"shapviz actively maintained hosted CRAN. compatible H2O, lgb, xgb models. https://github.com/ModelOriented/shapviz","code":"if(!require(shapviz)) install.packages(\"shapviz\") if(!require(xgboost)) install.packages(\"xgboost\") library(shapviz) library(xgboost) set.seed(3653) ## Setup X <- spinifex::penguins_na.rm[, 1:4] Y <- spinifex::penguins_na.rm$species clas <- spinifex::penguins_na.rm$species ## Model and predict peng_train <- data.matrix(X) %>% xgb.DMatrix(label = Y) peng_xgb_fit <- xgboost(data = peng_train, max.depth = 3, nrounds = 25) peng_xgb_pred <- predict(peng_xgb_fit, newdata = peng_train) ## SHAP peng_xgb_shap <- shapviz(peng_xgb_fit, X_pred = peng_train, X = X) ## Keep just the [n, p] local explanations peng_xgb_shap <- peng_xgb_shap$S"},{"path":"/articles/getting-started-with-cheem.html","id":"treeshap-randomforest-regression","dir":"Articles","previous_headings":"Other local explanations (& models)","what":"treeshap (& randomForest regression)","title":"Getting started with cheem","text":"treeshap available CRAN. compatible many tree-based models including gbm, lbm, rf, ranger, xgb models. https://github.com/ModelOriented/treeshap","code":"if(!require(treeshap)) install.packages(\"treeshap\") if(!require(randomForest)) install.packages(\"randomForest\") library(treeshap) library(randomForest) ## Setup X <- spinifex::wine[, -1:2] Y <- spinifex::wine$Alcohol clas <- spinifex::wine$Type ## Fit randomForest::randomForest wine_rf_fit <- randomForest::randomForest( X, Y, ntree = 125, mtry = ifelse(is_discrete(Y), sqrt(ncol(X)), ncol(X) / 3), nodesize = max(ifelse(is_discrete(Y), 1, 5), nrow(X) / 500)) wine_rf_pred <- predict(wine_rf_fit) ## treeshap::treeshap() wine_rf_tshap <- wine_rf_fit %>% treeshap::randomForest.unify(X) %>% treeshap::treeshap(X, interactions = FALSE, verbose = FALSE) ## Keep just the [n, p] local explanations wine_rf_tshap <- wine_rf_tshap$shaps"},{"path":"/articles/getting-started-with-cheem.html","id":"dalex-lm-regression","dir":"Articles","previous_headings":"Other local explanations (& models)","what":"DALEX (& LM regression)","title":"Getting started with cheem","text":"DALEX popular versatile XAI package available CRAN. compatible many models, uses original, slower variant SHAP local explanation. Expect long run times sizable data complex models. https://ema.drwhy.ai/shapley.html#SHAPRcode","code":"if(!require(DALEX)) install.packages(\"DALEX\") library(DALEX) ## Setup X <- dragons[, c(1:4, 6)] Y <- dragons$life_length clas <- dragons$colour ## Model and predict drag_lm_fit <- lm(data = data.frame(Y, X), Y ~ .) drag_lm_pred <- predict(drag_lm_fit) ## SHAP via DALEX, versatile but slow drag_lm_exp <- explain(drag_lm_fit, data = X, y = Y, label = \"Dragons, LM, SHAP\") ## DALEX::predict_parts_shap is flexible, but slow and one row at a time drag_lm_shap <- matrix(NA, nrow(X), ncol(X)) sapply(1:nrow(X), function(i){ pps <- predict_parts_shap(drag_lm_exp, new_observation = X[i, ]) ## Keep just the [n, p] local explanations drag_lm_shap[i, ] <<- tapply( pps$contribution, pps$variable, mean, na.rm = TRUE) %>% as.vector() }) drag_lm_shap <- as.data.frame(drag_lm_shap)"},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Nicholas Spyrison. Author, maintainer.","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Spyrison N (2023). cheem: Interactively Explore Local Explanations Radial Tour. R package version 0.4.0.0, https://nspyrison.github.io/cheem/, https://github.com/nspyrison/cheem/.","code":"@Manual{, title = {cheem: Interactively Explore Local Explanations with the Radial Tour}, author = {Nicholas Spyrison}, year = {2023}, note = {R package version 0.4.0.0, https://nspyrison.github.io/cheem/}, url = {https://github.com/nspyrison/cheem/}, }"},{"path":"/index.html","id":"cheem","dir":"","previous_headings":"","what":"Interactively Explore Local Explanations with the Radial Tour","title":"Interactively Explore Local Explanations with the Radial Tour","text":"Interactively explore data- local explanation- spaces residual side--side. explore support selected observation’s local explanation radial tour.","code":""},{"path":"/index.html","id":"context","dir":"","previous_headings":"","what":"Context","title":"Interactively Explore Local Explanations with the Radial Tour","text":"Local explanations approximate linear variable importance non-linear model vicinity one instance(observation). , point-measure variable’s importance model particular location data-space. cheem extracts local explanation every observation dataset, given model. Given model, extract local explanation every observation data set. View data- explanation-spaces side--side interactive shiny application. explored selected point comparison using explanation 1D projection basis. radial tour explores structure explanation projection.","code":""},{"path":"/index.html","id":"getting-started","dir":"","previous_headings":"","what":"Getting started","title":"Interactively Explore Local Explanations with the Radial Tour","text":"","code":"## Download the package install.packages(\"cheem\", dependencies = TRUE) ## May need to restart the R session so RSudio has the correct file structure rstudioapi::restartSession() ## Load cheem into session library(cheem) ## Try the app run_app() ## Processing your data; follow the examples in cheem_ls() ?cheem_ls"},{"path":"/index.html","id":"global-view","dir":"","previous_headings":"","what":"Global view","title":"Interactively Explore Local Explanations with the Radial Tour","text":"global view shows data-, attribution-spaces, residual plot side--side linked brushing hover tooltip. exploring global view, identify primary comparison observation compare. classification task, typically misclassified point selected compared nearby correctly classified one. regression, can compare point extreme residual nearby point accurately predicted.","code":""},{"path":"/index.html","id":"radial-cheem-tour","dir":"","previous_headings":"","what":"Radial cheem tour","title":"Interactively Explore Local Explanations with the Radial Tour","text":"attribution primary observation becomes 1D basis tour. variable largest difference primary comparison point’s bases selected manipulation variable. variable whose contribution change drives change projection basis. , testing local explanation. testing variable sensitivity structure identified local explanation, can better evaluate good explanation ; sensitive prediction change variable contributions.","code":""},{"path":"/index.html","id":"original-application","dir":"","previous_headings":"","what":"Original application","title":"Interactively Explore Local Explanations with the Radial Tour","text":"started looking model-agnostic local explanation tree SHAP applied random forests. made choice concern runtime (treeshap uses alternative algorithm reduced computational complexity thus achieves much faster run time extracting full SHAP matrix preprocessing step). namesake, Cheem, stems original application tree-based models DALEX ecosystem; Cheem fictional race tree-based humanoids consistency Dr. /Dr. theme.","code":""},{"path":"/index.html","id":"sources","dir":"","previous_headings":"","what":"Sources","title":"Interactively Explore Local Explanations with the Radial Tour","text":"Explanatory Model Analysis (ebook) DALEX CRAN page spinifex CRAN page","code":""},{"path":"/index.html","id":"package-build-workflow","dir":"","previous_headings":"","what":"Package build workflow","title":"Interactively Explore Local Explanations with the Radial Tour","text":"devtools::document() ## documentation changes pkgdown::build_site() ## packagedown site changes (documentation, vignettes, readme) message(“Manually : Build tab > Install Restart”) ## build package rhub::check_for_cran() ## check package devtools::submit_cran() ## Submit CRAN","code":""},{"path":"/reference/amesHousing2018.html","id":null,"dir":"Reference","previous_headings":"","what":"Ames housing data 2018 — amesHousing2018","title":"Ames housing data 2018 — amesHousing2018","text":"House sales prices Ames, Iowa, USA 2006 2010. complete numeric observations remain.","code":""},{"path":"/reference/amesHousing2018.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ames housing data 2018 — amesHousing2018","text":"","code":"amesHousing2018 amesHousing2018_raw amesHousing2018_NorthAmes"},{"path":"/reference/amesHousing2018.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Ames housing data 2018 — amesHousing2018","text":"complete data.frame 2291 rows 18 numeric variables, SalesPrice, response variable, 3 class variables object class data.frame 2930 rows 82 columns. object class data.frame 338 rows 11 columns.","code":""},{"path":"/reference/amesHousing2018.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Ames housing data 2018 — amesHousing2018","text":"De Cock, D. (2011). \"Ames, Iowa: Alternative Boston Housing Data End Semester Regression Project,\" Journal Statistics Education, Volume 19, Number 3. http://jse.amstat.org/v19n3/decock/DataDocumentation.txt http://jse.amstat.org/v19n3/decock.pdf Kaggle, Ames Housing Dataset https://www.kaggle.com/prevek18/ames-housing-dataset Replicating dataset:","code":"if(FALSE) ## Don't accidentally open the URL. browseURL(\"https://www.kaggle.com/prevek18/ames-housing-dataset\") ames <- readr::read_csv(\"./buildignore/AmesHousing.csv\") amesHousing2018_raw <- data.frame(ames) ## save(amesHousing2018_raw, file = \"./data/amesHousing2018_raw.rda\") ## Complete rows and numeric variables ames1 <- ames[, unlist(lapply(ames, is.numeric))] ames1$Bathrooms <- ames1$`Full Bath` + ames1$`Half Bath` ames1 <- ames1[, c(1:18, 38, 19:37)] col_idx <- !(colnames(ames1) %in% c( \"Order\", \"Mas Vnr Area\", \"BsmtFin SF 1\", \"BsmtFin SF 2\", \"Bsmt Full Bath\", \"Bsmt Half Bath\", \"Fireplaces\", \"Wood Deck SF\", \"Open Porch SF\", \"Enclosed Porch\", \"3Ssn Porch\", \"Screen Porch\", \"Pool Area\", \"Misc Val\", \"2nd Flr SF\", \"Low Qual Fin SF\", \"Full Bath\", \"Half Bath\", \"Kitchen AbvGr\")) row_idx <- !is.na(ames1$\"Garage Yr Blt\") & !is.na(ames1$\"Lot Frontage\") & !is.na(ames1$\"Bsmt Unf SF\") & !is.na(ames1$\"Total Bsmt SF\") ames2 <- as.data.frame(ames1[row_idx, col_idx]) ## Looking for character classes to keep: ames_char <- ames[, unlist(lapply(ames, is.character))] ames_clas <- as.data.frame(lapply(ames_char, factor))[, -1] ames_clasint <- data.frame(lapply(ames_clas, as.integer)) col_idx_char <- which(names(ames_clas) %in% c(\"MS.SubClass\", \"MS.Zoning\", \"Neighborhood\")) classes <- ames_clas[row_idx, col_idx_char] amesHousing2018 <- cbind(ames2, classes) names(amesHousing2018) <- c( \"LotFrontage\", \"LotArea\",\"OverallQual\", \"OverallCond\", \"YearBuild\", \"YearRemod\", \"BsmtUnfArea\", \"TotBsmtArea\", \"1stFlrArea\", \"LivingArea\", \"Bathrms\", \"Bedrms\", \"TotRms\", \"GarageYrBlt\", \"GarageCars\", \"GarageArea\", \"MoSold\", \"YrSold\", \"SalePrice\", \"SubclassMS\", \"ZoneMS\", \"Neighborhd\") ## save(amesHousing2018, file = \"./data/amesHousing2018.rda\") .thin_col_idx <- names(amesHousing2018) %in% c( \"LotArea\", \"OverallQual\", \"YearBuild\", \"LivingArea\", \"Bathrms\", \"Bedrms\", \"TotRms\", \"GarageYrBlt\", \"GarageArea\", \"SalePrice\", \"SubclassMS\") amesHousing2018_thin <- amesHousing2018[, .thin_col_idx] ## subset to north ames, and only 5 largest subclasses r_idx <- amesHousing2018$Neighborhd == \"NAmes\" & amesHousing2018$SubclassMS %in% c(\"020\", \"050\", \"080\", \"090\", \"060\") amesHousing2018_NorthAmes <- amesHousing2018_thin[r_idx, ] amesHousing2018_NorthAmes$SubclassMS <- factor( amesHousing2018_NorthAmes$SubclassMS, unique(amesHousing2018_NorthAmes$SubclassMS)) if(F){ ## Don't accidentally save save(amesHousing2018_NorthAmes, file = \"./data/amesHousing2018_NorthAmes.rda\")"},{"path":"/reference/amesHousing2018.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Ames housing data 2018 — amesHousing2018","text":"amesHousing2018 Complete data.frame, n = 2291, 18 numeric variable (including 2 temporal: MoSold, YrSold ), response variable SalePrice, 3 class factors. amesHousing2018_NorthAmes simplified subsample, just North Ames (largest neighborhood). Complete data.frame, n = 338, 9 numeric variables, response variable SalePrice, 1 class factor SubclassMS, zoning subclass. amesHousing2018_raw Original data Kaggle, 2930 rows 82 variables. Sparse rows (639) sparse/defaulted columns (64) removed. data dictionary provided Kaggle, amesHousing2018 variables inferred : LotFrontage, Length front (street facing) side lot yards (0.914m) LotArea, Area lot square yards (0.836m^2) OverallQual, Overall quality (house?), integer (1, 10) OverallCond, Overall condition (lot?), integer (1, 10) YearBuild, year house originally built BsmtUnfArea, Unfinished basement area, square yards (0.836m^2) TotBsmtArea, Total basement area, square yards (0.836m^2) 1stFlrArea, First (ground) floor living area square yards (0.836m^2) LivingArea, Total living area square yards (0.836m^2) Bathrms, number bathrooms Bedrms, number bedrooms TotRms, total number rooms GarageYrBlt, year garage build GarageCars, number car spaces garage GarageArea, area garage square yards (0.836m^2) MoSold, number month house sale YrSold, number year house sale SalePrice, sale house USD (year sale?) SubclassMS, Factor subclass construction zone, 16 levels SubclassMS, Factor major class construction zone, 7 levels Neighborhd, Factor neighborhood Ames, IA, 28 levels","code":""},{"path":"/reference/amesHousing2018.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Ames housing data 2018 — amesHousing2018","text":"","code":"library(cheem) ## Regression setup: dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## Cheem list ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas, label = \"North Ames, RF, SHAP\") ## Cheem visuals if(interactive()){ prim <- 1 comp <- 2 global_view(ames_rf_chm, primary_obs = prim, comparison_obs = comp) bas <- sug_basis(ames_rf_chm, prim, comp) mv <- sug_manip_var(ames_rf_chm, primary_obs = prim, comp) ggt <- radial_cheem_tour(ames_rf_chm, basis = bas, manip_var = mv) animate_plotly(ggt) } ## 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. }"},{"path":"/reference/ames_rf_pred.html","id":null,"dir":"Reference","previous_headings":"","what":"Ames random forest model predictions and shap values — ames_rf_pred","title":"Ames random forest model predictions and shap values — ames_rf_pred","text":"Predictions treeshap attribution random forest model North Ames house sales data regressing Sales Price house lot variables.","code":""},{"path":"/reference/ames_rf_pred.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ames random forest model predictions and shap values — ames_rf_pred","text":"","code":"ames_rf_pred ames_rf_shap"},{"path":"/reference/ames_rf_pred.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Ames random forest model predictions and shap values — ames_rf_pred","text":"ames_rf_pred n=338 length vector prediction random forest model predicting numeric House Sales North Ames. ames_rf_shap (338 x 9) data frame treeshap SHAP attribution random forest model observation. Replicating object class data.frame 338 rows 9 columns.","code":"library(cheem) library(randomForest) library(treeshap) set.seed(135) ## Regression setup dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## Model and treeSHAP ames_rf_fit <- randomForest::randomForest( X, Y, ntree = 125, mtry = ifelse(is_discrete(Y), sqrt(ncol(X)), ncol(X) / 3), nodesize = max(ifelse(is_discrete(Y), 1, 5), nrow(X) / 500)) ames_rf_pred <- predict(ames_rf_fit, X) ames_rf_shap <- treeshap::treeshap( treeshap::randomForest.unify(ames_rf_fit, X), X, FALSE, FALSE) ames_rf_shap <- ames_rf_shap$shaps if(F){ ## Don't accidentally save save(ames_rf_pred, file = \"./data/ames_rf_pred.rda\") save(ames_rf_shap, file = \"./data/ames_rf_shap.rda\") #usethis::use_data(ames_rf_pred) #usethis::use_data(ames_rf_shap) }"},{"path":"/reference/ames_rf_pred.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Ames random forest model predictions and shap values — ames_rf_pred","text":"","code":"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) #> Named num [1:338] 203193 116048 167320 223589 139029 ... #> - attr(*, \"names\")= chr [1:338] \"1\" \"2\" \"3\" \"4\" ... str(ames_rf_shap) #> 'data.frame':\t338 obs. of 9 variables: #> $ LotArea : num 27231 -374 14749 1687 -1036 ... #> $ OverallQual: num 6828 -5011 6182 22641 -3156 ... #> $ YearBuild : num 1881 294 -438 4182 2677 ... #> $ LivingArea : num 13490 -16765 4160 28335 -3640 ... #> $ Bathrms : num -824 -1310 1621 10436 -996 ... #> $ Bedrms : num 528 -1363 360 744 672 ... #> $ TotRms : num 1866 -3193 124 5314 1135 ... #> $ GarageYrBlt: num 2847 -937 -559 791 1462 ... #> $ GarageArea : num 5312 672 -2915 5423 -2125 ... ## 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) }"},{"path":"/reference/as_logical_index.html","id":null,"dir":"Reference","previous_headings":"","what":"Assure a full length logical index — as_logical_index","title":"Assure a full length logical index — as_logical_index","text":"Suggests alpha opacity plot function number observation.","code":""},{"path":"/reference/as_logical_index.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assure a full length logical index — as_logical_index","text":"","code":"as_logical_index(index, n)"},{"path":"/reference/as_logical_index.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assure a full length logical index — as_logical_index","text":"index vector, typically numeric row index data coerce logical index. n Single numeric, number rows data use replicate return length.","code":""},{"path":"/reference/as_logical_index.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assure a full length logical index — as_logical_index","text":"logical index length n.","code":""},{"path":[]},{"path":"/reference/as_logical_index.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assure a full length logical index — as_logical_index","text":"","code":"library(cheem) ## Coerce a numeric index to logical as_logical_index(c(1, 4:10, 15), nrow(mtcars)) #> [1] TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE #> [13] FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE #> [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE ## Logical indexs are unchanged as_logical_index(mtcars$mpg > 30, nrow(mtcars)) #> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE #> [13] FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE #> [25] FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE"},{"path":"/reference/cheem.html","id":null,"dir":"Reference","previous_headings":"","what":"cheem — cheem","title":"cheem — cheem","text":"Consider arbitrary black-box model. Local explanations class point-measures variable importance model one location explanatory variables. package cheem extracts local attribution observations first creates 2D approximated space comparing data- attribution-spaces. primary comparison observation selected attribution primary used 1D basis manual tour. tour changes contribution variable deviates expected value. viewing positions primary comparison points, analyst can scrutinize explanation identify variable attribution leading misclassification large residual.","code":""},{"path":"/reference/cheem.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"cheem — cheem","text":"GitHub: https://github.com/nspyrison/cheem","code":""},{"path":[]},{"path":"/reference/cheem.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"cheem — cheem","text":"Maintainer: Nicholas Spyrison spyrison@gmail.com (ORCID)","code":""},{"path":"/reference/cheem_ls.html","id":null,"dir":"Reference","previous_headings":"","what":"Preprocessing for use in shiny app — cheem_ls","title":"Preprocessing for use in shiny app — cheem_ls","text":"Performs preprocessing steps needs supply plot functions global_view() radial_cheem_tour() used shiny app. user need supply attributions predictions. help getting started see vignette(\"getting-started--cheem\").","code":""},{"path":"/reference/cheem_ls.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Preprocessing for use in shiny app — cheem_ls","text":"","code":"cheem_ls( x, y = NULL, attr_df, pred = NULL, class = NULL, label = \"label\", verbose = getOption(\"verbose\") )"},{"path":"/reference/cheem_ls.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Preprocessing for use in shiny app — cheem_ls","text":"x explanatory variables model. y target variable model. attr_df data frame matrix (n, p) local explanation attributions. pred (n, 1) vector, predictions associated model. class Optional, (n, 1) vector, variable group points . can different y, target variable. label Optionally provide character label store reminder text type model local explanation used. Defaults \"label\". verbose Logical, start time run duration printed. Defaults getOption(\"verbose\").","code":""},{"path":"/reference/cheem_ls.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Preprocessing for use in shiny app — cheem_ls","text":"list data.frames needed shiny application.","code":""},{"path":[]},{"path":"/reference/cheem_ls.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Preprocessing for use in shiny app — cheem_ls","text":"","code":"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) }"},{"path":"/reference/chocolates.html","id":null,"dir":"Reference","previous_headings":"","what":"Chocolates dataset — chocolates","title":"Chocolates dataset — chocolates","text":"chocolates data compiled students Iowa State University STAT503 (circa 2015) taught Dianne Cook. Nutrition label information chocolates listed manufacturer websites. numbers normalized equivalent 100g serving. Units measurement listed variable name.","code":""},{"path":"/reference/chocolates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Chocolates dataset — chocolates","text":"","code":"chocolates"},{"path":"/reference/chocolates.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Chocolates dataset — chocolates","text":"complete data.frame 88 observations 10 numeric variables, name chocolate, manufacturer, country, type chocolate. Name, name chocolate MFR, chocolate manufacturer Country, country manufacturer incorporated. Type, type chocolate according website, either 'Dark' 'Milk\" Calories, number calories per 100 grams CalFat, calories fat per 100 grams TotFat_g, grams total fat per 100 grams SatFat_g, grams saturated fat per 100 grams Chol_mg, milligrams cholesterol per 100 grams Na_mg, milligrams sodium (salt) per 100 grams Carbs_g, grams carbohydrates per 100 grams Fiber_g, grams fiber per 100 grams Sugars_g, grams sugar per 100 grams Protein_g, grams sugar per 100 grams","code":""},{"path":"/reference/chocolates.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Chocolates dataset — chocolates","text":"Monash University, Introduction Machine Learning course https://iml.numbat.space/ Replicating dataset:","code":"if(FALSE) ## Don't accidentally open the URL. browseURL(\"https://iml.numbat.space/\") ## Accessed Jan 2022 chocolates <- readr::read_csv(\"https://iml.numbat.space/data/chocolates.csv\") chocolates <- data.frame(chocolates) chocolates[, 2] <- factor(chocolates[, 2]) chocolates[, 3] <- factor(chocolates[, 3]) chocolates[, 4] <- factor(chocolates[, 4]) if(F){ ## Don't accidentally save save(chocolates, file = \"./data/chocolates.rda\")"},{"path":"/reference/chocolates.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Chocolates dataset — chocolates","text":"","code":"library(cheem) ## Classification setup X <- chocolates[, 5:14] Y <- chocolates$Type clas <- chocolates$Type ## Cheem choc_chm <- cheem_ls(X, Y, chocolates_svm_shap, chocolates_svm_pred, clas, label = \"Chocolates, LM, shap\") ## Save for use with shiny app (expects an rds file) if(FALSE){ ## Don't accidentally save. saveRDS(choc_chm, \"./chm_chocolates_svm_shap.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) }"},{"path":"/reference/chocolates_svm_pred.html","id":null,"dir":"Reference","previous_headings":"","what":"Chocolate svm model predictions and shap values — chocolates_svm_pred","title":"Chocolate svm model predictions and shap values — chocolates_svm_pred","text":"Predictions DALEX shap attribution svm model Chocolate data classifying type chocolate (light/dark).","code":""},{"path":"/reference/chocolates_svm_pred.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Chocolate svm model predictions and shap values — chocolates_svm_pred","text":"","code":"chocolates_svm_pred chocolates_svm_shap"},{"path":"/reference/chocolates_svm_pred.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Chocolate svm model predictions and shap values — chocolates_svm_pred","text":"chocolate_svm_pred n=88 length vector prediction svm model predicting number factor level species penguin. chocolate_svm_shap (88 x 10) data frame DALEX SHAP attribution svm model observation. Replicating object class data.frame 88 rows 10 columns.","code":"library(cheem) library(e1071) library(DALEX) set.seed(135) ## Classification setup X <- chocolates[, 5:14] Y <- chocolates$Type clas <- chocolates$Type ## Model and predict choc_svm_fit <- svm( formula = Y ~ ., data = data.frame(Y, X), type = 'C-classification', kernel = 'linear', probability = TRUE) chocolates_svm_pred <- predict(choc_svm_fit, data.frame(Y, X)) ## SHAP via DALEX, versatile but slow choc_svm_exp <- explain(choc_svm_fit, data = X, y = Y, label = \"Chocolates, svm\") ## Note that cheem expects a full [n, p] attribution space ## Shap takes about ~30-40 sec for me chocolates_svm_shap <- matrix(NA, nrow(X), ncol(X)) ## init a df of the same structure sapply(1:nrow(X), function(i){ pps <- predict_parts_shap(choc_svm_exp, new_observation = X[i, ]) ## Keep just the [n, p] local explanations chocolates_svm_shap[i, ] <<- tapply( pps$contribution, pps$variable, mean, na.rm = TRUE) %>% as.vector() }) chocolates_svm_shap <- as.data.frame(chocolates_svm_shap) if(F){ ## Don't accidentally save save(chocolates_svm_pred, file = \"./data/chocolates_svm_pred.rda\") save(chocolates_svm_shap, file = \"./data/chocolates_svm_shap.rda\") #usethis::use_data(chocolates_svm_pred) #usethis::use_data(chocolates_svm_shap) }"},{"path":"/reference/chocolates_svm_pred.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Chocolate svm model predictions and shap values — chocolates_svm_pred","text":"","code":"library(cheem) ## Classification setup X <- chocolates[, 5:14] Y <- chocolates$Type clas <- chocolates$Type ## Precomputed predictions and shap attribution str(chocolates_svm_pred) #> Factor w/ 2 levels \"Dark\",\"Milk\": 1 1 1 1 1 1 1 1 2 1 ... #> - attr(*, \"names\")= chr [1:88] \"1\" \"2\" \"3\" \"4\" ... str(chocolates_svm_shap) #> 'data.frame':\t88 obs. of 10 variables: #> $ V1 : num -0.03852 -0.05926 0.00136 -0.02551 -0.01845 ... #> $ V2 : num -0.005681 0.003371 -0.000133 0.000113 0.004603 ... #> $ V3 : num 0.01161 0.00343 -0.00449 0.0062 0.00262 ... #> $ V4 : num -0.0156 -0.0021 -0.0257 -0.0195 -0.0222 ... #> $ V5 : num -0.106 -0.112 -0.168 -0.258 -0.251 ... #> $ V6 : num -0.0573 -0.0513 -0.0797 0.0294 0.0565 ... #> $ V7 : num 0.014471 0.012275 -0.000944 0.039095 0.039942 ... #> $ V8 : num -0.01986 -0.03739 -0.00627 -0.00754 -0.02157 ... #> $ V9 : num -0.0735 -0.0265 0.016 -0.0373 -0.0275 ... #> $ V10: num -0.0396 -0.0596 0.0114 -0.0295 -0.0322 ... ## Cheem choc_chm <- cheem_ls(X, Y, chocolates_svm_shap, chocolates_svm_pred, clas, label = \"Chocolates, SVM, shap\") ## Save for use with shiny app (expects an rds file) if(FALSE){ ## Don't accidentally save. saveRDS(choc_chm, \"./cmh_chocolates_svm_shap.rds\") run_app() ## Select the saved rds file from the data dropdown. } ## Cheem visuals if(interactive()){ prim <- 1 comp <- 2 global_view(choc_chm, primary_obs = prim, comparison_obs = comp) bas <- sug_basis(chocolates_svm_shap, prim, comp) mv <- sug_manip_var(chocolates_svm_shap, primary_obs = prim, comp) ggt <- radial_cheem_tour(choc_chm, basis = bas, manip_var = mv) animate_plotly(ggt) }"},{"path":"/reference/color_scale_of.html","id":null,"dir":"Reference","previous_headings":"","what":"Suggest a color and fill scale. — color_scale_of","title":"Suggest a color and fill scale. — color_scale_of","text":"Whether vector diverges value, returns logical. Used help default scale_color ggplot2.","code":""},{"path":"/reference/color_scale_of.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Suggest a color and fill scale. — color_scale_of","text":"","code":"color_scale_of(x, mid_pt = 0, limits = NULL, ...)"},{"path":"/reference/color_scale_of.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Suggest a color and fill scale. — color_scale_of","text":"x vector scale color . mid_pt single number checking divergence . Defaults 0. limits vector min max values scale. Useful setting absolute range, (-1, 1) attribution/y correlation point. Points outside limits show default grey. Defaults NULL; range x. ... Optional arguments passed ggplot2::continuous_scale ggplot2::discrete_scale.","code":""},{"path":"/reference/color_scale_of.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Suggest a color and fill scale. — color_scale_of","text":"list containing scale_color, scale_fill; suggested color/fill scale ggplot.","code":""},{"path":[]},{"path":"/reference/color_scale_of.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Suggest a color and fill scale. — color_scale_of","text":"","code":"library(cheem) library(ggplot2) g <- ggplot(mtcars, aes(disp, mpg)) ## Discrete g + geom_point(aes(color = factor(vs))) + color_scale_of(mtcars$vs) ## Sequential increasing g + geom_point(aes(color = mpg)) + color_scale_of(mtcars$mpg) ## Dummy sequential decr g + geom_point(aes(color = -1 *mpg)) + color_scale_of(-1 * mtcars$mpg) ## Dummy diverging g + geom_point(aes(color = mpg - median(mpg))) + color_scale_of(mtcars$mpg - median(mtcars$mpg)) ## Dummy limits g + geom_point(aes(color = mpg - median(mpg))) + color_scale_of(mtcars$mpg - median(mtcars$mpg), limits = c(-5, 5))"},{"path":"/reference/contains_nonnumeric.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if a vector contains non-numeric character — contains_nonnumeric","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"Returns logical, whether vector contains non-numeric characters. Typically used test row names hold non-index information.","code":""},{"path":"/reference/contains_nonnumeric.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"","code":"contains_nonnumeric(x)"},{"path":"/reference/contains_nonnumeric.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"x vector tested existence non-numeric characters.","code":""},{"path":"/reference/contains_nonnumeric.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"Logical, whether x contains non-numeric characters.","code":""},{"path":[]},{"path":"/reference/contains_nonnumeric.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Check if a vector contains non-numeric character — contains_nonnumeric","text":"","code":"library(cheem) contains_nonnumeric(mtcars$mpg) #> [1] FALSE contains_nonnumeric(rownames(mtcars)) ## Meaningful info to use in tooltip #> [1] TRUE contains_nonnumeric(rownames(cars)) ## Assume no meaningful info to use in tooltip #> [1] FALSE"},{"path":"/reference/devMessage.html","id":null,"dir":"Reference","previous_headings":"","what":"Development message — devMessage","title":"Development message — devMessage","text":"Send message 4th chunk package version 9000.","code":""},{"path":"/reference/devMessage.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Development message — devMessage","text":"","code":"devMessage(text)"},{"path":"/reference/devMessage.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Development message — devMessage","text":"text character string message() package version 9000.","code":""},{"path":"/reference/global_view.html","id":null,"dir":"Reference","previous_headings":"","what":"Linked plotly display, global view of data and attribution space. — global_view","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"cheem_ls() list, create linked plotly global data- attribution- spaces. Typically consumed directly shiny app.","code":""},{"path":"/reference/global_view.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"","code":"global_view( cheem_ls, primary_obs = NULL, comparison_obs = NULL, color = c(\"default\", \"residual\", \"log_maha.data\", \"cor_attr_proj.y\"), height_px = 480, width_px = 1440, as_ggplot = FALSE )"},{"path":"/reference/global_view.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"cheem_ls return cheem_ls(), list data frames. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. Defaults NULL, highlighting applied. comparison_obs rownumber comparison observation. Point highlighted dotted line. Defaults NULL, highlighting applied. color name column cheem_ls$global_view_df map color. Expects c(\"default\", \"residual\", \"log_maha.data\", \"cor_attr_proj.y\"). Defaults \"default\"; predicted_class classification, dummy class regression. height_px height pixels returned plotly plot. Defaults 480, nothing as_ggplot TRUE. width_px width pixels returned plotly plot. Defaults 1440, nothing as_ggplot TRUE. as_ggplot Logical, TRUE returns plots passed plotly functions.","code":""},{"path":"/reference/global_view.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"plotly plot, interactive html widget global view, first two components basis data- attribution- spaces.","code":""},{"path":[]},{"path":"/reference/global_view.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linked plotly display, global view of data and attribution space. — global_view","text":"","code":"library(cheem) ## Regression setup: dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## global_view() ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas, label = \"North Ames, RF, SHAP\") if(interactive()){ global_view(ames_rf_chm, as_ggplot = TRUE) ## early return of ggplot global_view(ames_rf_chm) ## uses ggplot facets %>% plotly ## Different color mappings, especially for regression global_view(ames_rf_chm, color = \"residual\") global_view(ames_rf_chm, color = \"log_maha.data\") global_view(ames_rf_chm, color = \"cor_attr_proj.y\") } ## Also consumed by: ?run_app()"},{"path":"/reference/global_view_df_1layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","title":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","text":"Internal function consumed cheem workflow. Produces plot data.frame 1 layer. consumed downstream cheem_ls.","code":""},{"path":"/reference/global_view_df_1layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","text":"","code":"global_view_df_1layer(x, class = NULL, label = \"label\")"},{"path":"/reference/global_view_df_1layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","text":"x explanatory variables model. class Optional, (n, 1) vector, variable group points . can different y, target variable. label Optionally provide character label store reminder text type model local explanation used. Defaults \"label\".","code":""},{"path":"/reference/global_view_df_1layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create the plot data.frame for the global linked plotly display. — global_view_df_1layer","text":"data.frame, global linked plotly display.","code":""},{"path":"/reference/global_view_legwork.html","id":null,"dir":"Reference","previous_headings":"","what":"The legwork behind the scenes for the global view — global_view_legwork","title":"The legwork behind the scenes for the global view — global_view_legwork","text":"meant end user. internal legwork function keep repeating global_view code.","code":""},{"path":"/reference/global_view_legwork.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The legwork behind the scenes for the global view — global_view_legwork","text":"","code":"global_view_legwork( cheem_ls, primary_obs = NULL, comparison_obs = NULL, color = c(\"default\", \"residual\", \"log_maha.data\", \"cor_attr_proj.y\") )"},{"path":"/reference/global_view_legwork.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"The legwork behind the scenes for the global view — global_view_legwork","text":"cheem_ls return cheem_ls(), list data frames. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. Defaults NULL, highlighting applied. comparison_obs rownumber comparison observation. Point highlighted dotted line. Defaults NULL, highlighting applied. color name column cheem_ls$global_view_df map color. Expects c(\"default\", \"residual\", \"log_maha.data\", \"cor_attr_proj.y\"). Defaults \"default\"; predicted_class classification, dummy class regression.","code":""},{"path":"/reference/global_view_legwork.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"The legwork behind the scenes for the global view — global_view_legwork","text":"ggplot2 object, waiting rendered global_view global_view_subplots.","code":""},{"path":[]},{"path":"/reference/ifDev.html","id":null,"dir":"Reference","previous_headings":"","what":"Evaluate if development — ifDev","title":"Evaluate if development — ifDev","text":"Evaluate expression 4th chunk package version 9000.","code":""},{"path":"/reference/ifDev.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Evaluate if development — ifDev","text":"","code":"ifDev(expr)"},{"path":"/reference/ifDev.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Evaluate if development — ifDev","text":"expr character string message() package version 9000.","code":""},{"path":"/reference/is_discrete.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if a vector is discrete — is_discrete","title":"Check if a vector is discrete — is_discrete","text":"Whether vector discrete variable, returns logical. Typically used Y variable model.","code":""},{"path":"/reference/is_discrete.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if a vector is discrete — is_discrete","text":"","code":"is_discrete(x, na.rm = TRUE)"},{"path":"/reference/is_discrete.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if a vector is discrete — is_discrete","text":"x vector check discreteness . na.rm Whether remove NA values testing discreteness. Defaults TRUE.","code":""},{"path":"/reference/is_discrete.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check if a vector is discrete — is_discrete","text":"Logical, whether x discrete variable.","code":""},{"path":[]},{"path":"/reference/is_discrete.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Check if a vector is discrete — is_discrete","text":"","code":"library(cheem) is_discrete(mtcars$mpg) ## Numeric column, with more than 25 unique values. #> [1] FALSE is_discrete(mtcars$cyl) ## Numeric column, labeled as discrete, because less than 25 unique values #> [1] TRUE is_discrete(letters) ## Characters and factors labeled discrete. #> [1] TRUE"},{"path":"/reference/is_diverging.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if a vector diverges a value — is_diverging","title":"Check if a vector diverges a value — is_diverging","text":"Whether vector diverges value, returns logical. Used help default scale_color ggplot2.","code":""},{"path":"/reference/is_diverging.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if a vector diverges a value — is_diverging","text":"","code":"is_diverging(x, mid_pt = 0)"},{"path":"/reference/is_diverging.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if a vector diverges a value — is_diverging","text":"x vector check divergence . mid_pt single number checking divergence . Defaults 0.","code":""},{"path":"/reference/is_diverging.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check if a vector diverges a value — is_diverging","text":"Logical, whether x diverges mid_pt.","code":""},{"path":[]},{"path":"/reference/is_diverging.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Check if a vector diverges a value — is_diverging","text":"","code":"library(cheem) is_diverging(-10:10) #> [1] TRUE is_diverging(-10:-5) #> [1] FALSE is_diverging(mtcars$mpg, 25) #> [1] TRUE is_diverging(mtcars$mpg, 40) #> [1] FALSE"},{"path":"/reference/linear_tform.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear function to help set alpha opacity — linear_tform","title":"Linear function to help set alpha opacity — linear_tform","text":"Suggests alpha opacity plot function number observation.","code":""},{"path":"/reference/linear_tform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear function to help set alpha opacity — linear_tform","text":"","code":"linear_tform(n, appox_max_n = 5000, ceiling = 1, floor = 0.3)"},{"path":"/reference/linear_tform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear function to help set alpha opacity — linear_tform","text":"n Number observations plot. appox_max_n number observation reach floor opacity. ceiling highest number returned. Defaults 1. floor lowest number returned. Defaults 0.3.","code":""},{"path":"/reference/linear_tform.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear function to help set alpha opacity — linear_tform","text":"scalar numeric, suggested value set alpha opacity.","code":""},{"path":[]},{"path":"/reference/linear_tform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear function to help set alpha opacity — linear_tform","text":"","code":"library(cheem) ## Suggest an opacity to use in plotting: (my_alpha <- linear_tform(nrow(spinifex::penguins_na.rm))) #> [1] 0.95338 ## Visualize x <- 1:2000 plot(x, sapply(x, linear_tform), col = \"blue\")"},{"path":"/reference/logistic_tform.html","id":null,"dir":"Reference","previous_headings":"","what":"Logistic function to help set alpha opacity — logistic_tform","title":"Logistic function to help set alpha opacity — logistic_tform","text":"Suggests alpha opacity plot function number observation.","code":""},{"path":"/reference/logistic_tform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logistic function to help set alpha opacity — logistic_tform","text":"","code":"logistic_tform(n, mid_pt = 600, k_attenuation = 5, ceiling = 1, floor = 0.3)"},{"path":"/reference/logistic_tform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logistic function to help set alpha opacity — logistic_tform","text":"n Number observations plot. mid_pt Inflection point logistic curve. Defaults 600. k_attenuation steepness transition, larger sharper transition. Quite sensitive defaults 5. ceiling highest number returned. Defaults 1. floor lowest number returned. Defaults 0.3.","code":""},{"path":"/reference/logistic_tform.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logistic function to help set alpha opacity — logistic_tform","text":"scalar numeric, suggested value set alpha opacity.","code":""},{"path":[]},{"path":"/reference/logistic_tform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Logistic function to help set alpha opacity — logistic_tform","text":"","code":"library(cheem) ## Suggest an opacity to use in plotting: (my_alpha <- logistic_tform(nrow(spinifex::penguins_na.rm))) #> [1] 0.8541665 ## Visualize x <- 1:2000 plot(x, logistic_tform(x), col = \"blue\")"},{"path":"/reference/model_performance.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract higher level model performance statistics — model_performance","title":"Extract higher level model performance statistics — model_performance","text":"Internal function, used downstream cheem_ls.","code":""},{"path":"/reference/model_performance.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract higher level model performance statistics — model_performance","text":"","code":"model_performance(y, pred, label = \"label\")"},{"path":"/reference/model_performance.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract higher level model performance statistics — model_performance","text":"y Observed response, required ranger models. pred (n, 1) vector predicted values observation. Typically obtainable stats::predict(). Exact syntax arguments may change across model types. label Optionally provide character label store reminder text type model local explanation used. Defaults \"label\".","code":""},{"path":"/reference/model_performance.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract higher level model performance statistics — model_performance","text":"data.frame model performance statistics.","code":""},{"path":"/reference/penguin_xgb_pred.html","id":null,"dir":"Reference","previous_headings":"","what":"Penguins xgb model predictions and shap values — penguin_xgb_pred","title":"Penguins xgb model predictions and shap values — penguin_xgb_pred","text":"Predictions shapviz attribution xgb model Penguin data classifying penguin species.","code":""},{"path":"/reference/penguin_xgb_pred.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Penguins xgb model predictions and shap values — penguin_xgb_pred","text":"","code":"penguin_xgb_pred penguin_xgb_shap"},{"path":"/reference/penguin_xgb_pred.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Penguins xgb model predictions and shap values — penguin_xgb_pred","text":"penguin_xgb_pred n=333 length vector prediction xgb model predicting number factor level species penguin. penguin_xgb_shap (333 x 4) data frame shapviz SHAP attribution xgb model observation. Replicating object class matrix (inherits array) 333 rows 4 columns.","code":"library(cheem) library(xgboost) library(shapviz) set.seed(135) ## Classification setup X <- spinifex::penguins_na.rm[, 1:4] Y <- spinifex::penguins_na.rm$species clas <- spinifex::penguins_na.rm$species ## Model and predict peng_train <- data.matrix(X) %>% xgb.DMatrix(label = Y) peng_xgb_fit <- xgboost(data = peng_train, max.depth = 3, nrounds = 5) penguin_xgb_pred <- predict(peng_xgb_fit, newdata = peng_train) ## shapviz penguin_xgb_shap <- shapviz(peng_xgb_fit, X_pred = peng_train, X = X) penguin_xgb_shap <- penguin_xgb_shap$S if(F){ ## Don't accidentally save save(penguin_xgb_pred, file = \"./data/penguin_xgb_pred.rda\") save(penguin_xgb_shap, file = \"./data/penguin_xgb_shap.rda\") #usethis::use_data(penguin_xgb_pred) #usethis::use_data(penguin_xgb_shap) }"},{"path":"/reference/penguin_xgb_pred.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Penguins xgb model predictions and shap values — penguin_xgb_pred","text":"","code":"library(cheem) ## Classification setup X <- spinifex::penguins_na.rm[, 1:4] Y <- spinifex::penguins_na.rm$species clas <- spinifex::penguins_na.rm$species ## Precomputed predictions and shap attribtion str(penguin_xgb_pred) #> num [1:333] 0.923 0.923 0.923 0.923 0.923 ... str(penguin_xgb_shap) #> num [1:333, 1:4] -0.242 -0.206 -0.242 -0.242 -0.226 ... #> - attr(*, \"dimnames\")=List of 2 #> ..$ : NULL #> ..$ : chr [1:4] \"bill_length_mm\" \"bill_depth_mm\" \"flipper_length_mm\" \"body_mass_g\" ## 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) }"},{"path":"/reference/problem_type.html","id":null,"dir":"Reference","previous_headings":"","what":"The type of model for a given Y variable — problem_type","title":"The type of model for a given Y variable — problem_type","text":"Whether Y \"classification\", \"regression\" ill-defined problem. Returns character: \"classification\", \"regression\", error strange classes. Minor redundancy is_discrete, though explicit. useful DALEX::explain(type) also expects \"classification\" \"regression\".","code":""},{"path":"/reference/problem_type.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The type of model for a given Y variable — problem_type","text":"","code":"problem_type(y)"},{"path":"/reference/problem_type.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"The type of model for a given Y variable — problem_type","text":"y Response variable modeled","code":""},{"path":"/reference/problem_type.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"The type of model for a given Y variable — problem_type","text":"Character either c(\"classification\", \"regression\") specifying assumed model task based discreteness y.","code":""},{"path":[]},{"path":"/reference/problem_type.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"The type of model for a given Y variable — problem_type","text":"","code":"library(cheem) problem_type(mtcars$mpg) ## Numeric, many values #> [1] \"regression\" problem_type(mtcars$cyl) ## Numeric column, labeled as discrete, because less than 25 unique values #> [1] \"classification\" problem_type(letters) ## Character to classification #> [1] \"classification\" problem_type(factor(letters)) ## Factor to classification #> [1] \"classification\""},{"path":"/reference/proto_basis1d_distribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"spinifex proto_*-like function, adds distribution orthonormalized row values specified local explanation attr_df. draw basis bars; use conjunction proto_basis1d().","code":""},{"path":"/reference/proto_basis1d_distribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"","code":"proto_basis1d_distribution( attr_df, primary_obs = NULL, comparison_obs = NULL, position = c(\"top1d\", \"floor1d\", \"bottom1d\", \"off\"), group_by = as.factor(FALSE), pcp_shape = c(3, 142, 124), do_add_pcp_segments = TRUE, inc_var_nms = NULL, row_index = NULL )"},{"path":"/reference/proto_basis1d_distribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"attr_df data frame, attributions local explanation. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. Defaults NULL, highlighting. comparison_obs rownumber comparison observation. Point highlighted dotted line. Defaults NULL, highlighting. position position basis, one : c(\"top1d\", \"floor1d\", \"bottom1d\", \"\"). Defaults \"top1d\"; basis density curves. group_by Vector group densities . Originally predicted class. pcp_shape number shape character add. Expects 3, 142, 124, '+', '|' plotly, '|' gganimate, respectively. Defaults 3, '+' either output. do_add_pcp_segments Logical, whether add add faint parallel coordinate lines 1D basis. Defaults TRUE. inc_var_nms character vector, names variables keep. Defaults NULL, variables kept. row_index numeric logical vector, index rows keep. Defaults NULL, rows kept.","code":""},{"path":"/reference/proto_basis1d_distribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"ggplot object distribution local explanation's attributions.","code":""},{"path":[]},{"path":"/reference/proto_basis1d_distribution.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Adds the distribution of the row local attributions to a ggtour — proto_basis1d_distribution","text":"","code":"library(cheem) library(spinifex) #> Loading required package: tourr #> -------------------------------------------------------- #> spinifex --- version 0.3.6 #> Please share bugs, suggestions, and feature requests at: #> https://github.com/nspyrison/spinifex/issues/ #> -------------------------------------------------------- ## Regression setup dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## Basis, manipulation var, manual tour path, & predictions to fix to y-axis bas <- sug_basis(ames_rf_shap, 1) mv <- sug_manip_var(ames_rf_shap, 1, 2) mt_path <- manual_tour(bas, mv) ## Also consumed by: ?radial_cheem_tour() ## Compose and animate the tour ggt <- ggtour(mt_path, scale_sd(X), angle = .3) + append_fixed_y(fixed_y = scale_sd(Y)) + proto_point(list(color = clas, shape = clas)) + proto_basis1d_distribution( attr_df = ames_rf_shap, primary_obs = 1, comparison_obs = 2, position = \"top1d\", group_by = clas) + proto_basis1d(position = \"bottom1d\") + proto_origin() if(interactive()){ animate_plotly(ggt) }"},{"path":"/reference/radial_cheem_tour.html","id":null,"dir":"Reference","previous_headings":"","what":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"Create linked plotlyof global data- attribution- spaces. Typically consumed directly shiny app.","code":""},{"path":"/reference/radial_cheem_tour.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"","code":"radial_cheem_tour( cheem_ls, basis, manip_var, primary_obs = NULL, comparison_obs = NULL, do_add_pcp_segments = TRUE, pcp_shape = c(3, 142, 124), angle = 0.15, row_index = NULL, inc_var_nms = NULL, do_center_frame = TRUE, do_add_residual = FALSE )"},{"path":"/reference/radial_cheem_tour.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"cheem_ls return cheem_ls(), list data frames. basis 1D projection basis, typically return sug_basis(). manip_var , number manipulation variable. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. Defaults NULL, primary observation highlighted. comparison_obs rownumber comparison observation. Point highlighted dotted line. Defaults NULL, comparison observation highlighted. do_add_pcp_segments Logical, whether add parallel coordinate line segments basis display. pcp_shape number shape character add. Expects 3, 142, 124, '+', '|' plotly, '|' gganimate, respectively. Defaults 3, '+' either output. angle step size interpolated frames, radians. Defaults .15. row_index Numeric index selected observations. Defaults TRUE; 1:n. inc_var_nms vector names variables include projection. do_center_frame Whether scale standard deviations away mean within frame . Defaults TRUE, helping keep animation centered. do_add_residual Whether add facet fixed y residual. may cause issues animation. Defaults FALSE.","code":""},{"path":"/reference/radial_cheem_tour.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"ggtour (ggplot2 object frame info) animation frames radial tour manipulating contribution selected tour. Animated spinifex::animate_* functions.","code":""},{"path":[]},{"path":"/reference/radial_cheem_tour.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cheem tour; 1D manual tour on the selected attribution — radial_cheem_tour","text":"","code":"library(cheem) ## Regression setup: dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## radial_cheem_tour() ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas, label = \"North Ames, RF, SHAP\") bas <- sug_basis(ames_rf_shap, 1) mv <- sug_manip_var(ames_rf_shap, 1, 2) ggt <- radial_cheem_tour(ames_rf_chm, basis = bas, manip_var = mv) if(interactive()){ ## As a plotly html widget spinifex::animate_plotly(ggt) ## As a gganimation spinifex::animate_gganimate(ggt, render = gganimate::av_renderer()) } ## Also used in: ?run_app()"},{"path":"/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. magrittr %>%","code":""},{"path":"/reference/rnorm_from.html","id":null,"dir":"Reference","previous_headings":"","what":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"Creates new observation data given specific means shapes. typically applied cluster subset data. ie draw cluster '', assign cluster 'b'.","code":""},{"path":"/reference/rnorm_from.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"","code":"rnorm_from( data, n_obs = 1, var_coeff = 1, method = c(\"pearson\", \"kendall\", \"spearman\") )"},{"path":"/reference/rnorm_from.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"data data.frame matrix sample . n_obs Number new observations draw. Defaults 1. var_coeff Variance coefficient, closer 0 make points near median, 1 makes points away median. Defaults 1. method method covariance matrix. Expects \"person\" (continuous numeric), \"kendall\" \"spearman\" (latter two ranked based ordinal).","code":""},{"path":"/reference/rnorm_from.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"data.frame, sampled observations given means covariance data based column names kept.","code":""},{"path":[]},{"path":"/reference/rnorm_from.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Draw new samples from the supplied data given its mean and covariances. — rnorm_from","text":"","code":"library(cheem) sub <- mtcars[mtcars$cyl == 6, ] ## Draw 3 new observations in the shape of 6 cylinder vehicles, with reduced variance. rnorm_from(data = sub, n_obs = 3, var_coeff = .5) #> mpg cyl disp hp drat wt qsec vs #> 1 19.88380 6.000002 158.1386 116.8094 2.810959 3.187406 18.09336 1.2173425 #> 2 20.32516 6.000001 153.4934 118.2449 3.865130 2.917924 17.11592 0.6315653 #> 3 18.44356 6.000001 145.8528 123.7805 3.853373 3.418231 17.78607 1.2031832 #> am gear carb #> 1 -0.2173411 4.257080 3.943761 #> 2 0.3684342 4.426302 5.029821 #> 3 -0.2031841 4.584125 5.241396"},{"path":"/reference/run_app.html","id":null,"dir":"Reference","previous_headings":"","what":"Runs a shiny app demonstrating manual tours — run_app","title":"Runs a shiny app demonstrating manual tours — run_app","text":"Runs local shiny app demonstrates manual tour comparable traditional techniques static projections multivariate data sets.","code":""},{"path":"/reference/run_app.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Runs a shiny app demonstrating manual tours — run_app","text":"","code":"run_app(app_nm = \"cheem\", ...)"},{"path":"/reference/run_app.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Runs a shiny app demonstrating manual tours — run_app","text":"app_nm Name shiny app run. Expects \"cheem_initial\". ... arguments passed shiny::runApp(). display.mode = \"showcase\".","code":""},{"path":"/reference/run_app.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Runs a shiny app demonstrating manual tours — run_app","text":"Runs locally hosted shiny app.","code":""},{"path":[]},{"path":"/reference/run_app.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Runs a shiny app demonstrating manual tours — run_app","text":"","code":"## Only run this example in interactive R sessions if(interactive()){ ## Runs the app run_app(\"cheem\") ## Run with app code displayed run_app(app_nm = \"cheem\", display.mode = \"showcase\") }"},{"path":"/reference/subset_cheem.html","id":null,"dir":"Reference","previous_headings":"","what":"Subset a cheem list — subset_cheem","title":"Subset a cheem list — subset_cheem","text":"Given numerical index rownumbers original data, subset correct elements cheem list.","code":""},{"path":"/reference/subset_cheem.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subset a cheem list — subset_cheem","text":"","code":"subset_cheem(cheem_ls, rownumbers = 1:500)"},{"path":"/reference/subset_cheem.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subset a cheem list — subset_cheem","text":"cheem_ls return cheem_ls() call. rownumbers vector numeric index rownumbers keep. use logical index, pass (), eg. idx <- (mtcars$mpg > 30).","code":""},{"path":"/reference/subset_cheem.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subset a cheem list — subset_cheem","text":"subset supplied cheem_ls.","code":""},{"path":[]},{"path":"/reference/subset_cheem.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subset a cheem list — subset_cheem","text":"","code":"library(cheem) ## Classification setup X <- spinifex::penguins_na.rm[, 1:4] Y <- spinifex::penguins_na.rm$species clas <- spinifex::penguins_na.rm$species ## Cheem peng_chm <- cheem_ls(X, Y, penguin_xgb_shap, penguin_xgb_pred, clas, label = \"Penguins, xgb, shapviz\") lapply(peng_chm, NROW) #> $type #> [1] 1 #> #> $model_performance #> [1] 1 #> #> $attr_df #> [1] 333 #> #> $global_view_df #> [1] 999 #> #> $global_view_basis_ls #> [1] 2 #> #> $decode_df #> [1] 333 #> ## subset a cheem list num_idx <- which(spinifex::penguins_na.rm$flipper_length_mm > 185) peng_chm_sub <- subset_cheem(peng_chm, num_idx) lapply(peng_chm_sub, NROW) #> $type #> [1] 1 #> #> $model_performance #> [1] 1 #> #> $attr_df #> [1] 294 #> #> $global_view_df #> [1] 882 #> #> $global_view_basis_ls #> [1] 2 #> #> $decode_df #> [1] 294 #> ## Notice that $global_view_df and $decode_df have fewer rows."},{"path":"/reference/sug_basis.html","id":null,"dir":"Reference","previous_headings":"","what":"Suggest a 1D Basis — sug_basis","title":"Suggest a 1D Basis — sug_basis","text":"Extract formats 1D attribution basis provided local explanation.","code":""},{"path":"/reference/sug_basis.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Suggest a 1D Basis — sug_basis","text":"","code":"sug_basis(attr_df, rownum)"},{"path":"/reference/sug_basis.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Suggest a 1D Basis — sug_basis","text":"attr_df data frame local explanation attributions. rownum rownumber observation. Typically primary comparison observations.","code":""},{"path":"/reference/sug_basis.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Suggest a 1D Basis — sug_basis","text":"matrix 1D basis.","code":""},{"path":[]},{"path":"/reference/sug_basis.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Suggest a 1D Basis — sug_basis","text":"","code":"library(cheem) ## Attribution basis of the primary instance sug_basis(ames_rf_shap, rownum = 1) #> data.frame #> LotArea 0.85497616 #> OverallQual 0.21436882 #> YearBuild 0.05907171 #> LivingArea 0.42354666 #> Bathrms -0.02586855 #> Bedrms 0.01659048 #> TotRms 0.05857403 #> GarageYrBlt 0.08939046 #> GarageArea 0.16677691 ## This can be used to find a basis to start the radial tour. # ?radial_cheem_tour ## Regression setup: dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## radial_cheem_tour() ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas, label = \"North Ames, RF, SHAP\") bas <- sug_basis(ames_rf_shap, 1) mv <- sug_manip_var(ames_rf_shap, 1, 2) ggt <- radial_cheem_tour(ames_rf_chm, basis = bas, manip_var = mv) if(interactive()){ ## As a plotly html widget spinifex::animate_plotly(ggt) ## As a gganimation spinifex::animate_gganimate(ggt, render = gganimate::av_renderer()) } ## radial_cheem_tour is also used in: ?run_app()"},{"path":"/reference/sug_manip_var.html","id":null,"dir":"Reference","previous_headings":"","what":"Suggest a manipulation variable — sug_manip_var","title":"Suggest a manipulation variable — sug_manip_var","text":"Suggest number variable largest difference attribution primary comparison observations.","code":""},{"path":"/reference/sug_manip_var.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Suggest a manipulation variable — sug_manip_var","text":"","code":"sug_manip_var(attr_df, primary_obs, comparison_obs)"},{"path":"/reference/sug_manip_var.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Suggest a manipulation variable — sug_manip_var","text":"attr_df data frame local explanation attributions. primary_obs rownumber primary observation. local attribution becomes 1d projection basis, point highlighted dashed line. comparison_obs rownumber comparison observation. Point highlighted dotted line.","code":""},{"path":"/reference/sug_manip_var.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Suggest a manipulation variable — sug_manip_var","text":"single number variable largest difference attribution (basis) variables.","code":""},{"path":[]},{"path":"/reference/sug_manip_var.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Suggest a manipulation variable — sug_manip_var","text":"","code":"library(cheem) ## Regression setup dat <- amesHousing2018_NorthAmes X <- dat[, 1:9] Y <- dat$SalePrice clas <- dat$SubclassMS ## Suggest the number of a variable to manipulate sug_manip_var(ames_rf_shap, primary_obs = 1, comparison_obs = 2) #> [1] 4 ## This can be used to find a basis to start the radial tour. # ?radial_cheem_tour"},{"path":"/news/index.html","id":"cheem-v040","dir":"Changelog","previous_headings":"","what":"cheem v0.4.0","title":"cheem v0.4.0","text":"Repaired packagedown site! Fixed news packagedown site. Shiny app go buttons rather waiting every input change. Shiny app text, plot dimensions, text cleaned . Classification tour now uses horizontal layout. Cleaned text facet panels global_tour() radial_cheem_tour(). Removed support basis_type argument. support alternative bases types really extension analysis. Recreate saved classification model, fit well work illustrations. Set seed consistently. model attribution shifted bit, replicable going forward. Minor documentation code clean clarifications.","code":""},{"path":"/news/index.html","id":"cheem-v030--generalized-for-any-attribution","dir":"Changelog","previous_headings":"","what":"cheem v0.3.0 – Generalized for any attribution","title":"cheem v0.3.0 – Generalized for any attribution","text":"CRAN release: 2023-05-08 Rebase functions expecting unified treeshap::shap() generalized data frame matrix format arbitrary attribution spaces. Rework vignette examples reflect change. Added precomputed predictions attributions Ames, Chocolates, Penguins datasets. allows users run attribution-agnostic functions without dependencies. Add subset_cheem(), convenience function subsetting cheem lists construction. Removed plotly subplot variations visuals: global_view_subplots(), radial_cheem_tour_subplots(). development variations never used shiny app. Minor function renames parsimony consistency.","code":""},{"path":"/news/index.html","id":"cheem-v020-cran-releases-here-on-out","dir":"Changelog","previous_headings":"","what":"cheem v0.2.0 (CRAN releases here on out)","title":"cheem v0.2.0 (CRAN releases here on out)","text":"CRAN release: 2022-03-14","code":""},{"path":"/news/index.html","id":"app-related-changes-0-2-0","dir":"Changelog","previous_headings":"","what":"App related changes","title":"cheem v0.2.0 (CRAN releases here on out)","text":"Added vignette: Getting started cheem. Added pkgdown site: https://nspyrison.github.io/cheem/. Added global model performance metrics shiny app. global_view(), added yhaty panel (residual plot/confusion matrix). global_view(), added color options: log_maha.data cor_attr.y. cheem_radial_tour(), added regression case panel additional fixed y residual. app radial tour inputs, added inclusion variable, subsetting variables used radial tour. plotly::subplot() variants global_view() & cheem_radial_tour(). Added AmesHousing data, chocolates, new toy simulated datasets (shiny app ). Reduced shiny app wording.","code":""},{"path":"/news/index.html","id":"internal--utilities-0-2-0","dir":"Changelog","previous_headings":"","what":"Internal & utilities","title":"cheem v0.2.0 (CRAN releases here on out)","text":"Major rebase cheem_ls(). Added linear/logistic_tform() suggest alpha function number observations.","code":""},{"path":"/news/index.html","id":"sourcing-treeshap-0-2-0","dir":"Changelog","previous_headings":"","what":"Sourcing treeshap","title":"cheem v0.2.0 (CRAN releases here on out)","text":"drat repository hosting treeshap work debian window rhub platforms; Minimally ported functions cpp source files @author & @source. Changed examples consistency smaller code base support. v0.3.0, cheem generalized local variable attributions, concern.","code":""},{"path":[]},{"path":"/news/index.html","id":"primary-preprocessing-functions-0-1-0","dir":"Changelog","previous_headings":"","what":"Primary preprocessing functions","title":"cheem v0.1.0 (GitHub only, commit 283da4)","text":"default_rf() create randomForest::randomForest() conservative defaults. attr_df_treeshap() create treeshap::treeshap() local explanations observation. cheem_ls() create cheem list prepared tables use run_app().","code":""},{"path":"/news/index.html","id":"primary-visual-functions-0-1-0","dir":"Changelog","previous_headings":"","what":"Primary visual functions","title":"cheem v0.1.0 (GitHub only, commit 283da4)","text":"run_app() shiny app consuming following two: global_view() linked ‘plotly’ approximations data- attribution-spaces model information. cheem_radial_tour() create spinifex::ggtour specified radial tour. Consumed animate_plotly, animate_gganimate, filmstrip.","code":""}]