This project focuses on classifying barbell exercises using accelerometer and gyroscope data while also counting the number of repetitions performed. It involves data processing, feature engineering, model selection, hyperparameter tuning, and evaluation to achieve high classification accuracy. Additionally, a dedicated script estimates the repetition count based on filtered motion data.
barbell-exercise-classification/
│
├── assets/ # Images and figures related to results and analysis
│
├── data/
│ ├── raw/ # Raw CSV files containing accelerometer and gyroscope data
│ ├── interim/ # Processed datasets after initial cleaning
│ ├── processed/ # Fully processed datasets ready for training
│
├── docs/ # Documentation files
│
├── models/ # Saved Models
│
├── notebooks/ # Jupyter notebooks for experiments and analysis
│
├── reports/
│ ├── figures/ # Visual representations of analysis and results
│
├── src/
│ ├── data/
│ │ ├── make_dataset.py # Script for dataset preparation
│ │
│ ├── features/
│ │ ├── remove_outliers.py # Outlier removal scripts
│ │ ├── build_features.py # Feature engineering scripts
│ │ ├── DataTransformation.py # Low-pass filtering and PCA for sensor data
│ │ ├── FrequencyAbstraction.py # Frequency domain feature extraction
│ │ ├── TemporalAbstraction.py # Temporal feature extraction
│ │ ├── count_repetitions.py # Repetition counting algorithm
│ │
│ ├── models/
│ │ ├── train_model.py # Training script for machine learning models
│ │ ├── LearningAlgorithms.py # Implementation of various learning algorithms
│ │
│ ├── visualization/
│ │ ├── visualize.py # Data visualization scripts
│
├── requirements.txt # Required dependencies
└── README.md # Project documentation
- The raw sensor data (accelerometer and gyroscope readings) is loaded from CSV files.
- Data is labeled according to exercise type and participant ID.
- Necessary preprocessing, such as handling missing values and standardizing column names, is performed.
- The processed data is saved as an interim dataset.
- The sensor readings for acceleration and gyroscope signals across all three axes are plotted.
- Visual comparison of exercises is done to identify patterns and trends.
- Each exercise type is plotted separately to analyze motion characteristics.
- Statistical techniques (e.g., Z-score and IQR-based filtering) are applied to detect and remove extreme outliers.
- Removing outliers improves the model’s performance by preventing bias from erroneous data.
Various feature extraction techniques were implemented to improve model performance:
- A low-pass filter is applied to smooth sensor readings and remove high-frequency noise.
- Enhances the ability to detect repetitions more accurately.
- Aggregated statistical features such as mean, standard deviation, min, and max over a rolling window.
- Helps capture time-dependent variations in the signal.
- Extracts frequency-domain features using Fourier Transform.
- Captures periodic movement patterns that are essential for distinguishing exercises.
- KMeans clustering is applied to accelerometer data to identify movement patterns.
- The optimal number of clusters is determined using the Elbow method, and 3D scatter plots visualize the clustered data.
- This approach extracts features that improve exercise classification by capturing latent movement variations.
- Multiple machine learning models, including Random Forest, Neural Networks, Decision Trees, KNN, and Naive Bayes, were trained and evaluated.
- Hyperparameter tuning was performed to optimize accuracy.
- A comparison of different models based on accuracy is studied.
- The number of repetitions performed in each exercise is counted using peak detection techniques.
- A low-pass filter is applied to smooth the acceleration magnitude before counting peaks.
- The results are evaluated against known repetition counts using Mean Absolute Error (MAE).
The table below shows the accuracy of different models trained on various feature sets:
Model | Feature Set | Accuracy |
---|---|---|
RF | Feature Set 4 | 99.59% |
NN | Feature Set 4 | 99.48% |
RF | Selected Features | 98.97% |
NN | Feature Set 3 | 98.76% |
RF | Feature Set 3 | 98.55% |
DT | Selected Features | 98.24% |
DT | Feature Set 4 | 98.24% |
NN | Selected Features | 97.31% |
KNN | Feature Set 4 | 96.89% |
DT | Feature Set 3 | 95.76% |
- Accuracy: 99.59%
- Accuracy: 99.45%
- Accuracy: 99.45%
- Random Forest and Neural Network models achieved the highest accuracy, making them ideal for classifying exercises.
- Feature engineering significantly improved classification performance.
- The repetition counting script performed well, with minimal error in rep counts.
- The final models are robust and generalize well across different participants.
conda env create -f environment.yml
conda activate barbell-classification
- Train the Model:
python src/models/train_model.py
- Count Repetitions:
python src/features/count_repetitions.py