Local White Box Explainers

Contrastive Explainers

SHAP Explainers

class aix360.algorithms.shap.shap_wrapper.GradientExplainer(*argv, **kwargs)

This class wraps the source class GradientExplainer available in the SHAP library. Additional variables or functions from the source class can also be accessed via the ‘explainer’ object variable that is initialized in ‘__init__’ function of this class.

Initialize shap kernelexplainer object.

explain_instance(*argv, **kwargs)

Explain one or more input instances.

set_params(*argv, **kwargs)

Optionally, set parameters for the explainer.

class aix360.algorithms.shap.shap_wrapper.DeepExplainer(*argv, **kwargs)

This class wraps the source class DeepExplainer available in the SHAP library. Additional variables or functions from the source class can also be accessed via the ‘explainer’ object variable that is initialized in ‘__init__’ function of this class.

Initialize shap kernelexplainer object.

explain_instance(*argv, **kwargs)

Explain one or more input instances.

set_params(*argv, **kwargs)

Optionally, set parameters for the explainer.

class aix360.algorithms.shap.shap_wrapper.TreeExplainer(*argv, **kwargs)

This class wraps the source class TreeExplainer available in the SHAP library. Additional variables or functions from the source class can also be accessed via the ‘explainer’ object variable that is initialized in ‘__init__’ function of this class.

Initialize shap kernelexplainer object.

explain_instance(*argv, **kwargs)

Explain one or more input instances.

set_params(*argv, **kwargs)

Optionally, set parameters for the explainer.

class aix360.algorithms.shap.shap_wrapper.LinearExplainer(*argv, **kwargs)

This class wraps the source class Linearexplainer available in the SHAP library. Additional variables or functions from the source class can also be accessed via the ‘explainer’ object variable that is initialized in ‘__init__’ function of this class.

Initialize shap kernelexplainer object.

explain_instance(*argv, **kwargs)

Explain one or more input instances.

set_params(*argv, **kwargs)

Optionally, set parameters for the explainer.

Matching Explainers

class aix360.algorithms.matching.order_constraints.OTMatchingExplainer(deactivate_bounds: bool = False, error_limit: float = 0.001)

OTMatchingExplainer provides explainations for a matching that satisfies the transport polytope constraints. Given a matching, it produces a set of alternative matchings, where each alternate contrasts with the provided instance by a sparse set of salient matchings. [1].

This is akin to a search engine providing alternative suggestions relevant to a search string. OTMatchingExplainer aims to provide the same for matchings.

References

[1]Fabian Lim, Laura Wynter, Shiau Hong Lim, “Order Constraints in Optimal Transport”, 2022

Initialize the OTMatchingExplainer

explain_instance(matching: numpy.ndarray, costs: numpy.ndarray, constraints: Tuple[numpy.ndarray, numpy.ndarray], num_alternate_matchings: int = 1, search_thresholds: Tuple[float, float] = (0.5, 0.5), search_node_limit: int = 20, search_depth_limit: int = 1, search_match_pos_filter: Optional[List[Tuple[int, int]]] = None)

Explain the matching

Parameters:
  • matching (numpy 2d array) – the matching to be explained.
  • costs – (numpy 2d array): the (non-negative) matching costs used to obtain above matching.
  • constraints (numpy array, numpy array) – the transport polytope row/column constraints.
  • num_alternate_matchings (int) – the number of alternate matchings to return back.
  • search_node_limit (int) – stop the search when this many nodes have been encountered.
  • search_depth_limit (int) – do not progress beyond this tree level in the search
  • search_match_pos_filter ((int,int) array or None) – if specified, this is a whitelist of positions (i,j) of candidate match positions
  • search_thresholds (float, float) – thresholds used to pick the candidate match positions to search over.
Returns:

list of AlternateMatching explanations.

set_params(*args, **kwargs)

Set parameters for the explainer.