Diversify: A General Framework for Time Series Out-of-Distribution Detection and Generalization

Wang Lu, Jindong Wang, Xinwei Sun, Yiqiang Chen, Xiangyang Ji, Qiang Yang, Xing Xie

TL;DR

This paper introduces DIVERSIFY, a novel framework for time series analysis that tackles the challenge of Out-of-Distribution (OOD) detection and generalization. DIVERSIFY learns robust representations by identifying and leveraging "latent subdomains" within time series data, even when domain labels are unknown, outperforming existing methods.

What Problem Does This Paper Address?

Time series data is notoriously difficult to work with in machine learning because its statistical properties often change over time – a phenomenon known as non-stationarity. This makes it hard for models to generalize to new, unseen data (generalization) or to distinguish between normal and anomalous data (OOD detection). Existing methods often rely on knowing domain labels or assume static distributions, which doesn't hold true for dynamic time series. This paper addresses the critical need for methods that can handle these temporal shifts and unknown domain structures in time series for both detection and generalization tasks.

Methods

DIVERSIFY is an iterative framework designed to learn generalized representations from time series data. Its core idea is to identify "latent subdomains" within the data without explicit domain labels. This is achieved through an adversarial game:

  1. Latent Distribution Characterization: DIVERSIFY first aims to maximize the divergence between these latent subdomains, effectively finding the "worst-case" distribution scenario. This helps preserve the diverse information within the data.
  2. Domain-Invariant Feature Learning: Subsequently, it minimizes the divergence between these identified latent distributions to learn representations that are invariant across them.

The framework uses "pseudo domain-class labels" for fine-grained feature updates and incorporates a gradient reversal layer for adversarial training. For OOD detection, DIVERSIFY offers two implementations: DIVERSIFY-MAH (using Mahalanobis distance) and DIVERSIFY-MCP (using maximum class probability). For generalization, it directly uses the learned representations with a softmax classifier.

Datasets

The paper evaluates DIVERSIFY on several diverse time series datasets across different domains:

  • Gesture Recognition: EMG (Electromyography) data.
  • Speech Commands: Audio recordings of spoken words.
  • Wearable Stress and Affect Detection: WESAD dataset.
  • Sensor-based Human Activity Recognition: DSADS, USC-HAD, UCI-HAR, and PAMAP2 datasets.

These datasets are used in various OOD settings, including cross-person, cross-position, and cross-dataset generalization, as well as for OOD detection tasks.

Key Insights and Ideas

  • Latent Subdomains are Crucial: The paper strongly argues that time series data, even from a single source or person, often contains multiple underlying "latent subdomains" due to temporal and spatial shifts. Ignoring these leads to poor generalization and detection.
  • "Worst-Case" Scenario Maximizes Diversity: By maximizing the divergence between latent subdomains, DIVERSIFY captures the most challenging distribution shifts, leading to more robust and generalizable representations.
  • Domain Labels Not Always Necessary: A key innovation is the ability to identify these latent subdomains and learn from them without explicit domain labels, making the framework more practical for real-world scenarios.
  • Unified Framework for Detection and Generalization: DIVERSIFY is presented as a versatile framework capable of addressing both OOD detection and generalization tasks, demonstrating its broad applicability.

Key Results

DIVERSIFY consistently outperforms state-of-the-art methods across various time series OOD detection and generalization benchmarks.

  • OOD Detection: DIVERSIFY-MAH and DIVERSIFY-MCP achieved significant improvements in AUROC and AUPR compared to baselines, often by substantial margins (e.g., over 62% improvement in AUROC for DIVERSIFY-MAH on USC-HAD in one setting).
  • OOD Generalization: The framework demonstrated superior ID accuracy and generalization performance on diverse tasks like gesture recognition, speech commands, and human activity recognition, often outperforming methods by several percentage points.
  • Robustness: DIVERSIFY showed robust performance across different backbone architectures (CNNs, Transformers) and parameter settings.

Limitations and Future Work

  • Hyperparameter K: The number of latent subdomains (K) is treated as a hyperparameter. The authors suggest future work to automatically estimate K.
  • Semantic Understanding: The paper acknowledges that understanding the semantic meaning behind the identified latent distributions is an open area.
  • Forecasting Problems: The current framework is focused on detection and generalization; extending it to time series forecasting is a potential future direction.
  • Broader Applicability: The authors hypothesize that dynamic distributions are not unique to time series and suggest exploring DIVERSIFY's application to other data modalities like images and text.

Summary updated

BibTeX
@article{lu2024diversify,
  author = {Wang Lu and Jindong Wang and Xinwei Sun and Yiqiang Chen and Xiangyang Ji and Qiang Yang and Xing Xie},
  title = {{Diversify: A General Framework for Time Series Out-of-Distribution Detection and Generalization}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2024},
  doi = {10.1109/tpami.2024.3355212},
}
Figure