Local attributions plot too wide due to unrounded model values
Closed this issue · 6 comments
For regressions, the table returned by local_attributions()
contains values that are not rounded (left column):
contribution
rf model: intercept 4.085
rf model: joy = 0 -0.539
rf model: negative = 0.5 -0.380
rf model: disgust = 0.214285714285714 -0.684
This would not be an issue, however, the plot becomes too wide which narrows the main plot:
Is there any way to round the decimal values in the y-axis?
Thansk, very important point,
can you give a reproducible example?
We are using the iBreakDown::nice_format
to round values (by default with signif(,4)).
and I cannot reproduce this problem because numerics are rounded in examples that I've tried/
By default names are rounded with signif(,4)
,
but now you can overwrite labels with the vnames
argument
see b2e96a0
It would still be great if the labels could be created automatically without using vnames.
I prepared a reproducible example with this model
Please use it like this:
models.list.short <- readRDS("models.list.short.rds")
model.rf <- models.list.short$rf
local.obs <- models.list.short$testing.set %>%
# filter(reviews.rating != 5 & reviews.rating != 4) %>%
filter(reviews.rating == TARGET.VALUE) %>%
select(-reviews.rating) %>%
sample_n(5)
DALEX.explainer <- DALEX::explain(
model = model.rf,
data = features,
y = target == TARGET.VALUE,
label = paste(model_object$method, " model"),
colorize = TRUE
)
DALEX.attribution <- DALEX.explainer %>%
iBreakDown::local_attributions(
local.obs,
keep_distributions = TRUE
)
DALEX.attribution.plot <- DALEX.attribution %>%
plot(
digits = 3,
shift_contributions = 0.03
) %>% print
@agilebean for some strange reason the problem comes from local.obs being a tibble.
this will work properly with local.obs converted to data.frame
DALEX.attribution <- DALEX.explainer %>%
iBreakDown::local_attributions(
as.data.frame(local.obs),
keep_distributions = TRUE
)
That is truly unexpected.
Thanks for finding that out!!
It's because for tibbles the local.obs[1,1]
is not numeric (it's still tilbble)
so iBreakDown does not know how to prettify and treats these values as characters