Back to projects
SIWES Internship Project2025

Detecting BFRB Behavior using Sensor Data

Adeteye Adedimeji JamesDepartment of Computer Science and EngineeringFaculty of Technology

Abstract

This project presents a machine learning-based approach to detecting Body-Focused Repetitive Behaviors (BFRBs) such as hair pulling and skin picking using multimodal wearable sensor data. Addressing challenges like data imbalance, missing values in Time-of-Flight and Thermopile sensors, and noisy signals, the study utilized structured preprocessing, PCA-based feature reduction, and tree-based ensemble models. The experimental results, specifically using a Random Forest classifier, demonstrated high predictive performance with an F1-score of 0.88, confirming the feasibility of the proposed system for scalable, real-time behavioral health monitoring.

Problem statement

Body-Focused Repetitive Behaviors (BFRBs) such as hair pulling, skin picking, and nail biting often occur subconsciously, making them difficult to detect in real time. Traditional monitoring methods are intrusive and unreliable for continuous tracking. The main challenge lies in distinguishing subtle BFRB motions from normal activities within noisy, high-frequency sensor data. Missing or incomplete readings further complicate detection.

Objectives

  • Design a robust machine learning model that detects BFRB activities from wearable sensor data.
  • Learn motion and temperature-based behavioral patterns from accelerometer, gyroscope, thermopile, and time-of-flight sensor data.
  • Develop a scalable pipeline for real-world behavioral monitoring by handling missing data, extracting statistical features, and addressing class imbalance.

Methodology

The project involved a comprehensive data pipeline. Data preprocessing included handling missing values using IterativeImputer for Time-of-Flight sensor data, encoding categorical gesture labels, and clipping extreme temperature readings from the Thermopile sensor to a range of 0°C to 40°C. Feature engineering included creating an acc_mag feature for total acceleration, transforming rotation data into quaternion representations, and reducing high-dimensional Time-of-Flight data using PCA to retain 20 components explaining 95% of variance. A tree-based tabular modeling strategy was adopted. Various models including Random Forest, Extra Trees, LightGBM, and XGBoost were trained using a stratified 5-fold cross-validation approach. To address the severe class imbalance, class-specific strategies were applied: Decision Tree, Random Forest, and Extra Trees used class_weight='balanced', XGBoost adjusted the scale_pos_weight parameter based on class ratios, and LightGBM enabled is_unbalance=True. Hyperparameter tuning was conducted using RandomizedSearchCV with metrics prioritized toward F1-score to ensure fairness across minority disease classes.

Results

The evaluation emphasized fairness over overall accuracy due to the highly imbalanced dataset. The models were evaluated using F1-score, precision, and recall. Among the tested models, the Extra Trees classifier achieved an F1-score of 0.88, precision of 0.86, and recall of 0.86. The Random Forest classifier emerged as the best-performing model, demonstrating the most balanced trade-off between precision and recall with an F1-score of 0.88, precision of 0.89, and recall of 0.88. The LightGBM model achieved an F1-score of 0.84, precision of 0.83, and recall of 0.83. The final Random Forest model was submitted to the Kaggle evaluation platform, achieving a public leaderboard score of 0.46, which, compared to the top score of 0.82, indicated reasonable generalization despite significant dataset noise and imbalance.

Conclusion

The project successfully demonstrated that Body-Focused Repetitive Behaviors (BFRBs) could be effectively detected using time-series data from wearable sensors formulated as a binary classification task. The research addressed critical real-world challenges including class imbalance, missing sensor modalities, varying sequence lengths, and noisy measurements through structured preprocessing, feature engineering, and model optimization. The final Random Forest classifier showed strong generalization, confirming the viability of classical machine learning approaches for sensor-based behavioral detection and providing a solid foundation for developing scalable, real-time monitoring systems for behavioral health applications.

Technologies

Random ForestExtra TreesLightGBMXGBoostScikit-learnIterativeImputerPrincipal Component Analysis (PCA)LabelEncoderPython

Keywords

BFRBSensor DataWearable TechnologyMachine LearningFeature EngineeringBehavioral Monitoring

Source document

DIMEJI IT REPORT_261003_124130.pdf