Exploring Contrastive Learning in Human Activity Recognition for Healthcare

Chi Ian Tang, Ignacio Perez-Pozuelo, Dimitris Spathis, Cecilia MascoloarXiv 2020

Abstract

Human Activity Recognition (HAR) constitutes one of the most important tasks for wearable and mobile sensing given its implications in human well-being and health monitoring. Motivated by the limitations of labeled datasets in HAR, particularly when employed in healthcare-related applications, this work explores the adoption and adaptation of SimCLR, a contrastive learning technique for visual representations, to HAR. The use of contrastive learning objectives causes the representations of corresponding views to be more similar, and those of non-corresponding views to be more different. After an extensive evaluation exploring 64 combinations of different signal transformations for augmenting the data, we observed significant performance differences owing to the order and the function thereof. In particular, preliminary results indicated an improvement over supervised and unsupervised learning methods when using fine-tuning and random rotation for augmentation, however, future work should explore under which conditions SimCLR is beneficial for HAR systems and other healthcare-related applications.

Introduction

Human Activity Recognition (HAR) is a cornerstone of digital health, enabling critical applications ranging from basic step counting to monitoring post-operative recovery. However, HAR research faces a significant "labeling bottleneck." Unlike images, which humans can categorize intuitively, raw sensor data—such as tri-axial accelerometer readings—is abstract and nearly impossible for a person to label without a synchronized ground-truth log. Consequently, high-quality labeled datasets remain small and are often collected in controlled laboratory settings, limiting their generalizability to real-world scenarios.

To address this, this research explores the application of self-supervised learning, specifically contrastive learning. By leveraging the vast amounts of unlabeled sensor data available from mobile devices, we can teach models useful representations of human movement before introducing any manual labels.

Methodology

We adapted the SimCLR (Simple Framework for Contrastive Learning of Visual Representations) framework, originally designed for computer vision, for time-series sensor data. The core logic of SimCLR involves taking a single data sample and applying two different random augmentations to create a "positive pair." The neural network is then trained to recognize that these two views represent the same underlying event while pushing them away from "negative" samples in the same batch.

A key technical challenge was adapting transformation functions for sensor data. While computer vision relies on cropping or color jittering, we evaluated eight time-series-specific augmentations:

  1. Noise: Adding Gaussian noise.
  2. Scaling: Multiplying the signal by a random factor.
  3. Rotation: Applying a random 3D rotation to the tri-axial signal.
  4. Negation: Multiplying values by -1.
  5. Time Flipping: Reversing the time axis.
  6. Permutation: Scrambling segments of the signal.
  7. Time Warping: Stretching or squeezing the time flow using cubic splines.
  8. Channel Shuffling: Randomizing the order of the x, y, and z channels.

The architecture utilizes a Temporal Pooling Network (TPN) as the base encoder and a three-layer Multi-Layer Perceptron (MLP) as the projection head for the contrastive loss (NT-Xent).

Evaluation and Results

The study utilized the MotionSense dataset, featuring tri-axial accelerometer data from 24 subjects performing six distinct activities (walking, jogging, sitting, standing, etc.). We evaluated the model using two protocols: Linear Evaluation, where the encoder is frozen and only a linear classifier is trained, and Fine-tuning, where the entire model is updated.

F1 scores for various augmentation pairs under linear and fine-tuned evaluation on the MotionSense dataset.

Key Insights

  • Augmentation Choice is Critical: The choice of how to distort the data significantly impacts what the model learns. We observed a performance spread of up to 27.8% in F1 score depending solely on which augmentations were paired together.
  • Rotation as the "Cropping" of HAR: In computer vision, random cropping is the most vital transformation for SimCLR. In our HAR study, random rotation emerged as the standout performer. During fine-tuning, rotation-based augmentations reached a peak F1 score of 0.942. This suggests that teaching a model that an activity (like jogging) remains the same regardless of the phone's orientation is a fundamental learning step for the network.
  • Performance Gains: The adapted SimCLR model achieved a performance gain of up to 2% in F1 score compared to fully supervised models. In linear evaluation, the best results (0.872 F1) were achieved by combining channel shuffling and permutation.

Discussion and Future Work

While these results are promising, several limitations remain. The evaluation was limited to the MotionSense dataset; because sensor data varies wildly based on device placement (e.g., wrist vs. pocket), future work must verify these findings across more diverse datasets. Furthermore, we noted that the "best" augmentation for linear evaluation was not always the best for fine-tuning, suggesting that the relationship between specific signal transformations and the resulting feature space is not yet fully understood.

Future research should explore whether these learned representations can improve performance on complex healthcare tasks, such as gait analysis for Parkinson’s disease or automated fall detection, where labeled data is particularly scarce.

Summary updated

BibTeX
@misc{tang2020exploring,
  author = {Chi Ian Tang and Ignacio Perez-Pozuelo and Dimitris Spathis and Cecilia Mascolo},
  title = {{Exploring Contrastive Learning in Human Activity Recognition for Healthcare}},
  year = {2020},
  eprint = {2011.11542},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2011.11542},
}
Figure