aiml report
aiml report
MINI PROJECT
SUBMITTED TO
Bangalore – 560054
SUBMITTED BY
P. Nitya Reddy 1MS22CS098
Joann M. Joseph 1MS22CS072
SUPERVISED BY
Faculty
Jan 2025
1
Department of Computer Science and Engineering
Bangalore – 54
CERTIFICATE
Submitted by Guided by
2
Department of Computer Science and Engineering
Bangalore – 54
Evaluation Sheet
Evaluated By
Name: Ms. Uzma Sulthana
Designation: Assistant Professor
Department: Computer Science & Engineering, RIT
Signature: HOD, CSE
3
Table of Contents
Page No
1. Introduction 6
2. Literature Survey 7
3. Methodology 11
4. Implementation 18
6. Conclusion 26
7. References 29
4
ABSTRACT
Falls are a leading cause of injury and reduced quality of life among the elderly, necessitating
effective fall detection systems to ensure timely intervention and support. This project presents an
AI-driven approach to fall detection using wearable sensor data.
The methodology integrates advanced preprocessing techniques, feature extraction, and machine
learning models to accurately identify falls from non-fall activities.
The system processes accelerometer and gyroscope data from the WEDA dataset, applying window-
based segmentation and normalization for noise reduction and consistency. Feature engineering
leverages time-domain and frequency-domain characteristics, such as mean, root mean square,
skewness, and energy, to extract meaningful insights from the data. A comprehensive feature
selection process refines the input space, ensuring optimal model performance.
For classification, both traditional machine learning models and deep learning architectures,
including Long Short-Term Memory (LSTM) networks, were employed. The LSTM model,
designed to handle sequential data, demonstrated superior performance, achieving a test accuracy of
over 95%. The system also incorporates techniques like class balancing and weighted loss functions
to address data imbalance.
The results highlight the efficacy of the proposed approach in distinguishing falls from daily
activities, underscoring its potential as a reliable fall detection solution. This project lays the
groundwork for integrating wearable technology with AI to enhance elderly care and reduce fall-
related injuries.
Keywords
Fall Detection, Wearable Sensors, Machine Learning, LSTM Networks
5
1. Introduction
Background
o Artificial Intelligence (AI) has emerged as a transformative technology with applications
spanning healthcare, transportation, finance, and more.
o Machine learning, a subset of AI, excels in analyzing patterns and making predictions, often
surpassing traditional methods in accuracy and efficiency.
o Deep learning, a branch of machine learning, is particularly effective in handling complex
data like time-series, images, and natural language. These advancements have enabled
breakthroughs in areas such as disease diagnosis, autonomous systems, and assistive
technologies.
In the context of elderly care, fall detection is a critical area where AI can make a significant impact.
Falls are among the leading causes of injury and death among older adults, with serious physical and
psychological consequences. Wearable sensors combined with AI offer a promising solution for real-
time detection and prevention, providing timely alerts to caregivers and medical professionals.
Problem Statement
The detection of falls using wearable sensor data presents several challenges, including variability in
human activity patterns, noise in sensor signals, and the imbalance between fall and non-fall events
in datasets. Traditional rule-based methods often fail to adapt to these complexities. There is a need
for a robust, AI-driven solution that can accurately distinguish between falls and daily activities in
real-world conditions.
Objectives
1. To preprocess and normalize accelerometer and gyroscope data for consistent input.
2. To extract meaningful features from time-domain and frequency-domain analyses.
3. To employ advanced machine learning models, including Long Short-Term Memory (LSTM)
networks, for accurate classification of falls.
4. To address data imbalance issues using class weighting and augmentation techniques.
5. To evaluate and validate the system’s performance using metrics such as accuracy, precision,
recall, and F1-score.
By achieving these objectives, the project seeks to contribute a robust and efficient AI-based solution
to enhance the safety and well-being of the elderly, ultimately reducing fall-related injuries and
fatalities.
6
2. Literature Survey
Key Studies-
"Support Vector Machine Classifiers Show High Generalizability in Automatic Fall Detection
in Older Adults"
Jalal Alizadeh, Martin Bogdan, Joseph Classen
Sensors - MDPI, 2021
This study emphasizes the high generalizability of SVM classifiers in fall detection for older adults,
demonstrating consistent performance across diverse datasets [1].
"An Elderly Fall Detection System Using Enhanced Random Forest in Machine Learning"
Ravikumar Subburam, Vijay Kandasamy
Engineering Proceedings, 2023
This study improves Random Forest algorithms to enhance fall detection accuracy for elderly
individuals [3].
"An Empirical Study on Fall-detection using K-means Based Training Data Subset Selection"
Dr. Kouichi Sakurai, Dr. Lopa Mandal, Dr. Baisakhi Das, R. Jothi
American Journal of Advanced Computing (AJAC), 2024
This paper uses K-means clustering to reduce training data, improving efficiency without major
accuracy loss [5].
7
Key Findings-
Common Machine Learning Algorithms in Fall Detection
• Decision Trees:
Utilized for both classification and regression, creating a tree-structured model. These are
effective for large datasets, though they can be computationally expensive.
• Random Forest:
An ensemble learning method that builds multiple Decision Trees and aggregates their results
to improve accuracy. This approach requires more computational time and power.
• Support Vector Machine (SVM):
This algorithm creates a decision boundary between classes. It is computationally intensive
but uses less memory compared to some other models.
• K-Nearest Neighbors (KNN):
A simple yet efficient algorithm that classifies based on the similarity to nearby data points. It
is particularly useful for small datasets but is sensitive to noise.
System Overview
The fall detection system leverages various machine learning algorithms, including Decision Trees
(DT), K-Nearest Neighbors (KNN), and Random Forest (RF), to classify falls based on sensor data
such as accelerometer and gyroscope readings.
8
Addressing Limitations in Fall Detection Systems
o Real-world Testing
Validation in real-world scenarios is essential, taking into account varying sensor placements,
user demographics, and diverse activity types to ensure reliable performance outside
controlled environments.
o Data Diversity
Testing systems on more diverse datasets, including varying demographics such as age,
gender, and health conditions, is crucial for improving the model’s generalizability.
o Multimodal Data
Integrating multimodal data (e.g., video, pressure sensors, heart rate) alongside accelerometer
and gyroscope data can significantly improve detection accuracy and robustness.
o Real-World Testing
Processes sensor data from wearable devices with noise filtering and normalization. Ensures
reliable performance in unpredictable, noisy real-world settings.
9
o Data Diversity
Includes multi-sensor data from varied age groups and conditions. Reduces bias and
improves accuracy across diverse populations and scenarios.
o Synthetic Data
Generates rare fall scenarios using GANs or physics-based simulations. Prepares the model to
handle edge cases effectively in real-world deployments.
Citations
[1] J. Alizadeh, M. Bogdan, and J. Classen, "Support Vector Machine Classifiers Show High
Generalizability in Automatic Fall Detection in Older Adults," Sensors - MDPI, 2021.
[2] S. Yoo and D. Oh, "An Artificial Neural Network-based Fall Detection," International Journal of
Engineering Business Management, 2019.
[3] R. Subburam and V. Kandasamy, "An Elderly Fall Detection System Using Enhanced Random
Forest in Machine Learning," Engineering Proceedings, 2023.
[4] T. Subramanyan, Y. JANG, and S. Bock, "Fall Detection System for Elderly People using
Vision-Based Analysis," Romanian Journal of Information Science and Technology, 2020.
[5] K. Sakurai, L. Mandal, B. Das, and R. Jothi, "An Empirical Study on Fall-detection using K-
means Based Training Data Subset Selection," American Journal of Advanced Computing (AJAC),
2024.
[6] L. Martinez-Villaseñor and H. Ponce, "Sensor Location Analysis and Deployment for Fall
Detection System," Journal of Visualized Experiments, 2020.
10
3. Methodology-
3.1.1 Downsampling:
o Sensor data, originally sampled at 50 Hz, was downsampled to 18 Hz to reduce
computational overhead while retaining critical activity features.
o Equations-
11
Fig 3.1.1.1 Before and After Downsampling
3.1.2 Normalization:
o Min-max normalization was applied to scale accelerometer and gyroscope values
between -1 and 1, ensuring consistency and preventing model bias.
o Equation-
12
Fig 3.1.2.3 Effect of normalization on data
3.1.3 Segmentation:
o The data was segmented into overlapping windows of 3 seconds, with a 1.5-
second overlap. This allowed the capture of temporal patterns while maintaining
computational efficiency.
3.1.4 Feature Extraction:
o Time-domain and frequency-domain features, such as mean, root mean square,
skewness, kurtosis, and energy, were calculated for each window to provide a rich
representation of the signal characteristics.
13
o Equations for time-domain, frequency-domain features-
14
3.2 Model Design
The fall detection system employed a hybrid approach, combining traditional machine learning with
deep learning for robust classification.
15
Fig 3.2.2 STM Model Architecture Diagram
16
o Validation data (20% of training data) was used to monitor performance during
training.
Total Training Files=Total Groups×Percent Training
Total Testing Files=Total Groups−Total Training Files
3.3.2 Hyperparameters:
o Learning rate: 0.001
o Batch size: 32
o Epochs: 25
o Optimizer: Adam (for efficient gradient descent)
o Equation-
3.4 Implementation
The project was implemented using the following tools and frameworks:
1. Python Libraries:
o Data manipulation and visualization: Pandas, NumPy, Matplotlib, and Seaborn.
o Machine learning: Scikit-learn for feature selection and traditional classifiers.
o Deep learning: TensorFlow and Keras for building and training the LSTM network.
2. Environment:
o All experiments were conducted on a local machine with Python 3.8. The system
requirements were optimized for memory efficiency due to the large dataset size.
3. Workflow:
o Data preprocessing and feature extraction scripts were modularized to ensure
reusability.
o Model training and evaluation scripts allowed iterative optimization and
hyperparameter tuning.
17
4. Implementation:
Main code-
import os
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier, ExtraTreesClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import LinearSVC
from sklearn.feature_selection import RFE
from sklearn.metrics import accuracy_score, confusion_matrix, classification_report
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt
import seaborn as sns
from keras.models import Sequential
from keras.layers import LSTM, Dense, Dropout
from keras.initializers import Constant
from keras.regularizers import l2
# Load data
X_train_WEDA, info_train_WEDA, y_train_WEDA, X_test_WEDA, info_test_WEDA,
y_test_WEDA = WEDA()
18
# Combine for class distribution analysis
X = pd.concat([X_train_WEDA, X_test_WEDA], axis=0, ignore_index=True)
y = pd.concat([y_train_WEDA, y_test_WEDA], axis=0, ignore_index=True)
# Class distribution
neg, pos = np.bincount(y)
total = neg + pos
class_weight = {0: (1 / neg) * (total / 2.0), 1: (1 / pos) * (total / 2.0)}
# L2 LinearSVC
l2_linearsvc_model = LinearSVC(C=1.00, penalty="l2", dual=False,
class_weight='balanced')
l2_linearsvc_model.fit(X, y)
importances_l2_linearsvc = np.abs(l2_linearsvc_model.coef_)
mean_importance = np.mean(importances_l2_linearsvc, axis=0)
ranking_important_features = np.argsort(mean_importance)[::-1]
19
rfe_decision_tree_indices.intersection(l2_linearsvc_indices)
)
)
plt.figure(figsize=(10, 6))
plt.plot(range(1, len(selected_features) + 1), accuracy_per_number_of_features)
plt.xlabel('Number of Selected Features')
plt.ylabel('Accuracy')
plt.title('Accuracy as a Function of the Number of Selected Features')
plt.grid(True)
plt.show()
x_train = X_train[selected_features]
x_test = X_test[selected_features]
print("Train and Test Shapes:")
print(x_train.shape, x_test.shape, y_train.shape, y_test.shape)
return selected_features
20
X_train_scaled = scaler.fit_transform(X_train_selected)
X_test_scaled = scaler.transform(X_test_selected)
X_train_lstm = X_train_scaled.reshape((X_train_scaled.shape[0], 1,
X_train_scaled.shape[1]))
X_test_lstm = X_test_scaled.reshape((X_test_scaled.shape[0], 1, X_test_scaled.shape[1]))
# LSTM Model
model = Sequential()
model.add(LSTM(128, activation='relu', input_shape=(1, X_train_lstm.shape[2]),
kernel_regularizer=l2(0.01)))
model.add(Dropout(0.2))
model.add(Dense(64, activation='relu', kernel_regularizer=l2(0.01)))
model.add(Dropout(0.2))
model.add(Dense(1, activation='sigmoid', bias_initializer=Constant(initial_bias)))
# Predictions
y_pred_probs = model.predict(X_test_lstm)
y_pred = (y_pred_probs > 0.5).astype(int)
# Confusion Matrix
cm = confusion_matrix(y_test_WEDA, y_pred)
cm_normalized = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
21
# Plot normalized confusion matrix
plt.figure(figsize=(8, 6))
sns.heatmap(
cm_normalized, annot=True, fmt='.2f', cmap='Blues', xticklabels=['No Fall', 'Fall'],
yticklabels=['No Fall', 'Fall']
)
plt.xlabel('Predicted')
plt.ylabel('Actual')
plt.title('Normalized Confusion Matrix')
plt.show()
# Classification Report
print("Classification Report:")
print(classification_report(y_test_WEDA, y_pred, target_names=['No Fall', 'Fall']))
22
5. Results and Discussion
23
Fig 5.3 Confusion Matrix
Results
o As depicted in Fig. 5.1, the accuracy of the model as a function of the number of selected
features is shown. The accuracy stabilizes after selecting a certain number of features,
indicating the optimal number needed for the model without overfitting. The maximum
accuracy achieved is 96%, which suggests that the feature selection process effectively
balances complexity and performance.
o Fig. 5.2 illustrates the training and validation loss over epochs. The convergence of both
losses suggests that the model is not overfitting and is learning effectively across epochs. The
final validation loss is 0.15, indicating a good fit of the model to the validation data.
o The performance of the model is further highlighted in Fig. 5.3, where the normalized
confusion matrix is displayed. It shows high classification accuracy with minimal false
negatives and false positives.
Comparison to benchmarks
24
Discussion
The results indicate that the proposed model achieves high accuracy and robust performance metrics
across various evaluation measures. The optimal feature set ensures that the model does not overfit
while maintaining high accuracy. The convergence of training and validation losses (Fig. 5.2) and
the detailed classification performance (Fig. 5.4) further validate the model's effectiveness. The
combination of optimized feature selection and advanced model architecture plays a crucial role
in these enhanced results.
Implications:
• With high precision and recall, this model is well-suited for critical applications like elderly
care, where accurate and timely fall detection is essential. It reduces false alarms and
ensures quick responses to real falls, improving safety and care quality in various settings.
Strengths:
• The robustness across different performance metrics.
• Effective feature selection that maintains high accuracy.
• Accuracy and efficiency
• Avoiding overfitting and maintaining performance even with limited data.
Limitations:
• The dataset size may affect generalization to unseen data.
• Further validation on different datasets would enhance confidence in the model's applicability
across varied environments.
Future Work:
• Implementing real-time fall detection and alert systems using the trained model.
• Exploring the integration of additional sensor data to improve accuracy.
• Test it on larger, more varied datasets to confirm its scalability and robustness.
• Future improvements may include integrating temporal data and exploring ensemble methods
25
5. Conclusion and Future Work
Conclusion
In this project, we developed and evaluated an LSTM-based model for fall detection using
accelerometer and gyroscope data from the WEDA Fall dataset. The key outcomes of the project are:
• The LSTM model with high precision and recall for the fall class, effectively addressing the
problem of fall detection in real-time applications.
• Feature selection techniques like Extra Trees, RFE, and LinearSVC were utilized to identify
the most relevant features, which enhanced the model’s performance by reducing noise and
computational overhead.
• The model's use of temporal dependencies allowed for more accurate recognition of fall
patterns compared to traditional machine learning models, which tend to overlook the
sequential nature of the data.
These outcomes demonstrate the potential of deep learning, specifically LSTM networks, in
improving the accuracy and reliability of fall detection systems, which is critical for elderly care and
workplace safety.
Broader Impacts
• Healthcare: The system can be integrated into wearable devices, providing continuous
monitoring and timely alerts for fall incidents, which could reduce response times and
prevent complications.
• Smart Home Technology: The fall detection system can be part of a larger home automation
system that ensures the safety of elderly individuals living alone.
• Occupational Safety: Implementing such a system in industrial settings could enhance worker
safety by promptly detecting and addressing fall incidents, thereby reducing workplace
injuries.
Future Work
Several avenues for future research and development could further enhance the effectiveness and
applicability of this AI solution:
• Model Improvements: Future work could involve fine-tuning the LSTM architecture,
experimenting with deeper networks, or incorporating attention mechanisms to further
enhance the model's ability to focus on critical time periods in the data.
• Dataset Expansion: Collecting and incorporating more diverse datasets, including data from
different environments and sensor types, would improve the model's generalization
capabilities.
26
• Real-Time System Scaling: Scaling the system to handle real-time data streams efficiently
while maintaining low latency and high accuracy is essential for practical deployment in real-
world scenarios.
• Multimodal Data Integration: Future research could explore the integration of additional data
types, such as video or audio, to complement the sensor data and provide a more
comprehensive fall detection system.
By addressing these areas, future iterations of the model could offer even more robust and versatile
solutions for fall detection, with broader applicability and improved performance.
27
Acknowledgments
I would like to express my heartfelt gratitude to Ms. Uzma Sulthana, Assistant Professor in
the Department of Computer Science and Engineering at Ramaiah Institute of Technology,
for her invaluable guidance, constant encouragement, and support throughout this project.
Her expertise and insights have been instrumental in shaping the direction and success of this
work.
I am also deeply thankful to Ramaiah Institute of Technology, Bangalore, for providing the
state-of-the-art facilities, resources, and a conducive learning environment that were crucial
for the completion of this project. The support and infrastructure offered by the institution
played a significant role in facilitating my research and development efforts.
Finally, I would like to extend my sincere appreciation to all the individuals of our team who
contributed, directly or indirectly, to the development of this project. Their collaborative
efforts, constructive feedback, and technical support have been invaluable throughout the
project’s lifecycle.
Without their contributions, this work would not have reached its current form.
28
6. References
• L. Martinez-Villasenor and H. Ponce, "Design and Analysis for Fall Detection System
Simplification," Journal of Visualized Experiments, 2020.
• T. Subramanyan, Y.-M. Jang, and S.-B. Jang, "Fall Detection System for Elderly People
using Vision-Based Analysis," Romanian Journal of Information Science and Technology,
2020.
• K. Sakurai, L. Mandal, B. Das, and R. Jothi, "An empirical study on fall-detection using K-
means based training data subset selection," American Journal of Advanced Computing
(AJAC), vol. 1, no. 1, art. 2, 2024.
• J. Alizadeh, M. Bogdan, and J. Classen, "Support Vector Machine Classifiers Show High
Generalizability in Automatic Fall Detection in Older Adults," Sensors - MDPI, 2021.
• S. Yoo and D. Oh, "An artificial neural network-based fall detection," International Journal
of Engineering Business Management, 2019.
• R. Subburam and V. Kandasamy, "An Elderly Fall Detection System Using Enhanced
Random Forest in Machine Learning," Engineering Proceedings, 2023.
29