Temporal Graph Neural Networks (TGNNs) are widely used to model dynamic systems where relationships and features evolve over time—such as social networks, financial transactions, or e-commerce platforms. While TGNNs demonstrate strong predictive capabilities, their complex architectures act as "black boxes," making it difficult to understand why a specific prediction was made.
To address this, researchers have introduced CoDy (Counterfactual Explainer for Dynamic Graphs), the first model-agnostic, instance-level counterfactual explainer designed specifically for Continuous-Time Dynamic Graphs (CTDGs).
The Challenge: Factual vs. Counterfactual Explanations
Existing explainability methods for graphs mostly focus on factual explanations. These methods try to identify a subset of existing edges that contributed to a model's prediction. In dynamic graphs, however, factual explanations can become cluttered and cognitively demanding to interpret, often tracing complex paths of indirect connections.
CoDy tackles the challenge of counterfactual explanations, which ask: "What is the smallest change I could make to the past that would alter this future prediction?" This approach is often more intuitive for humans because it directly highlights causal dependencies and necessary events.
For example, in a student forum network, a factual explanation for a predicted link might highlight multiple past interactions. A counterfactual explanation simplifies this to a single necessary action: "If Student B hadn't posted on Math 1, the prediction for Math 2 wouldn't have occurred."
How CoDy Works
Because the search space of all possible past event combinations in a dynamic graph is exponentially large, CoDy employs a search algorithm based on Monte Carlo Tree Search (MCTS). It treats the underlying TGNN as a black box, making it compatible with various architectures like TGN or TGAT.
Key components of the CoDy framework include:
- Search Tree Structure: Each node in the MCTS tree represents a specific perturbation (the removal of specific events) from the input graph.
- Heuristic Selection Policies: To navigate the massive search tree efficiently, CoDy uses specialized policies to prioritize which events to remove first:
- Spatio-Temporal: Prioritizes events that are physically close in the graph and chronologically recent relative to the target prediction.
- Event-Impact: Measures the direct change in the model's prediction logits when an event is removed.
Key Insights and Results
The researchers evaluated CoDy on three diverse datasets (Wikipedia, UCI-Messages, and UCI-Forums) and compared it against state-of-the-art baselines like PGExplainer and T-GNNExplainer.
- Superior Performance: CoDy significantly outperformed baselines, showing a 16% improvement in AUFSC+ (Area Under the Fidelity-Sparsity Curve) over the strongest competitor. This indicates that CoDy finds higher-quality explanations using fewer events.
- Spatio-Temporal Context is King: The most effective explanations are almost always found among events that are spatially near and temporally recent to the target. Incorporating these as search heuristics significantly improved the explainer's efficiency.
- Explaining Errors is Easier: Interestingly, the authors found that explainers identify necessary events for incorrect predictions more than twice as often as for correct ones. When models fail, they often rely on a few specific, misinterpreted past events. This makes counterfactuals a highly powerful tool for model debugging.
- Conciseness vs. Sufficiency: Counterfactual methods excel at finding the minimal necessary information (sparsity), whereas factual methods often focus on finding enough information to recreate a prediction, leading to larger, more complex subgraphs.
Future Directions
Currently, CoDy explores counterfactuals by removing graph components. Future iterations could expand this scope to include adding nodes or edges, modifying features, or shifting timestamps to provide even richer "what-if" scenarios. Additionally, while MCTS is efficient, scaling these methods for massive, real-time dynamic graphs remains an ongoing challenge.
Summary updated