Counterfactual Explanations for Continuous Action Reinforcement Learning

Shuyang Dong, Shangtong Zhang, Lu Feng

Introduction

Reinforcement Learning (RL) has demonstrated significant potential in high-stakes domains such as healthcare and robotics. However, the "black box" nature of these agents often hinders human trust and adoption. Counterfactual explanations—answering "what if" questions—offer a promising path toward interpretability. This paper introduces a novel framework for generating such explanations specifically for RL agents operating in continuous action spaces, a complex area previously underserved by counterfactual research.

The Challenge of Continuous Counterfactuals

Most existing counterfactual research focuses on supervised learning or discrete RL. Real-world applications, however, often involve continuous actions (e.g., precise insulin dosages or engine thrust levels) and temporal dependencies where a single change impacts the entire future trajectory. The goal is to find "minimal-change" alternative paths that lead to improved outcomes while remaining close to the observed behavior.

Methodology: Optimizing for Minimal Change

The authors frame the search for a counterfactual as an optimization problem: identifying a new action sequence that maximizes cumulative reward while minimizing the distance from the original actions.

Key technical components include:

  • Normalized Distance Metric: A metric designed for continuous action sequences to ensure numerical stability across different scales.
  • TD3 Extension: The framework adapts the Twin Delayed Deep Deterministic Policy Gradient (TD3) algorithm. Instead of a standard policy, the agent learns a "counterfactual policy" trained on a hybrid reward: the environment's original reward minus a penalty for deviating from the observed trajectory.
  • Sparse Reward Shaping: To maintain sequence integrity, the distance penalty is applied as a sparse reward only at the conclusion of an episode.
  • Augmented MDP for Constraints: To handle "hard constraints"—such as safety protocols in medical settings—the authors introduce an Augmented MDP that ensures counterfactuals adhere to critical safety boundaries.
Counterfactual trajectories in the diabetes control environment, showing alternative insulin doses and resulting glucose levels.

Experimental Evaluation

The approach was evaluated in two simulated environments:

  1. Diabetes Control: Utilizing the FDA-approved UVA/PADOVA simulator to model glucose-insulin dynamics in Type 1 Diabetes.
  2. Lunar Lander (Continuous): A physics-based robotics context from OpenAI Gym.

Testing spanned both "Single-Environment" and "Multi-Environment" (diverse populations or physical conditions) settings to assess generalization capabilities.

Results: The Power of Multi-Environment Training

The researchers evaluated performance using two primary metrics: $\rho_+$ (the frequency of finding an improved path) and $\rho_{adv}$ (the degree of improvement over a baseline).

  • Effectiveness: In the Diabetes domain, the method (P1) found improved trajectories in 53% of cases. In the Lunar Lander environment, this success rate exceeded 80%.
  • The Multi-Env Boost: A significant finding was that training on a diverse set of environments (Multi-Env) drastically improved explanation quality. In Lunar Lander, the advantage metric ($\rho_{adv}$) rose from 0.38 in single-environment training to 0.94 in multi-environment training, suggesting the model learns a robust understanding of trajectory improvement across varying conditions.
Performance metrics in the multi-environment Lunar Lander setting, demonstrating the learning progress and effectiveness of the counterfactual policy.

Conclusion and Future Work

This framework provides a scalable method for generating interpretable, continuous-action counterfactuals. While the current approach requires environment interaction (simulated "roll-outs"), it marks a significant step toward transparent RL. Future work will focus on human-in-the-loop studies to determine if these "minimal distance" paths effectively aid human decision-making and on incorporating more nuanced "actionability" constraints.

Summary updated

BibTeX
@inproceedings{dong2025counterfactual,
  author = {Shuyang Dong and Shangtong Zhang and Lu Feng},
  title = {{Counterfactual Explanations for Continuous Action Reinforcement Learning}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.24963/ijcai.2025/561},
}
Figure