tabensemb.model.CatEmbed.cal_shap#
method
- CatEmbed.cal_shap(model_name: str, call_general_method: bool = False, return_importance: bool = True, n_background: int = 100, init_kwargs: Dict | None = None, shap_values_kwargs: Dict | None = None, indices: Iterable | None = None, **kwargs) ndarray#
Calculate SHAP values using a specified model. The
shap.DeepExplaineris used.- Parameters:
- model_name
The selected model in the model base.
- call_general_method
Call the general shap calculation
AbstractModel.cal_shap()instead of the optimized procedure for deep learning models. This is useful when calculating the feature importance of models that require other models.- return_importance
True to return mean absolute SHAP values. False to return
shap.DeepExplainer,shap.Explanation, and results of :meth:shap.DeepExplainer.shap_values- n_background
Number of randomly sampled background (training) data passed to
shap.DeepExplainer.- init_kwargs
Arguments of
shap.DeepExplainer.__init__- shap_values_kwargs
Arguments of
shap.DeepExplainer.shap_values- indices
The indices of data points where shap values are evaluated
- kwargs
Ignored.
- Returns:
- attr
The SHAP values. All features including derived unstacked features will be included.