Human Activity Recognition (HAR) using PCA and XGBoost, with Docker-based CPU vs GPU inference benchmarking.
This project implements a Human Activity Recognition pipeline using the UCI Human Activity Recognition dataset. The workflow applies feature standardization and PCA for dimensionality reduction, followed by an XGBoost classifier.
The trained model is then used for Dockerized inference to compare CPU and GPU execution performance.
UCI HAR Dataset
|
v
Feature Standardization
|
v
PCA (561 -> 50 features)
|
v
XGBoost Classifier
|
v
Saved Model
|
+------------------+
| |
v v
CPU Docker GPU Docker
| |
+--------+---------+
|
v
Inference Evaluation
|
v
CPU vs GPU Comparison
- Dataset: UCI Human Activity Recognition (UCI HAR)
- Input features: 561
- Preprocessing: StandardScaler
- Dimensionality reduction: PCA with 50 components
- Classifier: XGBoost
- Activities: Walking, Walking Upstairs, Walking Downstairs, Sitting, Standing, Laying
The evaluated model achieved:
| Metric | Result |
|---|---|
| Test Accuracy | 88.97% |
| GPU Inference Time | 0.01788 s |
| CPU Inference Time | 0.06543 s |
| Reported GPU Speedup | 3.66× |
| Reported Inference Time Reduction | 72.7% |
The repository also includes HAR Dashboard.pdf, which contains the recorded CPU/GPU comparison results and visualizations.
| File | Description |
|---|---|
train_model.py |
Downloads the UCI HAR dataset, preprocesses the data, trains the PCA + XGBoost model, evaluates it, and saves the trained model. |
model_values.py |
Evaluates the saved model using accuracy, macro F1-score, classification report, and multiclass ROC-AUC. |
gpu_har_pipeline.py |
Loads the trained model, performs inference, calculates metrics, and generates CPU/GPU result visualizations. |
Dockerfile.cpu |
Docker configuration for CPU-based inference. |
Dockerfilewithgpu |
Docker configuration for GPU-based inference. |
requirements.txt |
Python dependencies used by the project. |
HAR Dashboard.pdf |
Exported dashboard showing the recorded HAR CPU/GPU analysis and comparison results. |
pip install -r requirements.txtpython train_model.pyThis downloads the UCI HAR dataset, trains the model, and generates:
models/har_model_complete.pkl
The generated dataset and model files are intentionally excluded from version control.
After generating the trained model, the Docker inference pipelines can be built using the corresponding Dockerfiles.
docker build -f Dockerfile.cpu -t har-cpu .docker build -f Dockerfilewithgpu -t har-gpu .The inference pipeline generates evaluation results and visualizations under the results/ directory.
- Python
- XGBoost
- scikit-learn
- PCA
- Docker
- CUDA / CuPy for GPU execution
- Matplotlib
- Seaborn