OCD-Sense: A Novel Wearable Sensor Dataset and Transformer Framework for Recognizing OCD-Relevant Behaviors
Abstract
Objective and unobtrusive monitoring of repetitive behaviors could complement self-reported assessment of obsessive-compulsive disorder (OCD), but existing human activity recognition (HAR) datasets primarily target general activities of daily living and often lack behaviors relevant to OCD. We introduce OCD-Sense, a purpose-built wearable-sensor dataset collected from 35 adults performing 36 activities in semi-natural environments using commercially available smartphones and smartwatches at 50 Hz. The activities include personal-hygiene and house-cleaning behaviors relevant to contamination-related compulsions, together with activities of daily living, and are organized into six recognition classes: face washing, foot washing, hand washing, toothbrushing, house cleaning, and other activities. We develop a wearable HAR pipeline that addresses missing measurements, sensor noise, orientation variability, class imbalance, and overfitting, and evaluate conventional machine-learning and deep-learning approaches. Our best-performing model is a compact Transformer operating on 16-dimensional sensor inputs with three encoder layers, 128-dimensional representations, two self-attention heads, and 256-dimensional feed-forward layers. The Transformer achieves 98.93% training, 93.56% validation, and 94.29% held-out test accuracy, improving test accuracy by 2.23 percentage points over the previous best CNN-LSTM model (92.06%). Test-set class-wise recognition ranges from 88% to 99%, with 99% recognition for both hand washing and toothbrushing. These findings demonstrate that self-attention-based temporal modeling can effectively recognize OCD-relevant behavioral patterns from everyday wearable sensors. OCD-Sense provides a foundation for accessible, privacy-preserving longitudinal behavioral monitoring without audio, video, or specialized sensing hardware. Because the current dataset comprises non-clinical participants performing OCD-relevant activities, the proposed system is intended for behavior recognition rather than OCD diagnosis, with future validation needed in clinically diagnosed populations.