Contrastive Learning with Auxiliary User Detection for Identifying Activities

Wen Ge, Guanyi Mou, Emmanuel O. Agu, Kyumin Lee

Abstract

Human Activity Recognition (HAR) systems often struggle with the inherent heterogeneity of human movement, where the same activity is performed differently across individuals. This paper introduces CLAUDIA (Contrastive Learning with Auxiliary User Detection for Identifying Activities), a framework designed to improve HAR by integrating User Identification (UI) as an auxiliary task. By employing a novel supervised contrastive loss, CLAUDIA learns user-invariant activity representations. Experimental results on three benchmark datasets—WASH scripted, WASH unscripted, and Extrasensory—demonstrate that CLAUDIA significantly outperforms state-of-the-art models, particularly in real-world, unscripted environments.

Introduction

Modern Human Activity Recognition (HAR) has evolved to be increasingly Context-Aware (CA), accounting for variables such as device placement (e.g., phone in pocket vs. hand). However, a significant gap remains in User-Awareness (UA). Human behavior is highly heterogeneous; factors like gait, speed, and personal habits mean that "walking" or "climbing stairs" looks different from one person to the next.

Traditional models often fail to generalize across diverse users because they do not explicitly distinguish between user-specific nuances and the core patterns of the activity itself. CLAUDIA addresses this by bridging the gap between capturing user-specific patterns for identification and extracting user-invariant patterns for robust activity recognition.

The CLAUDIA Framework

CLAUDIA treats User Identification (UI) not as a nuisance variable, but as a beneficial auxiliary subtask. The framework is composed of three primary modules:

1. Data Encoder

The model utilizes a multi-modal encoding strategy. It processes raw sensor time-series data through a two-layer Long Short-Term Memory (LSTM) network to capture local temporal rhythms. Simultaneously, it incorporates handcrafted features to capture global statistical properties, ensuring a comprehensive representation of the signal.

2. Alignment Module

Following encoding, the alignment module projects the data into distinct latent spaces. These spaces are optimized for three specific objectives: activity prediction, phone placement prediction, and user identification. This separation allows the model to disentangle features relevant to the user's identity from those relevant to the activity.

3. Supervised Contrastive Loss ($L_d$)

The core innovation of CLAUDIA is its supervised contrastive loss function. Unlike standard self-supervised approaches that rely on data augmentation, CLAUDIA leverages ground-truth labels to pull together representations of the same activity performed by different users. Simultaneously, it pushes apart representations of different activities. To maintain stability during optimization—especially in multi-label batches where the number of positive and negative pairs fluctuates—the authors implement a strategy of averaging vectors for positive and negative samples before calculating the loss.

Experimental Evaluation

Datasets

The framework was evaluated on three benchmark datasets representing varying degrees of environmental control:

  • WASH scripted: Data from controlled environments with specific participant instructions.
  • WASH unscripted: "In-the-wild" data where participants performed natural daily activities.
  • Extrasensory: A large-scale dataset featuring over 6 million instances from 60 participants using smartphones and smartwatches in unscripted settings.

Performance Metrics

To account for class imbalances common in HAR data, the study utilized the Matthews Correlation Coefficient (MCC) and Macro F1 scores as primary evaluation metrics.

Results and Discussion

CLAUDIA consistently outperformed established baselines, including Graph Convolutional Networks (GCNs) and LightGBM.

  • Significant Gains in Accuracy: The model achieved an average improvement of 11.7% to 14.2% in MCC and 5.4% to 7.3% in Macro F1 scores across the tested datasets.
  • Robustness in Unscripted Settings: The most substantial performance leaps occurred in unscripted datasets. This suggests that CLAUDIA is uniquely capable of handling the messy, varied behaviors characteristic of real-world applications, whereas traditional models tend to overfit to specific, scripted movement patterns.
  • High-Fidelity User Identification: The model achieved near-perfect UI performance (up to 0.999 F1 score). This dual capability has significant implications for security and medical compliance, such as verifying that a specific patient is performing their prescribed physical therapy exercises.
  • Ablation Insights: Removing the LSTM component resulted in the most significant performance degradation, confirming that temporal sequencing is vital for distinguishing between similar activities, such as ascending versus descending stairs.

Conclusion

CLAUDIA demonstrates that incorporating user identity as a regularization factor, rather than a source of noise, significantly enhances the reliability of activity recognition. While the current implementation focuses on recurrent architectures, future work will explore the integration of Transformers to better capture long-range dependencies. Additionally, the high accuracy of user identification necessitates future research into privacy-preserving techniques, such as differential privacy, to ensure the secure deployment of UA-HAR systems in sensitive environments.

Summary updated

Abstract

Human Activity Recognition (HAR) is an important task in ubiquitous computing, with impactful real-world applications. While recent state-of-the-art HAR research has demonstrated impressive performance, some key aspects remain under-explored. First, we believe that for optimal performance, HAR models should be both Context-Aware (CA) and personalized. However, prior work has predominantly focused on being Context-Aware (CA), largely ignoring being User-Aware (UA). We argue that learning user-specific differences in performing various activities is as critical as considering user context while performing HAR tasks. Secondly, we believe that the predictions of HAR models should be unified, reliably recognizing the same activity even when performed by different users. As such, the representations utilized by CA and UA models should explicitly place different users performing the same activity closer together. Moreover, identifying the user performing an activity is useful in applications such as thwarting cheating by having another person perform medically-prescribed activities. To bridge this gap, we introduce Contrastive Learning with Auxiliary User Detection for Identifying Activities (CLAUDIA), a novel framework designed to address these issues. Specifically, we expand the contextual scope of the CAHAR task by integrating User Identification (UI) within the CAHAR framework, jointly predicting both CAHAR and UI in a new task called User and Context-Aware HAR (UCA-HAR). This approach enriches personalized and contextual understanding by jointly learning user-invariant and user-specific patterns. Inspired by state-of-the-art designs in the visual domain, we introduce a supervised contrastive loss objective on instance-instance pairs to enhance model efficacy and improve learned feature quality. Through theoretical exposition, empirical analysis of real-world datasets, and rigorous experimentation, we demonstrate the significance of each component of CLAUDIA and discuss its relationship with existing methodologies. Evaluation across three real-world CA-HAR datasets reveals substantial performance enhancements, with average improvements ranging from 11.7% to 14.2% in Matthew's Correlation Coefficient (MCC) and 5.4% to 7.3 % in Macro F1 score. To encourage further research, we share code with additional supplement material in repository https://github.com/GMouYes/CLAUDIA.
BibTeX
@inproceedings{ge2024contrastive,
  author = {Wen Ge and Guanyi Mou and Emmanuel O. Agu and Kyumin Lee},
  title = {{Contrastive Learning with Auxiliary User Detection for Identifying Activities}},
  booktitle = {ICMLA},
  year = {2024},
  url = {https://openreview.net/forum?id=GNIVLB44rv},
}
Figure