Skip to contents

Breaks the model's prediction for a single casualty into per-predictor contributions, using SHAP values. This answers "why this casualty?", as opposed to importance, which answers "what does this model use in general?".

Usage

sdt_shap(x, casualty, data = NULL, n_permutations = 10L)

Arguments

x

An sdt_model from sdt_fit(), or an explainer from sdt_explain().

casualty

A one-row data frame, or the id of a casualty in data.

data

Optional data to explain on, passed to sdt_explain(). Also where casualty is looked up when given as an id.

n_permutations

Number of sampling rounds for the SHAP estimate.

Value

A ggplot2 object.

Examples

# See ?sdt_importance for a runnable example.
sdt_engines()
#> # A tibble: 9 × 4
#>   engine      package class_box installed
#>   <chr>       <chr>   <chr>     <lgl>    
#> 1 tree        rpart   glass     TRUE     
#> 2 multinom    nnet    glass     TRUE     
#> 3 glmnet      glmnet  glass     TRUE     
#> 4 mars        earth   grey      TRUE     
#> 5 xgboost     xgboost grey      TRUE     
#> 6 ranger      ranger  black     TRUE     
#> 7 svm_rbf     kernlab black     TRUE     
#> 8 mlp         nnet    black     TRUE     
#> 9 transformer keras3  closed    TRUE