midlearn.plot_shapley
- midlearn.plot_shapley(shapley: MIDShapley, style: Literal['beeswarm', 'violinplot', 'waterfall', 'barplot', 'scatter'] = 'beeswarm', instances: Any | None = None, variables: Any | None = None, **kwargs)[source]
Visualize the calculated SHAP Explanation object with the shap library. This function provides a unified plotting interface for MID-derived Shapley values, wrapping various shap.plots functions.
- Parameters:
shapley (MIDShapley) – A calculated SHAP Explanation wrapper object containing the term contributions.
style ({'beeswarm', 'violinplot', 'waterfall', 'barplot', 'scatter'}, default 'beeswarm') – The plotting style. ‘beeswarm’ displays a summary plot showing the distribution of SHAP values for each feature across all samples. ‘violinplot’ displays a summary plot using violin plots instead of beeswarm scatter points. ‘waterfall’ displays contributions for a single prediction as a cascading plot, starting from the expected value. ‘barplot’ displays the global mean absolute SHAP values (for multiple samples) or local SHAP values (for a single sample) as simple horizontal bars. ‘scatter’ displays a scatter plot of SHAP values for a specific feature to show its dependence and interaction effects.
instances (int, list of int, or slice, default None) – Specific instances (row indices) to plot. If None, all instances are used. For ‘waterfall’, it is highly recommended to specify a single row (e.g., instances=0).
variables (str, list of str, int, or list of int, default None) – Specific variables (column names) to plot. If None, all variables are used.
**kwargs (dict) – Additional keyword arguments forwarded to the underlying shap.plots functions.