alibi.explainers.anchor_explanation module

class alibi.explainers.anchor_explanation.AnchorExplanation(exp_type, exp_map)[source]

Bases: object

__init__(exp_type, exp_map)[source]

Class used to unpack the anchors and metadata from the explainer dictionary.

Parameters
  • exp_type (str) – Type of explainer: tabular, text or image

  • exp_map (dict) – Dictionary with the anchors and explainer metadata for an observation

Return type

None

coverage(partial_index=None)[source]
Parameters

partial_index (Optional[int]) – Get the result coverage until a certain index. For example, if the result has precisions [0.1, 0.5, 0.95] and partial_index=1, this will return 0.5.

Return type

float

Returns

coverage – Anchor coverage

examples(only_different_prediction=False, only_same_prediction=False, partial_index=None)[source]
Parameters
  • only_different_prediction (bool) – If True, will only return examples where the result makes a different prediction than the original model

  • only_same_prediction (bool) – If True, will only return examples where the result makes the same prediction than the original model

  • partial_index (Optional[int]) – Get the examples from the partial result until a certain index

Return type

ndarray

Returns

Examples covered by result

features(partial_index=None)[source]
Parameters

partial_index (Optional[int]) – Get the result until a certain index. For example, if the result uses segment_labels (1, 2, 3) and partial_index=1, this will return [1, 2].

Return type

list

Returns

segment_labels – Features used in the result conditions.

names(partial_index=None)[source]
Parameters

partial_index (Optional[int]) – Get the result until a certain index. For example, if the result is (A=1,B=2,C=2) and partial_index=1, this will return [“A=1”, “B=2”].

Return type

list

Returns

names – Names with the result conditions

precision(partial_index=None)[source]
Parameters

partial_index (Optional[int]) – Get the result precision until a certain index. For example, if the result has precisions [0.1, 0.5, 0.95] and partial_index=1, this will return 0.5.

Return type

float

Returns

precision – Anchor precision