ModelOriented/iBreakDown

Request: Order the break_down like the old prediction_breakdown

brunocarlin opened this issue · 3 comments

I think it improves readability if the columns are ordered either ascending or descending

Would you give a code example that produces columns that are not ordered?

I can't really share the data, but here is the code and the picture with the results

library(tidyverse)
library(DALEX)
library(tictoc)
# convert feature data to non-h2o objects
x_valid <- df_testing %>% select(-default)

# make response variable numeric binary vector
y_valid <- as.vector(as.numeric(as.character(df_testing$default)))

# create custom predict function
pred_custom <- function(model, newdata)  {
  results <- as.data.frame(h2o.predict(model, as.h2o(newdata)))
  return(results[[3L]])
}
tic("dalex")
tic("explainer")
explainer_h2o_automl <- explain(
  model = best_h2o,
  data = x_valid,
  y = y_valid,
  predict_function = pred_custom,
  label = "h2o_automl"
)
toc()

tic("model_performance")
mp_h2o_automl <- model_performance(explainer_h2o_automl)
toc()

test_observation <- df_testing[1:1,]
tic("break_down")
bd_h2o_automl <- iBreakDown::break_down(explainer_h2o_automl,
                                        new_observation = test_observation)
toc()

bd_h2o_automl %>% plot()

image

As you can see there is no order of contributions to be ploted this worked fine on the old DALEX

new release (v 1.0) is currently tested, maybe it will solve this issue.
if not, please note that you can specify the order directly with the order argument in the plot()
or you can use shap function instead of break_down, for shap the contributions are automatically sorted