deepmol.feature_importance package

Submodules

deepmol.feature_importance.shap_values module

class ShapValues(explainer: str = 'permutation', masker: str | None = None)[source]

Bases: object

SHAP (SHapley Additive exPlanations) wrapper for DeepMol It allows to compute and analyze the SHAP values of DeepMol models.

bar_plot(path: str | None = None, **kwargs) None[source]

Plot the SHAP values of all the features as a beeswarm plot.

Parameters:
beeswarm_plot(path: str | None = None, **kwargs) None[source]

Plot the SHAP values of all the features as a beeswarm plot.

Parameters:
decision_plot(path: str | None = None, **kwargs) None[source]

Plot the SHAP values of all the features as a decision plot.

Parameters:
feature_explanation_plot(index: int, path: str | None = None, **kwargs) None[source]

Plot the SHAP values of a single feature.

Parameters:
fit(dataset: Dataset, model: Model, **kwargs) Explanation[source]

Compute the SHAP values for the given dataset and model.

Parameters:
  • dataset (Dataset) – The dataset to compute the SHAP values for.

  • model (Model) – The model to compute the SHAP values for.

  • kwargs (dict) – Additional arguments for the SHAP explainer.

Returns:

shap_values – The SHAP values.

Return type:

np.array

heatmap_plot(path: str | None = None, **kwargs) None[source]

Plot the SHAP values of all the features as a heatmap.

Parameters:
negative_class_plot(path: str | None = None, **kwargs) None[source]

Plot the SHAP values of the positive class as a bar plot.

Parameters:
positive_class_plot(path: str | None = None, **kwargs) None[source]

Plot the SHAP values of the positive class as a bar plot.

Parameters:
sample_explanation_plot(index: int, plot_type: str = 'waterfall', path: str | None = None, **kwargs) None[source]

Plot the SHAP values of a single sample.

Parameters:
  • index (int) – Index of the sample to explain

  • plot_type (str) – Type of plot to use. Can be ‘waterfall’ or ‘force’

  • path (str) – Path to save the plot to.

  • kwargs – Additional arguments for the plot function. see:https://github.com/slundberg/shap/blob/45b85c1837283fdaeed7440ec6365a886af4a333/shap/plots/_force.py#L33 https://github.com/slundberg/shap/blob/45b85c1837283fdaeed7440ec6365a886af4a333/shap/plots/_waterfall.py#L18

Module contents