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.
Return the SHAP results as dataframes.
as_html()Return the SHAP results as Pandas Styler objects.
Return the list of the found fnulls (y-intercepts) of the SHAP explanations
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 featureFeature Value: The value of the feature for this particular input.Mean Background Value: The mean value this feature took in the backgroundSHAP 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 Valuebased on how it compares to the correspondingMean Background Value.Color each
SHAP Valuebased 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
Saliencyobjects, keyed by output name.