Contrastive Learning for Unsupervised Domain Adaptation of Time Series

Yilmazcan Özyurt, Stefan Feuerriegel, Ce Zhang · DOI

Abstract

Unsupervised Domain Adaptation (UDA) is essential for deploying machine learning models in real-world time-series applications where data distributions shift across environments. We present CLUDA (Contrastive Learning for Unsupervised Domain Adaptation), a framework that aligns contextual representations using adversarial training and a custom nearest-neighbor contrastive learning objective. CLUDA ensures that learned features remain invariant across domains while preserving task-relevant information. Our evaluation on human activity recognition and large-scale medical datasets demonstrates that CLUDA consistently outperforms existing UDA baselines, effectively closing the performance gap caused by domain shift.

Introduction

Machine learning models often suffer from performance degradation when the "target domain" (real-world data) differs from the "source domain" (training data), a phenomenon known as domain shift. In time-series domains, such as medical monitoring, this shift is prevalent due to variations in clinical practices, demographics, and sensor hardware. Unsupervised Domain Adaptation (UDA) addresses this by leveraging labeled source data and unlabeled target data to train robust models. However, standard UDA methods often struggle with time-series data, potentially misaligning classes if global feature distributions overlap.

The CLUDA Framework

CLUDA moves beyond simple global feature alignment by focusing on contextual representations. The framework integrates three core components to achieve robust adaptation:

  1. Adversarial Training: A discriminator attempts to identify the domain of a sample, while the feature extractor learns to produce domain-invariant embeddings to "fool" the discriminator.
  2. Momentum Contrast (MoCo): To preserve high-level semantic features, CLUDA employs MoCo-style contrastive learning. By applying augmentations like history cropping and Gaussian noise, the model learns that different views of the same temporal window should have similar embeddings.
  3. Nearest-Neighbor Contrastive Learning (NNCL): This component facilitates cross-domain alignment. For each target sample, CLUDA identifies the most similar source sample in the embedding space and treats them as a positive pair, encouraging the model to cluster target samples with their likely source-domain counterparts.

The architecture utilizes a Temporal Convolutional Network (TCN) as the backbone, which is optimized for capturing long-range dependencies in multivariate time series.

Figure 1: The CLUDA architecture, illustrating the integration of adversarial training, contrastive learning, and nearest-neighbor alignment.

Experimental Evaluation

We evaluated CLUDA across two primary domains:

  • Human Activity Recognition (HAR): Utilizing the WISDM, HAR, and HHAR benchmarks, which involve predicting activities from sensor data across different subjects.
  • Clinical Risk Scoring: Using the MIMIC-IV and AmsterdamUMCdb datasets to predict outcomes like mortality and decompensation in ICU settings.

Results and Discussion

CLUDA demonstrates superior performance compared to established baselines such as CoDATS, AdvSKM, and CDAN. On the HHAR dataset, CLUDA achieved an accuracy of 75.9%, significantly higher than the 62.3% achieved by the best baseline. In cross-continental medical domain transfer (MIMIC to AmsterdamUMCdb), CLUDA recovered 47.6% of the performance gap, nearly tripling the improvement of the next best method.

Figure 6: (a) Performance comparison of CLUDA against UDA baselines across HAR datasets. (b) Ablation study showing the contribution of each component to the overall performance.

Qualitative analysis via t-SNE visualizations confirms that CLUDA successfully merges source and target distributions into tight, class-specific clusters. The ablation study highlights that both the contrastive learning and nearest-neighbor components are vital for achieving these results.

Conclusion and Future Work

CLUDA provides a powerful framework for time-series UDA by aligning high-level contextual representations. While effective, the method currently assumes fixed-length inputs and its performance is sensitive to the choice of data augmentations. Future research will explore more flexible architectures, such as Variational RNNs, to better handle the noise and missing data inherent in real-world time-series signals.

Summary updated

BibTeX
@inproceedings{ozyurt2023contrastive,
  author = {Yilmazcan Özyurt 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