Contrastive Learning for Unsupervised Domain Adaptation of Time Series

Yilmazcan Ozyurt, Stefan Feuerriegel, Ce Zhang

Overview

CLUDA (Contrastive Learning for Unsupervised Domain Adaptation) is a novel framework designed to tackle the "domain shift" problem in multivariate time series data. By combining adversarial training with a unique nearest-neighbor contrastive learning strategy, it learns to align complex temporal patterns across different domains (like different hospitals or sensor users) without requiring any labels in the target domain. The result is state-of-the-art performance on both activity recognition and medical risk-scoring tasks.

The Challenge of Domain Shift in Time Series

Machine learning models often fail when deployed in environments different from their training data—a phenomenon known as domain shift. In the medical field, for example, a risk-scoring model trained on patients in a US hospital might perform poorly in a European hospital due to differences in clinical routines, patient demographics, or reporting practices.

While Unsupervised Domain Adaptation (UDA) has been extensively studied for computer vision, time series data presents unique challenges. Temporal dynamics are harder to align than static pixels, and simple feature alignment often "mixes" different classes together, leading to poor generalization. Existing time series UDA methods often fail to effectively capture and align the contextual information—the high-level semantic meaning of a sequence—across domains.

The CLUDA Methodology

To address these gaps, the authors propose CLUDA, a framework that rests on three main pillars:

CLUDA Architecture
  1. Adversarial Training: A standard UDA technique where a "discriminator" tries to guess which domain a sample comes from, while the "feature extractor" learns to fool it. This encourages the model to find features that are common to both the source and target domains.
  2. Contextual Contrastive Learning (CL): Using a Momentum Contrast (MoCo) approach, the model learns to recognize a time series even when it's heavily augmented (e.g., cropped, jittered, or noisy). This forces the model to extract "contextual representations" that preserve the underlying label information.
  3. Nearest-Neighbor Contrastive Learning (NNCL): This is the paper's "secret sauce." Since target labels are unknown, CLUDA finds the nearest neighbor in the source domain for every target sample in the embedding space. It then treats these as a "positive pair," explicitly pulling the target representation toward its most similar source counterpart. This effectively performs class-aware alignment without ever seeing a target label.

Key Insights

  • Context over Raw Features: The authors hypothesize that the discrepancy between contextual representations (high-level patterns) is smaller than the discrepancy between raw feature spaces. By aligning the "context," the adaptation task becomes significantly easier.
  • The Power of Neighbors: The NNCL component acts as a proxy for labels. By assuming that a target sample's nearest neighbor in the source domain likely belongs to the same class, the model can perform fine-grained alignment that prevents the "class mixing" seen in simpler adversarial methods.
  • Visual Proof: t-SNE visualizations in the study provide a clear "aha moment." While baseline methods often create overlapping "clouds" of source and target data that still mix different classes, CLUDA clearly pulls samples of the same class together into tight, distinct clusters, regardless of which domain they originated from.

Datasets and Key Results

The authors evaluated CLUDA on two distinct types of data:

  • Human Activity Recognition (HAR) Benchmarks: WISDM, HAR, and HHAR. These involve 3-axis accelerometer/gyroscope data from smartphones and smartwatches to predict activities like walking, jogging, or sitting.
  • Large-Scale Medical Datasets: MIMIC-IV (Boston, USA) and AmsterdamUMCdb (Amsterdam, Netherlands). These are massive ICU datasets used to predict critical outcomes like mortality, decompensation (sudden health decline), and length of stay.

CLUDA consistently outperformed a wide array of baselines, including those specifically designed for time series (like CoDATS and VRADA) and adapted computer vision methods (like CDAN).

Performance and Ablation Results
  • Benchmarks: On the HAR dataset, CLUDA improved accuracy by 18.9% over the best baseline (CDAN). On HHAR, the improvement was 21.8%.
  • Medical Tasks: In the "cross-hospital" case study (MIMIC $\rightarrow$ AUMC), CLUDA filled nearly 48% of the performance gap for decompensation prediction, whereas the best baseline only managed 16.7%.
  • Ablation Study: The authors showed that removing either the Contrastive Learning or the Nearest-Neighbor component led to significant performance drops, proving that the synergy between these techniques is vital.

Limitations and Future Work

  • Fixed-Length Assumption: The core framework assumes time series are of a fixed length $T$. While the authors discuss how to adapt it for variable-length data (using Temporal Convolutional Networks or generative models like VRNNs), it wasn't the primary focus of the experiments.
  • Augmentation Dependency: Like all contrastive methods, CLUDA's success depends on choosing "semantic-preserving" augmentations. If an augmentation changes the fundamental meaning of the data (e.g., turning a "walking" signal into a "running" signal), the model will learn incorrect representations.
  • Future Directions: The authors suggest that future work could explore more sophisticated ways to handle the "heavy tail" distribution of medical outcomes (like length of stay) and further refine the selection of nearest neighbors to reduce noise in the alignment process.

Summary updated

BibTeX
@inproceedings{ozyurt2023contrastive,
  author = {Yilmazcan Ozyurt and Stefan Feuerriegel and Ce Zhang},
  title = {{Contrastive Learning for Unsupervised Domain Adaptation of Time Series}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=xPkJYRsQGM},
}
Figure