fidelity(explainer: Explainer, explanation: Explanation) Tuple[float, float][source]

Evaluates the fidelity of an Explainer given an Explanation, as described in the “GraphFramEx: Towards Systematic Evaluation of Explainability Methods for Graph Neural Networks” paper.

Fidelity evaluates the contribution of the produced explanatory subgraph to the initial prediction, either by giving only the subgraph to the model (fidelity-) or by removing it from the entire graph (fidelity+). The fidelity scores capture how good an explainable model reproduces the natural phenomenon or the GNN model logic.

For phenomenon explanations, the fidelity scores are given by:

\[ \begin{align}\begin{aligned}\textrm{fid}_{+} &= \frac{1}{N} \sum_{i = 1}^N \| \mathbb{1}(\hat{y}_i = y_i) - \mathbb{1}( \hat{y}_i^{G_{C \setminus S}} = y_i) \|\\\textrm{fid}_{-} &= \frac{1}{N} \sum_{i = 1}^N \| \mathbb{1}(\hat{y}_i = y_i) - \mathbb{1}( \hat{y}_i^{G_S} = y_i) \|\end{aligned}\end{align} \]

For model explanations, the fidelity scores are given by:

\[ \begin{align}\begin{aligned}\textrm{fid}_{+} &= 1 - \frac{1}{N} \sum_{i = 1}^N \mathbb{1}( \hat{y}_i^{G_{C \setminus S}} = \hat{y}_i)\\\textrm{fid}_{-} &= 1 - \frac{1}{N} \sum_{i = 1}^N \mathbb{1}( \hat{y}_i^{G_S} = \hat{y}_i)\end{aligned}\end{align} \]
  • explainer (Explainer) – The explainer to evaluate.

  • explanation (Explanation) – The explanation to evaluate.