TL;DR
RACCER is the first reinforcement learning-specific framework for generating counterfactual explanations that account for the sequential and stochastic nature of environments. By using a heuristic tree search to optimize for reachability and certainty, it provides users with actionable advice that is both easier to achieve and more likely to result in the desired outcome than existing feature-based methods.
What Problem Does This Paper Address?
Reinforcement Learning (RL) agents are often "black boxes" driven by complex neural networks, making their decisions hard to trust in high-stakes areas like healthcare or autonomous driving. Counterfactual explanations aim to solve this by answering: "How would the input need to change to get a different result?"
However, most existing methods were designed for supervised learning. They focus on "proximity"—making the smallest possible change to features. In RL, this is problematic for two reasons:
- Sequentiality: Two states might look identical in terms of features but be many actions apart in time. A "small" feature change suggested by a standard algorithm might be physically impossible for an agent to reach.
- Stochasticity: RL environments are often random. A suggested change might only lead to the desired outcome 10% of the time, which is useless for a human user seeking reliable advice.
Methods
The authors introduce RACCER (Reachable And Certain Counterfactual Explanations for RL). Instead of searching for a state in a dataset, RACCER searches for an optimal sequence of actions that transforms the current state into a desired counterfactual state.
The Three Pillars of RACCER
RACCER optimizes a loss function based on three novel RL-specific properties:
- Reachability: Minimizes the number of actions required to reach the counterfactual state.
- Fidelity: Ensures the suggested path is something the agent would actually do (based on its current policy), making the explanation a true reflection of the agent's behavior.
- Stochastic Certainty: Measures the probability that the desired outcome will actually occur once the counterfactual state is reached, accounting for environmental randomness.
Heuristic Tree Search
To find these paths, RACCER employs a heuristic tree search (similar to Monte Carlo Tree Search). It uses the Upper Confidence Bound applied for Trees (UCT) formula to balance exploring new action sequences and exploiting known good paths.
Datasets
The authors evaluated RACCER in two discrete, stochastic environments:
- Stochastic GridWorld: A 5x5 grid where an agent must shoot a dragon. Obstacles like trees and walls can stochastically regrow or be rebuilt, blocking paths.
- Frozen Lake: A classic environment where the agent navigates a slippery grid. Actions are uncertain; a command to move "right" might result in staying put or moving elsewhere due to the ice.
Key Insights and Ideas
- Feature Similarity $\neq$ Reachability: This is the paper's core "aha" moment. In RL, "close" in feature space does not mean "close" in execution space. RACCER prioritizes the latter, ensuring advice is actually actionable.
- Robustness to Suboptimal Agents: Unlike generative methods (like GANterfactual-RL) that require well-defined domains to train, RACCER’s search-based approach works even for agents that are only partially trained. This makes it a powerful tool for debugging agents during the development phase.
- Prefactual vs. Counterfactual: The paper highlights that in RL, users often need "prefactuals"—advice on what to do in the future to change an outcome—rather than just reflections on what could have happened in the past.
Key Results
RACCER was compared against GANterfactual-RL, the previous state-of-the-art model-agnostic approach.
- Performance: RACCER significantly outperformed the baseline on all RL-specific metrics. In Frozen Lake, RACCER achieved a Validity of 1.0 (meaning it always found a state that produced the target action), while the baseline struggled at 0.46.
- User Study: In a study with 153 participants, those provided with RACCER explanations were significantly better at predicting the agent's future actions (76.19% accuracy vs 70.94% for the baseline).
- User Satisfaction: Users rated RACCER explanations as significantly more useful, detailed, and complete.
Limitations and Future Work
- Search Constraints: RACCER searches the space of the agent's possible interactions. If a target action is something the agent would never do (e.g., a well-trained agent moving away from a goal), RACCER may fail to find a counterfactual.
- Single Explanation: Currently, the algorithm only returns the single "best" counterfactual. The authors suggest that future versions should provide a diverse set of options to give users more choice.
- Past vs. Future: While this work focuses on future-oriented "prefactuals," the authors plan to investigate how to apply these RL-specific properties to explanations that explore past decisions.
Summary updated