deepmol.feature_importance package

Submodules

deepmol.feature_importance.shap_values module

class ShapValues(dataset: Dataset, model: Model)[source]

Bases: object

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

computeExactShap(masker: bool = False, plot: bool = True, **kwargs)[source]

Compute the SHAP values using the Exact explainer.

Parameters
  • masker (bool) – If True, use a Partition masker to explain the model predictions on the given dataset

  • plot (bool) – If True, plot the SHAP values

  • kwargs (dict) – Additional arguments for the plot function

computePermutationShap(masker: bool = False, plot: bool = True, max_evals: int = 500, **kwargs)[source]

Compute the SHAP values using the Permutation explainer.

Parameters
  • masker (bool) – If True, use a Partition masker to explain the model predictions on the given dataset

  • plot (bool) – If True, plot the SHAP values

  • max_evals (int) – Maximum number of iterations

  • kwargs (dict) – Additional arguments for the plot function

plotFeatureExplanation(index: Optional[int] = None, **kwargs)[source]

Plot the SHAP values of a single feature.

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

  • kwargs – Additional arguments for the plot function.

plotHeatMap(**kwargs)[source]

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

Parameters

kwargs – Additional arguments for the plot function.

plotSampleExplanation(index: int = 0, plot_type: str = 'waterfall', **kwargs)[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’

  • kwargs – Additional arguments for the plot function.

Module contents