Update README.md
Browse files
README.md
CHANGED
|
@@ -7,4 +7,105 @@ language:
|
|
| 7 |
metrics:
|
| 8 |
- accuracy
|
| 9 |
pipeline_tag: tabular-classification
|
| 10 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
metrics:
|
| 8 |
- accuracy
|
| 9 |
pipeline_tag: tabular-classification
|
| 10 |
+
---
|
| 11 |
+
# Human Activity Recognition with CNN-LSTM and Residual Connections
|
| 12 |
+
|
| 13 |
+
## 📌 Overview
|
| 14 |
+
This project implements a **Human Activity Recognition (HAR)** model using the **WISDM dataset**.
|
| 15 |
+
The dataset consists of accelerometer and gyroscope sensor data collected from smartphones.
|
| 16 |
+
The proposed model combines **Convolutional Neural Networks (CNNs)** with **Long Short-Term Memory networks (LSTMs)** and integrates **residual connections** to enhance feature extraction and improve gradient flow.
|
| 17 |
+
|
| 18 |
+
The model achieved **~94% accuracy** with augmentation applied, making it suitable for academic and engineering exploration.
|
| 19 |
+
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
## 🎯 Motivation
|
| 23 |
+
- Human activities generate sequential time-series signals from sensors.
|
| 24 |
+
- Classical ML methods often fail to capture **temporal dependencies** and **complex motion patterns**.
|
| 25 |
+
- This project leverages:
|
| 26 |
+
- **CNNs** for local temporal feature extraction.
|
| 27 |
+
- **Residual connections** for stable training of deeper CNNs.
|
| 28 |
+
- **LSTMs** for long-term sequential modeling.
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## 🛠️ Data Preprocessing
|
| 33 |
+
- **Dataset:** [WISDM (Wireless Sensor Data Mining)](https://www.cis.fordham.edu/wisdm/dataset.php).
|
| 34 |
+
- **Challenge:** Class imbalance in activity distribution.
|
| 35 |
+
- **Solution:**
|
| 36 |
+
- Applied **data augmentation** using the **jittering technique** (adding Gaussian noise).
|
| 37 |
+
- Augmentation performed on both training and test sets to increase variability and improve robustness.
|
| 38 |
+
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
+
## 🏗️ Model Architecture
|
| 42 |
+
The CNN-LSTM model with residual connections is structured as follows:
|
| 43 |
+
|
| 44 |
+
1. **Input Layer**
|
| 45 |
+
- Time-series windows from accelerometer & gyroscope data.
|
| 46 |
+
|
| 47 |
+
2. **CNN Block 1**
|
| 48 |
+
- Conv1D (64 filters, kernel size 5) + BatchNorm + Dropout.
|
| 49 |
+
- Residual Conv1D (64 filters) added back to the block output.
|
| 50 |
+
|
| 51 |
+
3. **CNN Block 2**
|
| 52 |
+
- Conv1D (128 filters) + BatchNorm + Dropout.
|
| 53 |
+
|
| 54 |
+
4. **LSTM Layer**
|
| 55 |
+
- LSTM (128 units) to capture long-term dependencies.
|
| 56 |
+
|
| 57 |
+
5. **Dense Layers**
|
| 58 |
+
- Dense (128 units, ReLU) + Dropout.
|
| 59 |
+
- Final Dense layer with **Softmax activation** for multi-class classification.
|
| 60 |
+
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
## ⚙️ Training Strategy
|
| 64 |
+
- **Cross-validation:** 5-fold **Stratified K-Fold**.
|
| 65 |
+
- **Optimizer:** Adam.
|
| 66 |
+
- **Loss Function:** Sparse categorical cross-entropy.
|
| 67 |
+
- **Regularization:**
|
| 68 |
+
- L2 weight decay.
|
| 69 |
+
- Dropout.
|
| 70 |
+
- Early stopping & ReduceLROnPlateau.
|
| 71 |
+
- **Evaluation Metrics:**
|
| 72 |
+
- Accuracy.
|
| 73 |
+
- Macro F1-score.
|
| 74 |
+
- Detailed classification reports per fold.
|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
## 📊 Results
|
| 80 |
+
- Achieved an average **accuracy of ~94%** on the WISDM dataset.
|
| 81 |
+
- Residual connections and the CNN-LSTM hybrid improved performance over standalone CNN or LSTM baselines.
|
| 82 |
+
- Macro F1-scores across folds showed **balanced classification across both majority and minority activity classes**.
|
| 83 |
+
|
| 84 |
+
---
|
| 85 |
+
## ⚠️ Notes
|
| 86 |
+
- This work was conducted for **academic and experimental purposes**.
|
| 87 |
+
- Results are not intended as an official benchmark submission.
|
| 88 |
+
- Data augmentation (jittering) was applied to improve robustness but may not reflect standardized evaluation protocols.
|
| 89 |
+
|
| 90 |
+
## 📖 References
|
| 91 |
+
- WISDM Dataset: [https://www.cis.fordham.edu/wisdm/dataset.php](https://www.cis.fordham.edu/wisdm/dataset.php)
|
| 92 |
+
- Residual Networks: K. He, et al. *Deep Residual Learning for Image Recognition*. CVPR 2016.
|
| 93 |
+
- CNN-LSTM applications in HAR: Ordóñez & Roggen. *Deep Convolutional and LSTM Recurrent Neural Networks for Multimodal Wearable Activity Recognition*. Sensors 2016.
|
| 94 |
+
## Requirements
|
| 95 |
+
|
| 96 |
+
This project requires Python 3.8+ and the following Python libraries:
|
| 97 |
+
|
| 98 |
+
- [TensorFlow](https://www.tensorflow.org/) (for building and training the CNN-BiLSTM model)
|
| 99 |
+
- [Keras](https://keras.io/) (high-level API for neural networks, integrated with TensorFlow)
|
| 100 |
+
- [NumPy](https://numpy.org/) (numerical computations)
|
| 101 |
+
- [Pandas](https://pandas.pydata.org/) (data handling and preprocessing)
|
| 102 |
+
- [Matplotlib](https://matplotlib.org/) (visualization, e.g., loss curves, PCA plots)
|
| 103 |
+
- [Scikit-learn](https://scikit-learn.org/) (PCA, preprocessing, metrics)
|
| 104 |
+
- [Seaborn](https://seaborn.pydata.org/) (optional, for enhanced plots)
|
| 105 |
+
- [tqdm](https://tqdm.github.io/) (optional, progress bars for training loops)
|
| 106 |
+
|
| 107 |
+
## Installation (via pip)
|
| 108 |
+
|
| 109 |
+
```bash
|
| 110 |
+
pip install tensorflow keras numpy pandas matplotlib scikit-learn seaborn tqdm
|
| 111 |
+
|