Skip to content

shap

get_shap_values

get_shap_values(
    estimator, test_x, attribute_names=None, **kwargs
) -> ndarray

Computes SHAP (SHapley Additive exPlanations) values for the model's predictions on the given input features.

Parameters:

Name Type Description Default
test_x Union[DataFrame, ndarray]

The input features to compute SHAP values for.

required
kwargs dict

Additional keyword arguments to pass to the SHAP explainer.

{}

Returns:

Type Description
ndarray

np.ndarray: The computed SHAP values.

plot_shap

plot_shap(shap_values: ndarray)

Plots the shap values for the given test data. It will plot aggregated shap values for each feature, as well as per sample shap values. Additionally, if multiple samples are provided, it will plot the 3 most important interactions with the most important feature.

Parameters:

Name Type Description Default
shap_values ndarray
required