How to extract variable/contribution order from DALEX breakdown object?

Hi all,
I recently built breakdown plots for some of my caret prediction models using the DALEX package.

bd <- predict_parts(..., type = "break_down")

works fine in plain R and shiny, but I now need to bring these plots into a specific business intelligence tool. There's no problem creating a waterfall diagram there and no problem extracting variables and contributions from bd object in R.
But I can't figure out how to "tell" the BI tool the right order of variables in the breakdown plot. At first, I thougt field "position" would do this, but that gives the same order for all observations (not matching the R plot). I also tried predict_parts_break_down(), which resulted in different values for "position", but also did not match the order in the original R plots.
Does anybody know how to extract the correct order from the breakdown object?
I think that this must also be passed to the plot function in R somehow, but unfortunately I have not been able to get the corresponding source code of "plot" either.
Would be grateful for any help! Thanks!


Could you provide us with a reprex so we can see what it is you are trying to achieve. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:

Good luck,

Thank you very much for your response and the explanation of reprex, PJ.
I made it work by myself, after I had found the source code of plot.break_down on
Field "position" returns the correct order, but one has to first determine the ten (or how many variables you want to show) most contributing variables and then evaluate position only for those.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.