Skip to content

About

Human Activity Recognition using PCA and XGBoost with Docker-based CPU vs GPU inference benchmarking.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Docker HAR CPU vs GPU

Human Activity Recognition (HAR) using PCA and XGBoost, with Docker-based CPU vs GPU inference benchmarking.

Overview

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.

Pipeline

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

Model

  • 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

Results

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.

Project Files

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.

Running the Training Pipeline

1. Install Dependencies

pip install -r requirements.txt

2. Train the Model

python train_model.py

This 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.

Docker Inference

After generating the trained model, the Docker inference pipelines can be built using the corresponding Dockerfiles.

CPU

docker build -f Dockerfile.cpu -t har-cpu .

GPU

docker build -f Dockerfilewithgpu -t har-gpu .

The inference pipeline generates evaluation results and visualizations under the results/ directory.

Technologies

  • Python
  • XGBoost
  • scikit-learn
  • PCA
  • Docker
  • CUDA / CuPy for GPU execution
  • Matplotlib
  • Seaborn

About

Human Activity Recognition using PCA and XGBoost with Docker-based CPU vs GPU inference benchmarking.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages