![]() |
VOOZH | about |
Human Activity Recognition (HAR) refers to the process of identifying and classifying physical movements or actions performed by a person using sensors or other data sources. With the advancement of wearable devices, smartphones and various sensor technologies, HAR has become a critical field in areas such as health monitoring, smart homes, fitness tracking and even security systems. This article will explore how deep learning models are being used to improve the accuracy and efficiency of human activity recognition systems.
Human Activity Recognition involves identifying various activities based on data from sensors. Typically, accelerometers and gyroscopes in smartphones or wearable devices capture motion and orientation data. The main activities commonly recognized in this process are:
Accelerometers measure the magnitude and direction of acceleration, which helps detect movement and orientation. Gyroscopes track the angular rotation to maintain the orientation of the device, unaffected by tilting or rotation.
HAR can be classified as a time-series classification problem because the data collected from sensors, such as accelerometers or cameras, is sequential and depends on time.
Deep learning models have become popular in Human Activity Recognition (HAR) because they can automatically learn features from raw data, unlike traditional machine learning models that require hand-crafted features. This ability makes deep learning models well-suited for handling the complexity and variability of human activities.
The ability of LSTM networks to learn from both short-term and long-term dependencies makes them ideal for complicated HAR tasks, such as identifying anomalies or recognizing complex human actions. LSTM-based models have demonstrated significant improvements in HAR tasks using benchmark datasets and have achieved state-of-the-art performance. They have also shown resilience in detecting complex activities and handling variable-length input sequences.
To perform Human Activity Recognition using an LSTM model, we focus on building a deep learning architecture that can handle time-series data effectively. The LSTM model is specifically designed to capture temporal dependencies in sequential data, making it ideal for recognizing human activities, which evolve over time
Human activity recognition using smartphone sensors like accelerometer is one of the hectic topics of research. HAR is one of the time series classification problem. In this project various machine learning and deep learning models have been worked out to get the best final result. In the same sequence, we can use LSTM (long short term memory) model of the Recurrent Neural Network (RNN) to recognize various activities of humans like standing, climbing upstairs and downstairs etc.
LSTM model is a type of recurrent neural network capable of learning order dependence in sequence prediction problems. This model is used as this helps in remembering values over arbitrary intervals.
Human Activity Recognition dataset can be downloaded from the link given below: HAR dataset
Activities:
Accelerometers detect magnitude and direction of the proper acceleration, as a vector quantity and can be used to sense orientation (because direction of weight changes). GyroScope maintains orientation along a axis so that the orientation is unaffected by tilting or rotation of the mounting, according to the conservation of angular momentum.
Understanding the dataset:
Train and Test data were separated as : The readings from 80% of the volunteers were taken as training data and remaining 20% volunteers records were taken for test data. All the data is present in the folder downloaded using the link provided above.
Phases
The IDE used for this project is Google Colaboratory which is the best of the times to deal with deep learning projects. Phase 1 was explained above as from where the dataset is downloaded. In this sequence to start with the project open a new notebook in Google Colaboratory first import all the necessary libraries.
Code: Importing Libraries
Phase 2: It is uploading dataset in the notebook, before doing that we need to mount the notebook on drive so that this notebook is saved on our drive and retrieved whenever required.
Output:
You will see a pop up similar to one shown in the screenshot below, open the link and copy the authorization code and paste it in the authorization code bar and enter the drive will be mounted.Code: Uploading the dataset
Now moving on to model building and training phase, we need to look for different models which can help in building better accuracy model. Here, LSTM model of Recurrent Neural Network is chosen. The image given below shows how the data looks.
Phase 3: It begins with the data pre-processing. It is the phase where ~90% of time is consumed in actual data science projects. Here, raw data is taken and converted in some useful and efficient formats.
Code: Data transformation is performed to normalize the data
Code: Splitting the dataset
The test size is taken as 20% i.e. out of the total records 20% of records are used for test accuracy while rest is used for training model.
Number of classes = 6 (Walking, Sitting, Standing, Running, Upstairs and Downstairs)
Phase 4: In this phase model chosen is the LSTM model of RNN.
Code: Model building
Code: Performing optimization using AdamOptimizer to modifier loss values wrt the variables to improve accuracy and reduce loss.
Code: Performing 50 iterations of model training to get the highest accuracy and reduced loss
Output:
👁 ImageSo, with this approach the accuracy reaches nearly ~1 at 50th iteration. This indicates that most of the labels are identified clearly by this approach. To get the exact count of correctly identified activities confusion matrix is created.
Code: Accuracy graph
👁 ImageConfusion Matrix: A confusion matrix is no less then a 2D matrix unlike it helps calculating exact count of activities correctly identified. In other words, it describes the performance of the classification model on the set of test dataset.
Code: Confusion matrix
This is the complete description about the project so far. It can be built using other models like CNN or machine learning models like KNN.