dsgibbons/shap

Refactor `_violin` plot code and add examples

Opened this issue · 0 comments

Background

violin, beeswarm and bar plots were initially housed under the same summary() function (currently stored in _beeswarm.py as summary_legacy(), see here). At some point, slundberg refactored the code to split out the various plot types into their own individual functions.

The violin() function in _violin.py was pretty much just a copy of the original implementation in summary(), and while some amount of "dead" and irrelevant (for violin plotting) code was removed in #54 , I think we can still do some improvements.

Todo

  • Refactor violin() function signature to be more like beeswarm(). Importantly, I want to deprecate the passing of numpy array to violin, and only accept Explanation objects. See how it's implemented here in beeswarm(). This will unify the APIs for the plotting functions. If users want to use the numpy array, they can use summary_legacy().
  • Ensure docstrings for violin are correct and reflect the new API.
  • Add more comprehensive tests for violin, especially using the new syntax / function signature.
  • Add a violin plotting example to the front page README and an API example notebook, like this for beeswarm.