A comprehensive MATLAB implementation for Classifying Human Activities using Inertial Measurement Units (IMUs). This project leverages advanced feature selection techniques and multiple machine learning classifiers to achieve high accuracy in HAR (Human Activity Recognition).
This repository provides a complete pipeline for processing IMU data from the UCI Human Activity Recognition (HAR) dataset. It focuses on optimizing classification performance by selecting the most relevant features using a Discrete Biogeography-Based Optimization (BBO) algorithm.
- Intelligent Feature Selection: Implementation of a custom Discrete BBO to reduce dimensionality and improve model efficiency.
- Support for Multiple Classifiers: Easily switch between K-Nearest Neighbors (KNN), Linear Discriminant Analysis (LDA), and Decision Trees.
- Robust Validation: Built-in K-Fold Cross-Validation to ensure model generalizability.
- Detailed Evaluation: Generates confusion matrices and per-class accuracy metrics.
The project uses the UCI Human Activity Recognition Using Smartphones Dataset.
- 🔗 Access the Dataset Here
- The dataset includes recordings of 30 subjects performing activities of daily living while carrying a waist-mounted smartphone with embedded inertial sensors.
| File/Folder | Description |
|---|---|
Main.mlx |
The primary entry point (MATLAB Live Script) for running the detection pipeline. |
Classifier.m |
Core classification engine supporting KNN, LDA, and Trees with cross-validation. |
DiscreteBBO.m |
Implementation of the Biogeography-Based Optimization for feature selection. |
importfile.m |
Utility script for loading and preprocessing raw IMU data. |
Data-Description/ |
Detailed documentation regarding the source data and sensors. |
Results/ |
Storage for output metrics, plots, and performance logs. |
- MATLAB (R2021a or later recommended)
- Statistics and Machine Learning Toolbox
- Clone the repository:
git clone https://github.com/BanaanKiamanesh/IMU-Activity-Detection.git
- Download the dataset from the link above and place it in the appropriate directory (or update the path in
Main.mlx). - Open
Main.mlxin MATLAB. - Run the sections to execute data loading, feature selection, and classification.
- Preprocessing: Data is imported and normalized.
- Feature Selection: The
DiscreteBBOalgorithm identifies the most significant sensor readings (acceleration, angular velocity, etc.) to optimize the classification cost function. - Classification: The selected features are fed into the chosen classifier (
KNNby default). - Evaluation: Performance is assessed using 10-fold cross-validation.
Results, including classification accuracy and optimized feature subsets, are saved in the Results/ directory. The pipeline aims for maximum balanced accuracy across all activity types (Walking, Sitting, Standing, etc.).
Contributions are welcome! Please feel free to submit a Pull Request or open an issue for any bugs or feature requests.
Developed by Banaan Kiamanesh