tabensemb.model.PytorchTabular.cal_shap#

method

PytorchTabular.cal_shap(model_name: str, return_importance: bool = True, n_background: int = 10, explainer: str = 'KernelExplainer', init_kwargs: Dict | None = None, call_kwargs: Dict | None = None, indices: Iterable | None = None, **kwargs) ndarray#

Calculate SHAP values using a specified model. shap.kmeans is called to summarize the training data as the background data.

Parameters:
model_name

The selected model in the model base.

return_importance
True to return mean absolute SHAP values. False to return shap.Explainer, shap.Explanation,

and results of :meth:shap.Explainer.shap_values

n_background

Number of background data passed to shap.Explainer as data.

indices

The indices of data points where shap values are evaluated

explainer

The name of an explainer available at shap.

init_kwargs

Arguments of explainer.__init__

call_kwargs

Arguments of ``explainer.__call__`

kwargs

Ignored.

Returns:
attr

The SHAP values.