Explaining Reinforcement Learning with Shapley Values

Daniel Beechey, Thomas M. S. Smith, Özgür Şimşek

TL;DR

SVERL-P is a new framework that uses game-theoretic Shapley values to explain reinforcement learning (RL) agents by quantifying how much specific state features contribute to an agent's performance (expected return). Unlike previous methods that explain internal model predictions or isolated decisions, SVERL-P accounts for how feature observations change an agent's behavior, leading to explanations that are more theoretically sound and better aligned with human intuition.

What Problem Does This Paper Address?

Reinforcement learning agents are often "black boxes," making them difficult to trust in high-stakes applications like autonomous driving or healthcare. While post-hoc explanation methods like Shapley values (popularized by the SHAP package) have been successful in supervised learning, simply porting them to RL is problematic.

Earlier attempts focused on explaining the value function (what the agent thinks will happen) or the policy (what the agent decides to do). However, these don't necessarily explain performance. For example, a road sign might strongly influence an agent's decision to turn left, but if turning right was equally optimal, that sign didn't actually contribute to the agent's success. This paper addresses the gap between explaining an agent's internal state and explaining what actually makes it successful.

Methods

The authors introduce SVERL (Shapley Values for Explaining Reinforcement Learning), specifically focusing on a variant called SVERL-P (Performance).

The core innovation is the definition of the "characteristic value function" used in the Shapley calculation. Instead of using a model's output (like a class probability), SVERL-P uses the expected return of the agent.

  • Local SVERL-P: Measures the contribution of features to performance starting from a specific state $s$. It evaluates what happens to the expected return if the agent's observation of that state is restricted to a subset of features.
  • Global SVERL-P: Aggregates these contributions across the entire environment, weighted by how often the agent visits each state (the limiting state occupancy distribution).
  • On-Manifold Sampling: To handle correlated features, the authors use the agent's own state distribution to "fill in" missing features, ensuring the explanations stay grounded in realistic scenarios the agent actually encounters.

Datasets

The authors evaluated SVERL-P across several classic and custom RL benchmarks:

  • Gridworlds (A, B, C, D): Simple deterministic environments designed to test specific intuitive scenarios, such as states where multiple actions are optimal.
  • Tic-Tac-Toe: Used to show how SVERL-P behaves when an optimal agent always achieves the same outcome (a draw).
  • Taxi: A hierarchical task where an agent must pick up and drop off passengers, involving features like taxi coordinates, passenger location, and destination.
  • Minesweeper: A large-scale domain (~175,000 states) where identifying the contribution of specific grid squares to winning is non-trivial.

Key Insights and Ideas

  • Value Functions are Static Predictors: Explaining a value function $V(s)$ only tells you how features affect a prediction under the assumption that behavior remains constant. It fails to capture how removing a feature might cause the agent to take a disastrously different action.
  • The "Road Sign" Paradox: A feature can be highly "important" to a policy (it dictates the choice) but have zero importance for performance (if other choices are just as good). SVERL-P correctly identifies this distinction.
  • Dangerous Knowledge: In some cases, having partial information can be worse than having none. SVERL-P can produce negative Shapley values, indicating that observing a specific feature in isolation might lead the agent to a suboptimal decision that hurts its overall return.
Figure 1. Deterministic gridworlds, with actions North, South, East, and West. The numbers in each grid square show the state identifier. The initial state is either state 1 or state 2, with equal probability. The reward is −1 for each action and an additional +10 for transitions into a terminal state (G). The discount factor γ is 1. State features are the x and y coordinates. The red arrows show the optimal action in each state.

Key Results

The paper demonstrates that SVERL-P succeeds where standard Shapley applications fail:

  • Gridworld-A: In an environment where the optimal action is always "North," human intuition says no single feature should be "important" for performance. SVERL-P correctly yields zero for all features, whereas value-function-based Shapley values produce misleading non-zero results.
Figure 2. Top panel: Shapley values applied to a state-action value function in Gridworld-A (Figure 1a). Bottom panel: SVERL-P, presented in Section 4, for the same domain. The optimal action is always North so we intuitively expect contributions to performance to be zero for all state features in all states. This is accurately captured by SVERL-P but not by Shapley values applied to the value function.
  • Tic-Tac-Toe: For an optimal agent that always draws, the value function is a flat zero. Standard methods find no important features. SVERL-P, however, correctly identifies the critical board positions (like blocking an opponent's win) as the most important features for maintaining that draw.
  • Minesweeper: SVERL-P pinpointed the specific "unopened" squares that were mathematically necessary to locate hidden mines, providing a clear explanation of the agent's success in a complex state space.

Limitations and Future Work

  • Computational Complexity: Calculating exact Shapley values is exponentially expensive relative to the number of features. While the authors provide an approximation algorithm, scaling SVERL-P to high-dimensional inputs like raw pixels (e.g., Atari games) remains a significant challenge.
  • Human Interpretation: The authors note that humans tend to "over-interpret" these values, creating subjective narratives. Future work is needed to study how these explanations actually impact human trust and decision-making in real-world settings.
  • Feature Grouping: To handle large feature sets, the authors suggest integrating methods like groupShapley to explain clusters of features rather than individual ones.

Summary updated

BibTeX
@inproceedings{beechey2023explaining,
  author = {Daniel Beechey and Thomas M. S. Smith and Özgür Şimşek},
  title = {{Explaining Reinforcement Learning with Shapley Values}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=R1blujRwj1},
}
Figure