Code snippets
- Compute Shapley values for Henry
set.seed(11)
shap_henry <- predict_parts(explainer = explain_rf,
new_observation = henry,
type = "shap",
B = 25)
shap_henry
## min q1 median
## New Random Forest: age = 47 -0.14872225 -0.110022429 -0.058946498
## New Random Forest: class = 1st 0.10779338 0.168543072 0.182437245
## New Random Forest: embarked = Cherbourg 0.01765473 0.020325329 0.045746262
## New Random Forest: fare = 25 -0.03364295 -0.026465791 -0.009764386
## New Random Forest: gender = male -0.15356865 -0.143723154 -0.131250657
## New Random Forest: parch = 0 -0.02327322 -0.007531944 -0.003043951
## New Random Forest: sibsp = 0 -0.03593203 -0.011468962 -0.002637970
## mean q3 max
## New Random Forest: age = 47 -0.070780172 -0.0230765745 -0.016705029
## New Random Forest: class = 1st 0.175533412 0.1851354780 0.243139103
## New Random Forest: embarked = Cherbourg 0.050332941 0.0771913004 0.106751246
## New Random Forest: fare = 25 -0.002019465 0.0055777073 0.065804259
## New Random Forest: gender = male -0.131233530 -0.1250222021 -0.105236973
## New Random Forest: parch = 0 -0.005057907 -0.0008337109 0.004019030
## New Random Forest: sibsp = 0 -0.006084749 0.0022025374 0.007650204