tabensemb.trainer.Trainer.cal_shap#
method
- Trainer.cal_shap(program: str, model_name: str, **kwargs) ndarray[source]#
Calculate SHAP values using a specified model. If the model base is a
tabensemb.model.TorchModel, theshap.DeepExplaineris used. Otherwise,shap.KernelExplaineris called, which is much slower, and shap.kmeans is called to summarize the training data to 10 samples as the background data and 10 random samples in the testing set is explained, which will bias the results.- Parameters:
- program
The selected model base.
- model_name
The selected model in the model base.
- kwargs
kwargs for
tabensemb.model.AbstractModel.cal_shap()
- Returns:
- attr
The SHAP values. If the model base is a TorchModel, all features including derived unstacked features will be included. Otherwise, only
all_feature_names()will be considered.