ModelOriented / iBreakDown

Break Down with interactions for local explanations (SHAP, BreakDown, iBreakDown)
https://ModelOriented.github.io/iBreakDown/
GNU General Public License v3.0
81 stars 15 forks source link

Hidden last contribution label in the break_down plot #85

Closed hbaniecki closed 4 years ago

hbaniecki commented 4 years ago

@hbaniecki Thank you for pointing us the docs for iBreakDown, etc.! I don't know if this is helpful but I got this minor issue a while ago for binary classification models. The prediction for the positive cases works fine, but for negative cases the prediction becomes unreadable. image

adding vcolors to the generic plot function worked for me:

bd_glm <- variable_attribution(explainer_glm, 
                               new_observation = x_test[1,],
                               type="break_down")

bd_glm2 <- variable_attribution(explainer_glm,
                                new_observation = x_test[30,],
                                type="break_down")
bd_colors <- c("#f05a71","#4378bf", "#8bdcbe", "#ffa58c")

p1 <- plot(bd_glm2, vcolors = bd_colors)
p2 <- plot(bd_glm, vcolors = bd_colors)

image

Thanks for your reply!

Originally posted by @marcjermaine-pontiveros in https://github.com/ModelOriented/DALEX/issues/176#issuecomment-617911303

hbaniecki commented 4 years ago

This issue was reported numerous times. A possible solution (implemented in modelStudio) is to place the prediction number on the left side of the prediction bar (so it is always visible).

Edit: Unable to resolve, because the baseline parameter makes this situation hard to detect, and nudge_y is not an aes parameter.

pbiecek commented 4 years ago

@hbaniecki would you check if d574460 solves this issue? maybe I've missed something

hbaniecki commented 4 years ago

My intention was to place this text on the left side of the bar. The candidate fix is still better than no fix. Can we do the same for the intercept bar? See

library("DALEX")
library("iBreakDown")
set.seed(1313)
model_titanic_glm <- glm(survived ~ gender + age + fare,
                         data = titanic_imputed, family = "binomial")
explain_titanic_glm <- explain(model_titanic_glm,
                               data = titanic_imputed,
                               y = titanic_imputed$survived,
                               label = "glm")

bd_glm <- local_attributions(explain_titanic_glm, titanic_imputed[1, ])
bd_glm
plot(bd_glm, max_features = 3, baseline=0.5)
pbiecek commented 4 years ago

thanks, in a979cb4 the positioning works also for the intercept.

now it's on the right side, in next version we can add an option for this

hbaniecki commented 4 years ago

Thanks