Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Remove the show argument in shap.plots #3819

Open
2 tasks
connortann opened this issue Aug 20, 2024 · 0 comments
Open
2 tasks

ENH: Remove the show argument in shap.plots #3819

connortann opened this issue Aug 20, 2024 · 0 comments
Labels
BREAKING Indicates that a PR is introducing a breaking change visualization Relating to plotting

Comments

@connortann
Copy link
Collaborator

connortann commented Aug 20, 2024

Problem Description

At present the plotting functions accept a parameter show which defaults to True, which calls plt.show(). I suggest changing the default behaviour to not call plt.show, and deprecating the show parameter.

Rationale

Overall I think this parameter creates needless complexity for no added value.

  • It's not needed. In typical notebook environments (e.g. VS Code, jupyter, jupyterlab), matplotlib plots are rendered automatically without needing to call plt.show().
  • It can be frustrating, as plots can displaying twice (once by plt.show, and again by the notebook environment).
  • It makes the API more complex. Other common plotting libraries (e.g. seaborn) do not have this parameter, as far as I know. Our plotting modules are already complicated enough as is!

API complexity

We generally want to return ax to fit with matplotlib's recommended signature, but this is only workable before plt.show() is called. At present we have to return the ax only if show=False, and otherwise return None.

This means the type signatures need to be quite complex:

@overload
def plot(..., show: Literal[True]) -> None: ...
@overload
def plot(..., show: Literal[False]) -> plt.Axes: ...
def plot(..., show: bool) -> plt.Axes | None: ...

The simpler API could just be:

def plot(...) -> plt.Axes

Suggested implementation plan

@connortann connortann added enhancement Indicates new feature requests visualization Relating to plotting labels Aug 20, 2024
@connortann connortann changed the title ENH: Deprecate the show argument in shap.plots ENH: Remove the show argument in shap.plots Aug 20, 2024
@connortann connortann added BREAKING Indicates that a PR is introducing a breaking change and removed enhancement Indicates new feature requests labels Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING Indicates that a PR is introducing a breaking change visualization Relating to plotting
Projects
None yet
Development

No branches or pull requests

1 participant