baybe.insights.shap.make_explainer_for_surrogate¶
- baybe.insights.shap.make_explainer_for_surrogate(surrogate: Surrogate, data: DataFrame, explainer_cls: type[Explainer] | str = 'KernelExplainer', *, use_comp_rep: bool = False)[source]¶
Create a SHAP explainer for a given surrogate model.
- Parameters:
surrogate (
Surrogate
) – The surrogate model to be explained.data (
DataFrame
) – The background data set.explainer_cls (
type
[Explainer
] |str
) – The SHAP explainer class for generating the explanation.use_comp_rep (
bool
) – Boolean flag specifying whether to explain the model’s experimental or computational representation.
- Return type:
- Returns:
The created explainer object.
- Raises:
ValueError – If the provided background data set is empty.
TypeError – If the provided explainer class is incompatible with the surrogate.