This project implements a complete machine learning pipeline for Human Activity Recognition (HAR) using sensor data collected from wearable devices (accelerometer, gyroscope, etc.). The system automatically classifies human activities by extracting and learning patterns from time-series sensor readings.
Supported Activity Classes:
| Activity | Description |
|---|---|
| Walking | Walking |
| Walking_Upstair | Walking upstairs |
| Walking_Downstair | Walking downstairs |
| Sitting | Sitting |
| Standing | Standing |
| Laying | Laying down |
The dataset consists of two CSV files:
- Train set: 460 samples × 563 features
- Test set: 185 samples × 561 features
Features are derived from:
- Body and gravity acceleration signals
- Body gyroscope readings
- Jerk signals
- Signal magnitudes
- Frequency-domain transformations
A total of 561 sensor-based features are available for modeling. The Subject column is excluded from modeling as it is not a predictive feature.
- Load
train.csvandtest.csv - Drop the
Subjectcolumn - Separate features (
X) and target (y) - No missing values present in the dataset
Three tree-based classifiers were evaluated:
| Model | Key Hyperparameters |
|---|---|
| Decision Tree | max_depth=12, min_samples_split=5 |
| Random Forest | n_estimators=200, max_depth=15 |
| Extra Trees (selected) | n_estimators=200, max_depth=15 |
The Extra Trees Classifier was selected as the final model due to its superior generalization performance.
- Accuracy
- Precision (weighted)
- Recall (weighted)
- F1-Score (weighted) — primary evaluation metric
- Confusion Matrix
- 5-Fold Cross-Validation
| Metric | Score |
|---|---|
| Accuracy | ~1.00 |
| Precision | ~1.00 |
| Recall | ~1.00 |
| F1-Score | ~1.00 |
| CV F1 | ~0.96 |
The model exceeds the required threshold of F1-Score ≥ 0.96.
.
├── human_activity_classification.ipynb # Main notebook
├── train.csv # Training data
├── test.csv # Test data
├── submission.csv # Predictions on test set
└── README.md
-
Install dependencies:
pip install numpy pandas scikit-learn
-
Open and run the notebook:
jupyter notebook human_activity_classification.ipynb
-
The final cell generates
submission.csvandresult.zip.
The submission.csv file contains a single column: Activity_Name
Example:
Activity_Name
Standing
Walking
Laying
...