Sensor-Based Exercise Classifier
Classifying 8 gym exercises from smartphone sensor data using LSTM networks, Random Forest, and signal processing techniques.
June 1, 2024
Deep LearningLSTMTime Seriesscikit-learn
Overview
Group project for Machine Learning for Quantitative Self (ML4QS) at Vrije Universiteit Amsterdam (M.Sc. AI). Built a system that classifies gym exercises from smartphone sensor data strapped to the upper arm, using both classical ML and deep learning approaches.
Data Collection
- Smartphone (PhyPhox app) strapped to the upper left arm during workouts
- Sensors: 3-axis gyroscope, 3-axis accelerometer, compensated accelerometer, light, proximity, GPS, magnetometer
- Polling at ~500Hz (0.002s intervals) for accelerometer and gyroscope
- 8 exercises across 4 muscle groups:
- Chest: Bench Press, Cable Flys
- Back: Deadlift, Pull-ups
- Arms: Bicep Curls, Shoulder Press
- Core: Crunches, Russian Twists
Feature Engineering
- Time-step aggregation to 0.02s intervals to reduce sparsity
- Velocity computation from discrete acceleration integration
- Resultant acceleration: sqrt(ax² + ay² + az²)
- Butterworth low-pass filter (50Hz base, 55Hz cutoff) for noise removal
- KNN imputation for missing values after time aggregation
- Removed irrelevant features (GPS, magnetometer) based on correlation analysis
Models
- Random Forest: For feature importance analysis and baseline classification
- LSTM Network: Sequence-based classification using rolling window features with MinMaxScaler normalization
- Both approaches significantly outperformed random baselines, with accelerometer and gyroscope features dominating importance
Technologies
Python, TensorFlow/Keras (LSTM), scikit-learn (Random Forest), Pandas, NumPy, PhyPhox