dig.xgraph.evaluation¶
Evaluation interfaces under dig.xgraph.evaluation
.
Explanation Processor is edge mask explanation processor which can handle sparsity control and use data collector automatically. |
|
XCollector is a data collector which takes processed related prediction probabilities to calculate Fidelity+ and Fidelity-. |
-
class
ExplanationProcessor
(model: torch.nn.modules.module.Module, device: torch.device)[source]¶ Explanation Processor is edge mask explanation processor which can handle sparsity control and use data collector automatically.
- Parameters
model (torch.nn.Module) – The target model prepared to explain.
device (torch.device) – Specify running device: CPU or CUDA.
-
forward
(data: torch_geometric.data.data.Data, masks: List[torch.Tensor], x_collector: dig.xgraph.evaluation.metrics.XCollector, **kwargs)[source]¶ Please refer to the main function in metric.py.
-
class
XCollector
(sparsity=None)[source]¶ XCollector is a data collector which takes processed related prediction probabilities to calculate Fidelity+ and Fidelity-.
- Parameters
sparsity (float) – The Sparsity is use to transform the soft mask to a hard one.
Note
For more examples, see benchmarks/xgraph.
-
collect_data
(masks: List[torch.Tensor], related_preds: dir, label: int = 0) → None[source]¶ The function is used to collect related data. After collection, we can call fidelity, fidelity_inv, sparsity to calculate their values.
-
property
fidelity
¶ Return the Fidelity+ value according to collected data.
Note
Please refer to Explainability in Graph Neural Networks: A Taxonomic Survey for details.
-
property
fidelity_inv
¶ Return the Fidelity- value according to collected data.
Note
Please refer to Explainability in Graph Neural Networks: A Taxonomic Survey for details.
-
property
sparsity
¶ Return the Sparsity value.