docs/source/modules/explain.rst
.. currentmodule:: torch_geometric.explain
.. warning::
This module is in active development and may not be stable.
Access requires installing :pyg:`PyG` from master.
.. contents:: Contents :local:
This module provides a set of tools to explain the predictions of a PyG model or to explain the underlying phenomenon of a dataset (see the "GraphFramEx: Towards Systematic Evaluation of Explainability Methods for Graph Neural Networks" <https://arxiv.org/abs/2206.09677>_ paper for more details).
We represent explanations using the :class:torch_geometric.explain.Explanation class, which is a :class:~torch_geometric.data.Data object containing masks for the nodes, edges, features and any attributes of the data.
The :class:torch_geometric.explain.Explainer class is designed to handle all explainability parameters (see the :class:torch_geometric.explain.config.ExplainerConfig class for more details):
torch_geometric.explain.algorithm module to use (e.g., :class:~torch_geometric.explain.algorithm.GNNExplainer)explanation_type="phenomenon" or :obj:explanation_type="model")mask="object" or :obj:mask="attributes")threshold_type="topk" or :obj:threshold_type="hard")This class allows the user to easily compare different explainability methods and to easily switch between different types of masks, while making sure the high-level framework stays the same.
.. autoclass:: torch_geometric.explain.Explainer :show-inheritance: :members: :special-members: call
.. autoclass:: torch_geometric.explain.config.ExplainerConfig :members:
.. autoclass:: torch_geometric.explain.config.ModelConfig :members:
.. autoclass:: torch_geometric.explain.config.ThresholdConfig :members:
.. autoclass:: torch_geometric.explain.Explanation :show-inheritance: :members:
.. autoclass:: torch_geometric.explain.HeteroExplanation :show-inheritance: :members:
.. currentmodule:: torch_geometric.explain.algorithm
.. autosummary:: :nosignatures: :toctree: ../generated
{% for name in torch_geometric.explain.algorithm.classes %} {{ name }} {% endfor %}
The quality of an explanation can be judged by a variety of different methods. PyG supports the following metrics out-of-the-box:
.. currentmodule:: torch_geometric.explain.metric
.. autosummary:: :nosignatures: :toctree: ../generated
{% for name in torch_geometric.explain.metric.classes %} {{ name }} {% endfor %}