Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in shap on model with one variable #93

Closed
hbaniecki opened this issue Apr 2, 2021 · 0 comments
Closed

Error in shap on model with one variable #93

hbaniecki opened this issue Apr 2, 2021 · 0 comments
Assignees
Labels
bug 💣 Bug to fix

Comments

@hbaniecki
Copy link
Member

hbaniecki commented Apr 2, 2021

related to: ModelOriented/modelStudio#99

library(DALEX)
titanic_imputed_sub <- subset(titanic_imputed, select = c("survived", "class"))
model_titanic <- glm(survived ~ class, data = titanic_imputed_sub, family = "binomial")

# create an explainer for the model
explainer_titanic <- explain(model_titanic,
                             data = titanic_imputed_sub[,2, drop=FALSE],
                             y = titanic_imputed$survived,
                             label = "Titanic GLM")

sh <- iBreakDown::shap(explainer_titanic, titanic_imputed_sub[1,,drop=FALSE])
plot(sh)

library(ranger)
temp <- subset(HR, select = c("status", "age"))
model_ranger <- ranger(status ~., temp, probability = TRUE)
explainer_ranger <- explain(model_ranger,
                            data = temp[,2, drop=FALSE],
                            y = temp$status)
sh <- iBreakDown::shap(explainer_ranger, B=2,
                       new_observation = temp[1, ,drop=FALSE])
plot(sh)
@hbaniecki hbaniecki added the bug 💣 Bug to fix label Apr 2, 2021
@hbaniecki hbaniecki self-assigned this Apr 2, 2021
hbaniecki added a commit that referenced this issue Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 💣 Bug to fix
Projects
None yet
Development

No branches or pull requests

1 participant