trustyai.explainers.SHAPResults

class trustyai.explainers.SHAPResults(saliency_results: SaliencyResults, background)

Wraps SHAP results. This object is returned by the SHAPExplainer, and provides a variety of methods to visualize and interact with the explanation.

__init__(saliency_results: SaliencyResults, background)

Constructor method. This is called internally, and shouldn’t ever need to be used manually.

Methods

__init__(saliency_results, background)

Constructor method.

as_dataframe()

Return the SHAP results as dataframes.

as_html()

Return the SHAP results as Pandas Styler objects.

get_fnull()

Return the list of the found fnulls (y-intercepts) of the SHAP explanations

saliency_map()

Return a dictionary of found saliencies.

as_dataframe() Dict[str, DataFrame]

Return the SHAP results as dataframes.

Returns:
Dict[str, pandas.DataFrame]

Dictionary of DataFrames, keyed by output name, containing the results of the SHAP explanation. For each model output, the table will contain the following columns:

  • Feature: The name of the feature

  • Feature Value: The value of the feature for this particular input.

  • Mean Background Value: The mean value this feature took in the background

  • SHAP Value: The found SHAP value of this feature.

  • Confidence: The confidence of this explanation as returned by the explainer.

as_html() Dict[str, Styler]

Return the SHAP results as Pandas Styler objects.

Returns:
Dict[str, pandas.Styler]

Dictionary of stylers keyed by output name. Each styler containing the results of the SHAP explanation for that particular output, in the same schema as in as_dataframe(). This will:

  • Color each Feature Value based on how it compares to the corresponding Mean Background Value.

  • Color each SHAP Value based on how their magnitude.

get_fnull()

Return the list of the found fnulls (y-intercepts) of the SHAP explanations

Returns:
Array[float]

An array of the y-intercepts, in order of the model outputs.

saliency_map() Dict[str, Saliency]

Return a dictionary of found saliencies.

Returns:
Dict[str, Saliency]

A dictionary of Saliency objects, keyed by output name.