Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Human Activity Recognition (HAR) Classification

Overview

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

Dataset

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.


Approach

1. Data Loading & Preprocessing

  • Load train.csv and test.csv
  • Drop the Subject column
  • Separate features (X) and target (y)
  • No missing values present in the dataset

2. Modeling

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.

3. Evaluation Metrics

  • Accuracy
  • Precision (weighted)
  • Recall (weighted)
  • F1-Score (weighted) — primary evaluation metric
  • Confusion Matrix
  • 5-Fold Cross-Validation

Results

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.


Project Structure

.
├── human_activity_classification.ipynb   # Main notebook
├── train.csv                             # Training data
├── test.csv                              # Test data
├── submission.csv                        # Predictions on test set
└── README.md

How to Run

  1. Install dependencies:

    pip install numpy pandas scikit-learn
  2. Open and run the notebook:

    jupyter notebook human_activity_classification.ipynb
  3. The final cell generates submission.csv and result.zip.


Submission Format

The submission.csv file contains a single column: Activity_Name

Example:

Activity_Name
Standing
Walking
Laying
...

About

این پروژه یک سیستم تشخیص فعالیت انسانی (HAR) با استفاده از داده‌های حسگرهای پوشیدنی (شتاب‌سنج و ژیروسکوپ) است. داده‌ها شامل ۵۶۱ ویژگی و ۶ کلاس فعالیت مانند راه‌رفتن و نشستن هستند. پس از پیش‌پردازش، سه مدل درختی ارزیابی شده و **Extra Trees** به دلیل عملکرد برتر (دقت و F1 حدود ۱ در اعتبارسنجی و ۰.۹۶ در CV) به عنوان مدل نهایی انتخاب شده است.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages