torch_geometric.explain
Warning
This module is in active development and may not be stable. Access requires installing PyG
from master.
Contents
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" paper for more details).
We represent explanations using the torch_geometric.explain.Explanation
class, which is a ~torch_geometric.data.Data
object containing masks for the nodes, edges, features and any attributes of the data.
The torch_geometric.explain.Explainer
class is designed to handle all explainability parameters (see the torch_geometric.explain.config.ExplainerConfig
class for more details):
- which algorithm from the
torch_geometric.explain.algorithm
module to use (e.g.,~torch_geometric.explain.algorithm.GNNExplainer
) - the type of explanation to compute (e.g.,
explanation_type="phenomenon"
orexplanation_type="model"
) - the different type of masks for node and edges (e.g.,
mask="object"
ormask="attributes"
) - any postprocessing of the masks (e.g.,
threshold_type="topk"
orthreshold_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.
torch_geometric.explain.Explainer
torch_geometric.explain.config.ExplainerConfig
torch_geometric.explain.config.ModelConfig
torch_geometric.explain.config.ThresholdConfig
torch_geometric.explain.Explanation
torch_geometric.explain.HeteroExplanation
torch_geometric.explain.algorithm
- {% 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:
torch_geometric.explain.metric
- {% for name in torch_geometric.explain.metric.classes %}
{{ name }}
{% endfor %}