A Theoretical Framework for Explaining Reinforcement Learning with Shapley Values

Daniel Beechey, Thomas M. S. Smith, Özgür SimsekarXiv 2025 · DOI

Abstract

Reinforcement Learning (RL) agents often operate as "black boxes," making sequential decisions that are difficult for humans to interpret. While Shapley values from cooperative game theory offer a principled way to attribute importance to input features, their application to RL has historically lacked theoretical rigor. This paper introduces SVERL (Shapley Values for Explaining Reinforcement Learning), a unified axiomatic framework that decomposes an agent's behavior, outcomes, and internal predictions into contributions from individual features. By distinguishing between different explanatory targets, SVERL provides a mathematically consistent foundation for understanding why RL agents act the way they do.

Introduction

As reinforcement learning agents are increasingly deployed in critical domains like autonomous driving and financial trading, the need for interpretability becomes paramount. Standard "Explainable AI" (XAI) techniques, often designed for static image classification, frequently fail in RL contexts because they ignore the sequential nature of the task and the distinction between an agent's immediate policy and its long-term goals.

Existing attempts to apply Shapley values—a method for fairly distributing a "payout" among players in a coalition—to RL have often conflated different concepts. For instance, a feature might be critical for an agent to choose a specific action (Behavior) without actually impacting the final reward (Outcome). This paper addresses these ambiguities by providing a rigorous mathematical framework to separate and define these explanatory targets.

The SVERL Framework

The core of the SVERL framework is the definition of specific "coalitional games" where the "players" are the features observed by the agent (e.g., position, velocity, or distance to a goal). The "payout" being distributed is one of three distinct targets:

  1. Behaviour: Explains the probability of the agent selecting a specific action.
  2. Outcomes: Explains the expected return (total discounted reward) the agent receives.
  3. Predictions: Explains the agent’s internal estimate of future rewards (the value function).

Axiomatic Foundation

SVERL derives its explanations from four fundamental axioms of cooperative game theory, ensuring the credit assignment is unique and mathematically consistent:

  • Efficiency: The sum of all feature contributions must equal the total payout.
  • Linearity: The explanation of a sum of games is the sum of the individual explanations.
  • Symmetry: If two features contribute identically to all possible coalitions, they receive equal credit.
  • Nullity: A feature that never changes the payout receives zero credit.

To handle "missing" features during the calculation of these values, the authors utilize a conditional approach based on the agent's steady-state distribution. This involves asking what the expected value of a feature would be based on the agent's typical experience within the environment.

Key Theoretical Insights

The "Equal Path" Paradox

A significant contribution of this work is the formal distinction between behavior and outcomes. Consider an agent with two paths of equal length to a goal. A signpost might influence the agent to turn left (affecting Behavior), but because both paths result in the same reward, the signpost has no impact on the final Outcome. SVERL is the first framework to formally separate these influences, preventing misleading attributions.

Predictions vs. Outcomes

In competitive environments, an agent's internal predictions may differ significantly from actual outcomes. In a game like Tic-Tac-Toe against a perfect opponent, every state leads to a draw (Return = 0). A "Prediction" explanation might suggest no feature matters because the result is always zero. However, an "Outcome" explanation correctly identifies the opponent's moves as critical features that the agent must react to in order to maintain that draw.

Steady-State Deviations

The authors prove that the expected contribution of any feature, when averaged over the agent's entire experience (the steady-state), is zero. This implies that SVERL specifically explains how a feature causes the agent to deviate from its average behavior or expected rewards in a specific state.

Experimental Evaluation

The framework was validated across several benchmarks, including Mastermind, Minesweeper, and the Taxi domain. In the Taxi environment, SVERL demonstrated qualitative clarity: it showed that the "passenger location" feature dominates the agent's behavior when the taxi is empty, whereas the "destination" feature becomes the primary driver of behavior once the passenger has been picked up.

Limitations and Future Directions

While SVERL provides a robust theoretical foundation, practical challenges remain. Calculating exact Shapley values is computationally expensive (NP-hard), as it requires evaluating an exponential number of feature subsets. While Monte Carlo sampling offers a viable approximation, scaling to high-dimensional inputs like raw pixels remains difficult. Furthermore, the reliance on a steady-state distribution may be problematic in non-stationary environments or during early stages of training. Future work will focus on extending these principles to continuous action spaces and complex robotics tasks.

Conclusion

SVERL moves beyond heuristic saliency maps by providing an axiomatic, principled approach to RL interpretability. By distinguishing between what an agent does and what actually matters for its success, this framework offers a clearer lens through which we can audit and understand complex autonomous systems.

Summary updated

BibTeX
@misc{beechey2025theoretical,
  author = {Daniel Beechey and Thomas M. S. Smith and Özgür Simsek},
  title = {{A Theoretical Framework for Explaining Reinforcement Learning with Shapley Values}},
  year = {2025},
  eprint = {2505.07797},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.07797},
}
Figure