NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Rethinking Out-of-Distribution Detection for Reinforcement Learning: Advancing Methods for Evaluation and Detection

Linas Nasvytis, Kai Sandbrink, Jakob N. Foerster, Tim Franzmeyer, Christian Schröder de Witt · DOI

TL;DR

Reinforcement learning (RL) agents struggle in unseen environments. This paper introduces new, temporally correlated anomaly benchmarks for out-of-distribution (OOD) detection in RL and proposes DEXTER, a novel method that extracts time-series features to detect these anomalies, significantly outperforming existing methods.

What Problem Does This Paper Address?

Reinforcement learning (RL) has shown remarkable success in various sequential decision-making tasks. However, a critical challenge remains: ensuring the safety and reliability of RL agents when deployed in environments that differ from their training conditions. These "out-of-distribution" (OOD) scenarios pose a significant risk, as agents may behave unpredictably or even dangerously. Existing OOD detection methods in RL often rely on injecting simple, independent and identically distributed (i.i.d.) noise, which doesn't accurately reflect many real-world anomalies. For instance, a robot's camera lens getting smudged would introduce a series of correlated errors, not random ones. This paper argues that current benchmarks and detection methods are insufficient for these more realistic, temporally correlated anomalies.

Methods

The paper introduces a novel OOD detection framework called DEXTER (Detection via Extraction of Time Series Representations). DEXTER operates in two main stages:

  1. Feature Extraction: It treats environment observations as time series data and uses the tsfresh library to extract a diverse set of features. This includes descriptive statistics, autocorrelation statistics, and advanced spectral features, aiming to be anomaly-agnostic.
  2. Anomaly Detection: An ensemble of Isolation Forest models is trained on these extracted features. Each Isolation Forest is trained on data from a specific state dimension, learning the "normal" patterns within that dimension. The anomaly score for a given time step is the average score across all dimensions.

To improve decision-making, the authors also propose DEXTER+C, which combines DEXTER's anomaly scores with a Cumulative Sum (CUSUM) detector. This statistical method leverages information-theoretically grounded sequential hypothesis testing to accumulate anomaly scores over time, providing a more robust decision rule for identifying OOD scenarios.

Datasets

The paper introduces three new benchmark environments:

  • ARTS (Autoregressive Time Series): A baseline environment where noise is generated using an Autoregressive (AR) process, but the environment state remains constant.
  • ARNO (Autoregressive Noised Observation): Introduces sensory anomalies by adding temporally correlated noise to the agent's observations.
  • ARNS (Autoregressive Noised State): Introduces semantic anomalies by applying temporally correlated noise to the environment's state transitions, effectively changing the underlying dynamics.

These new environments are designed to simulate temporally correlated anomalies, which are argued to be more representative of real-world issues than the i.i.d. noise used in prior work. The authors also evaluate their method on existing benchmark scenarios from prior research.

Key Insights and Ideas

  • Real-world anomalies are often temporally correlated: The paper strongly advocates that current OOD detection benchmarks, which primarily use i.i.d. noise, are insufficient. Real-world issues like sensor degradation or physical disturbances often introduce patterns of errors over time.
  • Time-series features are crucial for detecting correlated anomalies: By treating observations as time series and extracting features, DEXTER can capture the temporal dependencies that simpler methods miss.
  • Sequential hypothesis testing (CUSUM) enhances detection: Simply looking at per-step anomaly scores is less effective than accumulating evidence over time. DEXTER+C leverages CUSUM to make more informed decisions, reducing detection time.
  • A unified terminology is needed: The paper clarifies the often-confused terminology around OOD detection in RL, aligning it with broader machine learning definitions (sensory vs. semantic anomalies).

Key Results

  • DEXTER significantly outperforms state-of-the-art: Across the newly introduced ARNO and ARNS scenarios, DEXTER consistently achieves higher AUROC scores than existing methods like PEDM and changepoint detectors (OCD, Chan).
  • DEXTER+C dramatically reduces detection time: While DEXTER provides anomaly scores, DEXTER+C uses these scores with a CUSUM detector to identify OOD episodes much faster than other methods, often in a fraction of the episode length.
  • PEDM struggles with correlated noise: As hypothesized, the Probabilistic Ensemble Dynamics Model (PEDM), which relies on predicting future states, performs poorly on temporally correlated anomalies, often performing close to random guessing.
  • Hybrid approaches may be optimal: In some existing benchmark scenarios, a combination of DEXTER and PEDM (or their CUSUM variants) showed the best results, suggesting that different anomaly types might benefit from different detection strategies.

Limitations and Future Work

  • Simulated environments: The current evaluation is limited to simulated environments. Future work should explore sim-to-real transfer.
  • Cross-dimensional correlations: The current DEXTER implementation focuses on features within individual dimensions. Future work should address anomalies that involve correlations across different dimensions.
  • Fixed window length: DEXTER uses a fixed window size for feature extraction. Investigating adaptive or sliding window approaches could improve performance.
  • Feature selection: Exploring methods for selecting the most relevant features at test time could further enhance DEXTER's efficiency, especially in high-dimensional environments.
  • Combining detectors: The authors suggest that combining DEXTER (for correlated anomalies) with methods like PEDM (for i.i.d. or single-step anomalies) could lead to more robust overall OOD detection systems.

Summary updated

BibTeX
@inproceedings{nasvytis2024rethinking,
  author = {Linas Nasvytis and Kai Sandbrink and Jakob N. Foerster and Tim Franzmeyer and Christian Schröder de Witt},
  title = {{Rethinking Out-of-Distribution Detection for Reinforcement Learning: Advancing Methods for Evaluation and Detection}},
  booktitle = {AAMAS},
  year = {2024},
  doi = {10.48550/arxiv.2404.07099},
}
Figure