kernelshap_tabular
Module Contents
Classes
Wrapper around the SHAP Kernel explainer for tabular data. |
- class kernelshap_tabular.KERNELSHAPTabular(training_data: numpy.array, mode: str = 'classification', feature_names: List[int] = None, training_data_kmeans: int | None = None)[source]
Wrapper around the SHAP Kernel explainer for tabular data.
- explain(model_or_function: str | callable, input_tabular: numpy.array, link: str = 'identity', **kwargs) numpy.array [source]
Run the KernelSHAP explainer.
- Parameters:
model_or_function (callable or str) – The function that runs the model to be explained or the path to a ONNX model on disk.
input_tabular (np.ndarray) – Data to be explained.
link (str) – A generalized linear model link to connect the feature importance values to the model. Must be either “identity” or “logit”.
kwargs – These parameters are passed on
Other keyword arguments: see the documentation for KernelExplainer: https://github.com/shap/shap/blob/master/shap/explainers/_kernel.py
- Returns:
An array (np.ndarray) containing the KernelExplainer explanations for each class.