0% found this document useful (0 votes)
27 views42 pages

Final Report

Uploaded by

Mani Sandeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views42 pages

Final Report

Uploaded by

Mani Sandeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

CAPSTONE PROJECT REPORT

(Project Term January-May 2024)

HUMAN STRESS DETECTION USING


MACHINE LEARNING

Submitted by

Yedoti Mahesh 12005660

C. Manoj Kumar Raju 12003450

Pogarthi Sindhura 12004533

Male Sowmya Reddy 12018581

Srishti Dwivedi 12005693

Chekonda Alex Nitin 12003121

Project Group Number: CSERGC0261


Course Code: CSE445

Under the Guidance of


Sanjay Babu Jaiswal
Assistant Professor
Lovely Professional University

SCHOOL OF COMPUTER SCIENCE AND ENGINEERING

1
TOPIC APPROVAL PERFORMA

School of Computer Science and Engineering (SCSE)

Program : P132::B.Tech. (Computer Science and Engineering)

COURSE CODE : CSE445 REGULAR/BACKLOG : Regular GROUP NUMBER : CSERGC0261

Supervisor Name : Sanjay Babu Jaiswal UID : 31174 Designation : Assistant Professor

Qualification : Research Experience :

SR.NO. NAME OF STUDENT Prov. Regd. No. BATCH SECTION CONTACT NUMBER

1 Male Sowmya 12018581 2020 K20FH 8374913643


2 Srishti Dwivedi 12005693 2020 K20DA 9129076729

3 Yedoti Mahesh 12005660 2020 K20CR 9949650109


4 Pogarthi Sindhura 12004533 2020 K20GR 7675810818
5 Chamarthi Manoj Kumar Raju 12003450 2020 K20DA 8897393885

6 Chekonda Alex Nitin 12003121 2020 K20GR 8328086697

SPECIALIZATION AREA : Database System-II Supervisor Signature:

PROPOSED TOPIC : HUMAN STRESS DETECTION WITH PRECAUTIONS USING MACHINE LEARNING ALGORITHMS

Qualitative Assessment of Proposed Topic by PAC


Sr.No. Parameter Rating (out of 10)

1 Project Novelty: Potential of the project to create new knowledge 5.67

2 Project Feasibility: Project can be timely carried out in-house with low-cost and available resources in 6.00
the University by the students.
3 Project Academic Inputs: Project topic is relevant and makes extensive use of academic inputs in UG 7.00
program and serves as a culminating effort for core study area of the degree program.
4 Project Supervision: Project supervisor’s is technically competent to guide students, resolve any issues, 7.00
and impart necessary skills.
5 Social Applicability: Project work intends to solve a practical problem. 6.33

6 Future Scope: Project has potential to become basis of future research work, publication or patent. 6.00

PAC Committee Members

PAC Member (HOD/Chairperson) Name: Dr. Robin Prakash UID: 14597 Recommended (Y/N): Yes
Mathur
PAC Member (Allied) Name: Dr. Gursharan Singh UID: 16967 Recommended (Y/N): Yes

PAC Member 3 Name: Dr. Avinash Kaur UID: 14557 Recommended (Y/N): Yes

Final Topic Approved by PAC: HUMAN STRESS DETECTION WITH PRECAUTIONS USING MACHINE LEARNING ALGORITHMS

Overall Remarks: Approved

PAC CHAIRPERSON Name: 17442::Dr. Arun Malik Approval Date: 28 Mar 2024

5/2/2024 9:14:14 AM

2
DECLARATION

We affirm that the project titled " HUMAN STRESS DETECTION USING MACHINE
LEARNING" is a representation of our efforts completed as part of the Capstone Project
to earn a B. Tech degree in "Computer Science & Engineering”, from Lovely
Professional University, Phagwara. This project was conducted under the guidance of
Dr. Sanjay Babu Jaiswal (Assistant Professor) from January, to May 2024. The content
included in this capstone project report reflects our work. Is entirely authentic.

Project Group Number: CSERGC0261

Yedoti Mahesh
Registration Number: 12005660

Pogarthi Sindhura

Registration Number: 12004533

Chamarthi Manoj Kumar


Registration Number: 12003450
Male Sowmya Reddy
Registration Number:12018581
Srishti Dwivedi
Registration Number:12005693
Chekonda Alex Nitin
Registration Number:12003121

3
Declaration by the supervisor

To whom so ever it may concern


This is to certify that declaration statement made by this group of students from Lovely
Professional University, Phagwara, Punjab, has worked on “HUMAN STRESS
DETECTION USING MACHINE LEARNING ” under my supervision from. It is further stated
that the work carried out by the student is a record of original work to the best of my knowledge for
the partial fulfilment of the requirements for the award of the B. Tech degree in Computer Science
and Engineering from Lovely Professional University, Phagwara.

Name of Supervisor:

Mr. Sanjay Babu Jaiswal

UID of Supervisor
31174

Signature of Supervisor

4
CERTIFICATE

I confirm that, to the best of my knowledge and belief the statement provided by this group of students
is accurate. They completed this Capstone Project under my supervision and guidance. Theirresearch,
study and hard work have led to the creation of this work. None of the content has been previously
presented for another degree at a university. The capstone project meets the criteria for submission.
Partially fulfills the requirements for a "Computer Science & Engineering" B. Tech degree at Lovely
Professional University, in Phagwara.

Mr Sanjay Babu Jaiswal

Assistant Professor

School of Computer Science and Engineering,


Lovely Professional University,
Phagwara, Punjab.

,
Phagwara, Punjab.

Date:

5
ACKNOWLEDGEMENT

To everyone who helped us to successfully complete this computer science project, we would like
to extend our sincere gratitude.

Above all, we owe a debt of gratitude to SANJAY BABU JAISWAL, our project supervisor, for her
constant direction and steadfast assistance during the project. Their knowledge and helpful criticism
have greatly shaped our concepts and methods and have helped to guarantee the caliber ofour work.

We also want to thank our classmates and colleagues for their invaluable advice and insights that
they have provided us with while conducting our research. Their advice has been invaluable in
helping us polish our work and deal with obstacles that have come up.

We further wish to recognize the significance of the resources offered by our organization, which
include access to state-of-the-art hardware and software in addition to a number of online databases
and libraries. These resources have proven invaluable in the development of our concept since they
have enabled us to carry out exhaustive study and experimentation.

We would like to conclude by thanking our friends and families for their unwavering encouragement
and support during this undertaking. We are sincerely appreciative of their love andsupport, and their
unfailing faith in our talents has been a wonderful source of inspiration and motivation for us.

We would like to thank everyone who has helped us with this project once more. We also hope that
our effort will help to further the fields of computer science and technology.

6
List of Content

SNO. TITLE PAGE NO.

1 Abstract 8

2 List of Figures 9

3 Introduction 10

4 Literature Overview 14

5 System Analysis 17

6 System Design 20

7 Implementation 27

8 Testing 30

9 Result Screens 34

10 Conclusion 36

11 Reference 37

12 Appendices 39

13 Plagiarism Report 40

7
ABSTRACT
Stress is a pervasive problem that significantly impacts individuals mental and physical well-
being. Detecting and understanding stress patterns during sleep, the level of stress and aid in the
development of targeted interventions for stress management. This project focuses on the
detection of human stress in and through sleep using various sensing modalities and machine
learning techniques. The project employs a multimodal approach, combining physiological
signals, sleep-related data, and contextual information to capture comprehensive stress patterns
during sleep. Physiological signals such as heart rate, electrodermal activity, and respiratory
patterns are collected using wearable sensors, while sleep-related data, including sleep stages
and sleep quality metrics, are obtained through polysomnography and actigraphy. This data
when given to the web application, performs the prediction through the ML model and gives the
predicted output. This project is made on a Decision Tree Classifier with best hyperparameters.
This prevents overfitting of the data and hence better predictions on unseen data which people
provide to the program.

8
List of figures

Figure No. Figure Page


3.4 System Architecture 20

3.5.1 System Design 23

3.6.1 Use case Diagram 24

3.6.2 Activity Diagram 25

3.6.3 Class Diagram 26

3.6.4 Sequence Diagram 26

6.1 Home Screen 34

6.2 Sleep Parameter Inputs 34

6.3 Stress Level Prediction 35

6.4 Prediction Summary 34

10 Plagiarism Report 40

9
CHAPTER-1. INTRODUCTION

1.2 HUMAN STRESS DETECTION DURING SLEEP: A MACHINE LEARNING APPROACH

Importance of Detecting Stress During Sleep with Machine Learning

Prolonged stress can have an impact on both mental wellbeing posing a significant concern for public health.
Sleep Disruptions; Stress responses may disrupt sleep patterns causing issues with falling awakenings and
reduced sleep quality.

The Importance of Early Identification.


Conventional stress assessment methods often rely on evaluations or self-reported surveys. These approaches
may be prone to inaccuracies due to factors such as bias or challenges in recalling experiences.
Early and accurate identification of stress is crucial for reasons.
• Timely Support; Detecting stress enables intervention through techniques like relaxation therapies, cognitive
behavioral therapy or medication as necessary. This proactive approach could potentially help prevent or
alleviate the health effects of stress.
• Enhanced Treatment Outcomes; Mental health professionals can use stress detection to customize treatment
plans leading to better outcomes for individuals dealing with stress related conditions.
• Optimization of Preventive Measures; By pinpointing individuals at risk of stress related health issues
healthcare providers can implement strategies such as lifestyle adjustments or stress management programs.

Benefits Beyond Personal Health.


The importance of identifying stress extends beyond wellbeing. Can also contribute to:
• Enhanced Productivity, in the Workplace Extended periods of stress can impact one’s drive, concentration
and efficiency in the workplace. Individuals who implement stress management techniques may find
themselves in a positive and fruitful work setting.
• Reduced Medical Expenses; Identifying and addressing stress related issues can lead to savings in healthcare
expenses.

10
Recognizing stress is essential to advancing both physical and mental health. Precise and impartial techniques,
such as those investigated in this study, have great promise for facilitating early intervention, enhancing
treatment results, and eventually.
Applicability

This research, on stress detection during sleep using machine learning (ML) has applications across different
areas.

1. In Clinical Settings Early Identification and Intervention for Stress Related Disorders; This technology
can help in identifying individuals at risk of developing conditions like depression and anxiety enabling
interventions such as behavioral therapy, relaxation techniques or medication. Personalized Stress
Management Plans; Healthcare professionals can create tailored stress reduction programs for patients based
on their stress and sleep data. These programs may include activities like exercises, yoga or mindfulness
meditation customized to suit the individuals needs and preferences.

Monitoring Treatment Efficacy: This approach allows for tracking the effectiveness of stress management
interventions over time.

2. Within Workplace Wellness Initiatives.

Identifying Stressed Employees; Employers can utilize this technology to identify employees experiencing
levels of stress, crucial in high pressure fields such as banking or healthcare. Promoting Work Life Balance;
Organizations can develop programs aimed at enhancing the work of people and reducing stress by analyzing
the stress patterns among their employees. Staff being programs stress management workshops and flexible
work arrangements are some solutions. Boosting employee productivity is crucial as long-term stress can
hinder job performance. By addressing and alleviating employee stress levels companies can improve
productivity. Decrease absenteeism rates.

The Relevance of Detecting Stress During Sleep with Machine Learning

Prolonged stress can greatly impact health by affecting both physical and mental well-being increasing the risk
of conditions, like depression, anxiety, heart disease and weakened immune system function. Traditional stress

11
assessment methods often rely on data or observations made after stress symptoms have already manifested.
This research initiative, utilizing machine learning (ML) and sleep data analysis to identify stress levels during
sleep holds importance for reasons

1. Detection

Unlike approaches this method allows for proactive intervention. Healthcare professionals can take action by
finding stress while sleep offering insights for every individual stress response. This enables individuals to
employ stress relief techniques such as therapy, relaxation methods or medications in severe cases.

2. Tailored Stress Management

Many current stress management techniques lack personalization. This study recognizes stress patterns.
Evaluates sleep data on an individual basis opening avenues, for personalized therapies. By considering
reactions tailored stress management strategies have the potential to lead to long term health outcomes.

3.Enhanced Physical Wellness.

Long term stress can disrupt processes leading to negative impacts, on overall health.

Advancements, in Wearable Technology and Healthcare;

This study utilizes wearable sensors to gather information on sleep patterns. This method presents a cost non
intrusive and convenient way to monitor stress levels. In comparison to sleep tracking methods like
polysomnography wearable sensors are generally more affordable and comfortable for users. Furthermore the
continuous collection of data in real world settings provides understanding of stress patterns compared to
assessments conducted in a laboratory.

Focus of Stress Detection

The aim of this research projects stress detection scope is to utilize machine learning (ML) and analyse sleep
data to detect stress during sleep. Here is an examination of its limitations and potentials;

12
Scope:

* Primary goal.

Identifying and measuring stress levels during the sleeping phase.

* Source of Data.

Wearable sensors would include EDA sensors, heart rate monitors, and maybe actigraphy for tracking
movements during sleep.

13
CHAPTER - 2 REVIEW OF LITERATURE

2.1 A new method for detecting stress using bio signals and machine learning techniques.
It was presented in a study by M. F. Rizwan et al. [1]. The study aims to present Electrocardiography as a bio
signal for stress detection. Stress, defined as an imbalance in well being is an issue in biomedical engineering
because of its probable effects both on the body and the mind. Identification of changes in bio signals like
ECG, EMG, Respiration and GSR caused by stress is achieved through this study to develop a stress detection
system. ECG is therefore preferred over other tests because of its availability and the ability to provide
Respiratory signal data. Supervised machine learning techniques include SVM, which are used to classify
stress based on features extracted from the ECG signals, such as RR interval, QT interval and EDR. Outcomes,
as given, show accuracy rates. Highlight how respiratory information can improve stress detection using
machine learning techniques. In a nutshell, this study provides insights into building stress detection systems
in use of bio signals and machine learning models.
2.2 Detecting Mental Stress Through Machine Learning and Mobile App Development.
A paper by C. Vuppalapati et al. discusses the problem of detecting and managing stress through mobile development
and machine learning. Stress, as defined as the physiological reaction to the need for change, spreads around the world
not only causing problems in health but also huge economic fallouts. Despite the large presence, detection and effective
management of stress are less effective, creating negative health impacts and massive economic fallouts. Addressing
this, the research proposes the use of an app based on machine learning technology, connected with EEG biosensors.
This new way of detecting users' moments of stress would lead to them receiving suggestions for preventive healthcare,
based on a variety of data types, from demographic information to physiological signals, to lifestyle habits, and
behavioral patterns. The intelligence in this approach would be combined with a machine learning method like Support
Vector Machine and K Nearest Neighbor and would place the system in a way to relieve the stress impact on the general
health of people in the future. By creating prototypes and running experiments to prove its functionality, the paper shows
how this proposed solution would change the way stress is dealt with within the challenges of today's society.

2.3 Stress Detection, through Smartwatches with Machine Learning; An Overview


In a study by R. Katarya and S. Maan, smartwatches are used for stress detection with the aid of machine learning
techniques. Stress has turned out to be an issue in lifestyles and has led to the need for efficient detection methods so

14
that its effects can be reduced. Smartwatches, which have sensors like HRV, GSR, and skin temperature monitoring and
tracking sleep patterns, would help collect the information. Machine learning methods like SVM and KNN are used for
analyses of the same data and in the process of determining the stress level of individuals. This research looks at the
combinations of signals and machine learning classifiers to ascertain the exact method of the accurate detection of stress.
The study tries to give some insights into the improvement in the approaches of stress detection when using smartwatch
data and machine learning.
2.4 Exploring the Impact of Feature Normalization and Feature Selection, on Multimodal Stress Detection
Using Logistic Regression
In a study titled "Examining the Effects of Normalizing Features and Selecting Features on Detecting Stress
Through Logistic Regression M. A. Fauzi, B. Yang and P. K. Yeng explore the realm of automated stress
identification through the utilization of smartwatches and machine learning techniques. They concentrated on
the realm of ML driven categorization particularly examining how feature normalization and feature selection
can improve classification accuracy. Through the creation of a stress detection framework based on Logistic
Regression the researchers investigate the impact of these techniques, on system performance.. Their study
reveals that implementing feature normalization greatly improves stress classification compared to systems
without it. Furthermore, they find that using a number of features results in performance while optimal
outcomes are achieved by increasing the number of features up to a certain threshold. The researchers point
out that using Min Max normalization, in conjunction with ANOVA based feature selection results, in
achieving levels of accuracy, precision, recall and F1 measure values. Notably peak performance is observed
when utilizing 90% of all features. This research emphasizes the significance of feature preprocessing
techniques in enhancing the efficacy of stress detection systems, within machine learning applications.[4]

2.5 "A cost effective approach, for stress detection using machine learning based on EDA."
In a study Hosseini and colleagues delve into the topic of detecting stress in today’s society recognizing its
harmful effects, on both mental and physical well being. They emphasize the significance of detection and
monitoring to lessen the impact of stress related conditions like depression, anxiety and heart diseases. By
utilizing advancements in technology, The scientists are studying Electrodermal Activity (EDA) as a signal
that shows stress levels. EDA also referred to as Galvanic Skin Response (GSR) detects variations, in skin
conductance triggered by stress induced perspiration. The study utilizes machine learning methods to analyze
EDA signals extracting 87 features and standardizing data for each individual to accommodate differences.

15
Through testing with the stress and emotion detection dataset (WESAD) the researchers pinpoint five key
features essential for detecting stress accurately. Notably their findings showcase the effectiveness of the One
Leave Out technique achieving a 97.03% accuracy in stress detection. By concentrating on EDA sensors and
leveraging machine learning techniques this research presents a cost accessible method for monitoring stress
levels holding significant implications, for personalized healthcare and well-being management. [5]

16
CHAPTER-3 SYSTEM ANALYSIS
Stress is bad for your health. The current methodology identifies stress through face-to-face interactions,
interviews, and any other scenario when two or more persons are assessing each other. The current
approach usually uses stress data from social networking sites or information about interpersonal
interactions in place of body-based sensor data. Some modern technologies have the capability of
detecting stress while they are awake.

3.1 PROPOSED SYSTEM

The proposed system aims to detect and analyze stress levels in individuals using machine learning
techniques applied to various data sources, such as physiological signals, sleep patterns, activity levels,
and self-reported data. The system utilizes machine learning algorithms to analyze the collected data and
identify patterns indicative of stress. The system can potentially detect signs of stress at an early stage,
enabling timely interventions and support. Early detection can help individuals proactively manage stress
and prevent its escalation into more severe issues.

3.2 FEASIBILITY STUDY

3.2.1 TECHNICAL FEASIBILITY

Data Availability: Assess whether the required sleep-related physiological data (snoring, respiration rate,
body temperature, limb movement rate, blood oxygen levels, eye movement, heart rate) is readily
available and can be collected accurately. Ensure data sources and sensors are accessible and reliable.

Data Compatibility: Check if the collected data can be efficiently processed and integrated into the
system. Verify that the data can be structured appropriately and

17
converted into a format suitable for analysis.

Model Selection: Evaluate the feasibility of using the Decision Tree algorithm for stress prediction.
Ensure that the algorithm can effectively handle the selected attributes and provide accurate predictions.

Hardware and Software Requirements: Examine the technical requirements, such as computing power,
memory, and software libraries, needed to implement and run the system. Assess if these resources are
readily available or can be obtained within budget constraints.

3.2.2 OPERATIONAL FEASIBILITY

In our project, operational feasibility is favorable. The system relies on readily available sensors and data
collection methods for physiological and sleep-related parameters, making it feasible to gather the
required data. Additionally, the Decision Tree algorithm is known for its efficiency and effectiveness,
ensuring that the system's computational requirements are manageable. The modular structure of our
project, divided into data collection, pre-processing, model training, and stress prediction, simplifies
system operation and maintenance. Moreover, the prediction of stress during sleep can be integrated into
existing wellness or healthcare applications, enhancing its practicality and usability.

3.2.3 ECONOMIC FEASIBILITY

Economic feasibility assesses the project's affordability and potential return on investment. Our project
exhibits strong economic feasibility. The cost of data collection sensors and equipment is generally
reasonable and becoming increasingly accessible. The primary expenses involve data collection, system
development, and training. However, these costs are offset by the potential benefits, including improved
stress management, mental health, and overall well-being for users. Moreover, the project can be
monetized through various avenues, such as offering the stress prediction service as a premium feature
in wellness apps or licensing the technology to healthcare providers. The potential for long-term financial
sustainability makes our project economically viable.

18
3.3 SCOPE OF PROJECT

Our project aims to create a stress-detection system that uses physiological and sleep-related data to predict
outcomes using the Decision Tree algorithm. Users will be able to rate their stress levels on a scale of
low/normal to high, right after the use of the technology that will be able to predict their levels of stress in
advance while they are sleeping. The project tries to give personalized, accurate insights on stress levels by
collecting and analyzing relevant variables, such as heart rate, blood oxygen, blood temperature, limb activity
rate, snoring range, and hours of sleep. Data collection, pre-processing, model training, and user- friendly
stress prediction are all within the scope, which may contribute to better management of stress and overall
well-being. This project's relevance may be applied in wellness programs and healthcare by giving relevant
information on stress to the user.

3.4 MODULES DISCRIPTION


1) INPUT MODEL: -
• Data Collection
• User Interaction
2) DATA PRE-PROCESSING MODULE: -
• Data Validation
• Data Transformation
3) MACHINE LEARNING MODULE: -
• Model Loading
• Stress Categorization
4) OUTPUT MODULE: -
• Display Results
• Data Summary
• Model Information
• Visualization
3.5 SYSTEM CONFIGURATION:
SOFTWARE REQUIREMENTS
➢ OS : Windows 11
➢ Programming Language : Python 3.10
➢ IDE : Jupyter Lab or Google Colab
HARDWARE REQUIREMENTS
➢ System : Intel or 86-64 processor
➢ Hard Disk : 10GB HDD (SSD recommended)
➢ Ram : 8GB DDR4 RAM

19
The level of stress of an individual is highly influenced by their sleeping patterns. Physiological traits that
usually change between the NREM and the REM stages of sleep include temperature, blood pressure, heart
rate, and breathing rate. The number of hours slept, snoring range, sleeping position, and the environment
can all determine the quality of one's sleeping patterns. For the purpose of this below analysis, these
variables are included in order to view the sleeping patterns. A system is available to forecast stress at five
levels: high, medium-high, medium, medium-low, and low stress.

SYSTEM DESIGN

3.4 SYSTEM ARCHITECTURE

Fig 3.4 System Architecture

3.4.1 MODULE DISCRIPTION

Python is a high-level, general-purpose language profoundly characterized by its dynamic, object-oriented


nature and the power of its data types, dynamic typing, and dynamic binding that all give it an edge in the
area of rapid application development. It could be used for some programming purposes or joining objects.
The structure of Python language is developed in this way so as to get on any programmer's foot. It
emphatically takes into consideration the readability feature that is known to lower the costs for the
programs that are being maintained. Python with modular and packaging features, is used to structure
programs into smaller units and to reuse the developed code.

20
PANDAS:

The Pandas package is widely used for data analysis in Python. It offers fast, user-friendly data structures and
functions for structured data manipulation while also being able to read/write different file formats as well.
It enables users to clean up messy datasets quickly or process large amounts of information efficiently –
things like grouping by categories or merging tables on shared columns are quite easy using this library alone!
Because of its speediness & flexibility it finds frequent usage within the realms of statistics/finance where
speed matters most.
NUMPY:

NumPy is a package used in the Python programming language which deals with arrays mainly. Its main
feature is an object of multidimensional array and functions to deal with those arrays. It should be installed
first before doing scientific computations using python Other than that, it has various applications for
example as an efficient multi-dimensional container for generic data. NumPy represents n-dimensional
arrays (with n being any positive integer) in memory.

STREAMLIT

Streamlit is built on open-source Python framework mainly designed to create machine learning web
apps faster and easier. Streamlit works well with scikit-learn, Keras or PyTorch among other libraries.
Streamlit does not use callbacks because it treats widgets as variables. Data caching speeds up and
simplifies computation pipelines. Watch our video tutorial on how to deploy streamlit applications using
heroku

STREAMLIT installation steps:


1. You must have python downloaded on your working laptop.
2. Use the below command in command prompt:
Pip install streamlit

Matplotlib:

Matplotlib is a Python package that can create interactive, animated, and static visualizations. It provides
tools for creating various types of plots such as line plots, scatter plots, histograms etc., with a MATLAB-
like interface. There are many ways to customize the appearance of plots in Matplotlib – colors can be
changed easily; markers and labels may be added or removed at will; titles can be modified so as to better
suit one’s needs etcetera. It integrates well with NumPy; it supports both stateful and object-oriented plotting
interfaces. Though there are other options available for data visualization in Python but considering its wide
adoption rate and active community support Matplotlib should be your first choice

21
WHAT IS MACHINE LEARNING:

To start with, we will explain the concept of machine learning and the differences between learning methods,
afterward, we will study: Machine-learning is a branch or a type of artificial intelligence. The justification
might be confusing at the beginning. Of course, as the research became more advanced, it got coupled up
with machine learning. People in data science customize machine learning to develop models by data.
Machine learning is based of data and correlation and uses mathematical models to gain insight into data.
"Learning" refers to the models' ability to adapt their parameters as they are confronted with the data, so that
they would be able to fit them. They support a system which allows the competitors learning by the
information from the datum. These models first fit to earlier data on the sample before they draw on previous
data to make predictions and come up with interpretations. However, will be free from such philosophical
inclinations and I will leave it for a reader to decide how mathematical model driven learning resembles what
brain learns. It is important that in order to use the machine learning tools well you must understand problem
setup well. Wider categories will be specified for the purposes of getting into details

22
3.5 SYSTEM DESIGN

Collection of
Psychological

Dataset

Data pre-processing

Machine
Learning

knn Decision Random Gradient XGB


Tree Forest Boosting

Best One (KNN


Classifier)

Hyperparameter
tuning and
Model

Final Result
(Prediction)
Fig 3.5.1 System Design

23
3.6 UML DIAGRAM:

3.6.1 USE CASE DIAGRAM

We used a UML use case diagram for our Project Development. It is a kind of behavior chart made by
and through Use-case analysis. It provides a visual representation of the ways in which an object could
express its thoughts about itself to others who have experience with it (represented as actors) byshowing
what they can do (represented as use cases) and any conditions that may exist between those use cases.

Fig 3.6.1 Use Case Diagram

24
3.6.2 ACTIVITY DIAGRAM:

An activity diagram is a diagram showing the flow of control from the starting point to the ending point,
with all the decision paths that can be taken during an execution of the system. Activity diagrams can be
used for showing both sequential and concurrent processing steps.

Fig 3.6.2 Activity Diagram

3.6.3 CLASS DIAGRAM:

A class diagram is one of the kinds of UML diagrams used in software engineering for describing the
structure and behavior of systems or programs. It displays the classes in a system, their attributes,
methods, and how they are related via associations or inheritance chains. It gives a view of the system at
a higher level of abstraction than other diagrams like object or component diagrams.

25
Fig 3.6.3 Class Diagram

3.6.4 SEQUENCE DIAGRAM:

A sequence diagram is an interaction between objects, in terms of messages ordered with respect to time,
i.e., they depict which messages are sent in which order within one use case realization. These are called
event diagrams or event scenarios. Sequence diagrams tell us how different objects work together to
achieve specific functionality within a context. These types of diagrams are mostly used by business
analysts and software developers during the requirements gathering process while analyzing existing/new

systems.

Fig 3.6.4 Sequence Diagram

26
CHAPTER 4: IMPLEMENTATION

MODULES:

Data loading: our intent in this section is to provide the information. Create your Own Post!
Generation Z is a generation that could have also been considered social by reputation, as it has
always been an aspect of everyday life for them.

Data Preprocessing: this section will cover the data on the one hand.

Splitting data into train & test: those data to be split to initial training and testing.

User signup and login: This module is the registration and log in section that will lead to sign up
and log in the application.
User input: There will be a special feature for the module that will provide the users make the
predictions.
Prediction: to demonstrate this, an index of the final prediction is shown.

ALGORITHMS:

27
Modified SVM (SUPPORT VECTOR MACHINE)

It is an algorithm that can be used for regression and classification tasks learned in the course
material. It can do this because it createsa hyperplane that best separates classes in feature space.
A modified version of SVM is used as a“sleep detection system” to divide driver states into
categories by sleepiness level, using factors derived from physiological signals or video inputs.
This means that new elements may be added to the current approach while still ensuring
maximum detection accuracy with regards to certain features. The sleep detection system uses
behavior features- derived from biological signs or video frames – so a the modified SVM
should be applied for this purpose.

KNN (k-Nearest Neighbors):

Itis a non-parametric method used for classification and regression which is quite simple yet effective
when it comes to analysis in supervised learning. As the algorithm progresses,it groups clusters together
based on votes cast by friends within their feature space. In sleep monitoring systems KNN
algorithmically clusters drivers such that those whose feature vectors are most closely similar to other
drivers who fell asleep at wheel or had tiredness behind them form one cluster

28
Decision Tree:

It is a simpler expression for supervised learning used in same as KNN .This creates the decision tree by
decomposing overlapping feature subspaces recursively while attempting to find the rule that best splits
individual classes. The system of analysis of sleep data creates Decision Tree, which provides for the
creation of decision rules in the form of trees based on behavior attributes or physiological signs from the
driver. It allows you to accurately determine whether a person is tired or not through a number of yes, no or
maybe turns, which are easier to understand and more efficient in work. The system can assess whether
someone is drowsiness with a series of yes/no questions; it’s smarter and better at classifying'.

Naïve Bayes

naive Bayes’ theory works as a probability estimator targeted at classifications of objects especially. This
approach uses Bayes’ Theorem where naive assumption is that nothing relates with anything else since
everything is independent. Sleepiness system employs Naive Bayes for assessment on how likely a driver
may be getting sleepy which also takes into account discovered values features. However Naive Bayes is
both well worked out but also fast reliable therefore great for tasks like such det.

29
CHAPTER-5 TESTING

5.1 INTRODUCTION
To test the debugging programme and ensure that it works as intended is part of computer programming. The
person using the system needs to identify errors through their results when testing. Rather than the quantity,
it is the quality of test data that matters most. Prior to this stage however, accuracy and efficiency are what
testing seeks to validate.

Objectives for Testing:

Testing has one major goal which is to detect defects in a logical manner i.e., systematically. In other words,
we can say that testing checks whether a program is free from error by executing it.

1. Any error exposing test fails

2. Each statement or object function should be tested separately

3. There are some mistakes which may not be caught during this process

4. Generally, software meets dependability requirements

5.2 TESTING LEVELS


Code Inspection:
In this phase, an algorithm is checked for logical fallacies. For instance, the controlling of sample data
updating and sample files as well as folders were tested against the logic.
Specification Testing:

The tests are carried out based on specifications that indicate what a program should do or not do under
certain conditions/settings. Test cases cover every possible combination of situations and conditions for all
modules.

30
Unit testing:

We test each module. Next, during unit testing we integrate it into the entire system. The focus of
verification is at the software design unit within the module through unit testing also known as module
testing. During programming phase every system module undergoes independent testing. Each module
should perform according to its output during the testing phase. Besides that validation tests are for fields
such as checking if user input is consistent and genuine data is entered. It’s quite easy to identify errors in the
system.

When it comes to testing each module, you have two options;

5.2.1 BLACK BOX TESTING

It refers to a method of testing where the functionality of the application under test is considered without
regard to its internal programme structure, execute specifics or internal paths of execution.

It is important that these guidelines and requirements for this type of test be followed when conducting such
tests against any given program or system being evaluated on whether it’s an operating system like
Windows; a website such as Google; a database management software like Oracle among others

31
5.2.1 WHITE BOX TESTING

It is the process of evaluating a software system’s programming and structure. This is done to ensure
security, enhance design and usability as well as optimizing input-output flow within the program among
other things. It can also be called open-box, clear-box or structural testing.

This method belongs to the family of “box testing” techniques used in software testing methodologies; where
black box focuses on end user perspective while white box looks at app functioning internally. The term
‘white’ comes from its transparency i.e., being able to see what is inside the “box” – representing visibility
into how the software works.

In this case, “clear box” or ‘white box’ denotes ability to see past surface level features (or "box") and
understand inner workings of a given software. Similarly, with ' box testing ' this means that one cannot
know anything about the internal operations of an application; hence such assessment can only be based on
interactions between it and users.

WHAT DO YOU VERIFY IN WHITE BOX TESTING?

When checking the software code at white box testing phase for

5.2.2 Security vulnerabilities

5.2.3 Poorly structured or malfunctioning pathways in the coding procedures

5.2.4 The flow of inputs through the code achieving the intended outcome.

5. 2.5 How conditional loops function

5 .2.6 Conducting separate tests on each statement object and function.

32
Integration Testing:

As they develop software developers should conduct white box testing to ensure codes security checks are
carried out on various points where errors may occur understand how input flows through code until desired
output is produced evaluate loop functionality and perform individual tests for each statement object
function separately

System testing:

The intention of system testing is to validate that software meets requirements and works as expected in its
intended environment. It involves performance, security and usability among others. Different kinds of tests
like functional, load or security testing are conducted to detect faults. Test cases are executed in an
environment similar to the production setup where all identified issues are logged for fixing. The software
undergoes all these tests until exit criteria are satisfied before system testing phase can be said to be over
hence readying it for deployment.

33
CHAPTER-6 RESULTS
6.1 Home Screen

Fig 6.1 Home Screen

6.2 SLEEP PARAMETER INPUTS

Fig 6.2 Sleep Parameter Inputs

34
6.3 STRESS LEVEL PREDICTION

Fig 6.3 Stress level Prediction

6.4 PREDICTION SUMMARY

Fig 6.4 Prediction Summary

35
FINAL CHAPTER CONCLUSION

7.1 Conclusion

The implementation of the KNN algorithm has demonstrated its effectiveness in detecting
stress during sleep. By analyzing various physiological and behavioral parameters such as
heart rate, respiratory rate, body movement, and sleep patterns, we were able to classify
instances of stress with a reasonable degree of accuracy.

7.2 FUTURE ENHANCEMENTS

 Combining data from multiple sources such as wearable sensors, audio
recordings, and self-reported information can provide a more
comprehensive view of an
individual's stress levels during sleep. Integration of additional modalities could lead
to more accurate stress detection.

 Collaborating with healthcare professionals to validate the effectiveness


of stress detection algorithms and integrating them into clinical practice
can be a crucial step in translating research into real-world applications.

36
8. REFERENCES

[1] M. F. Rizwan, R. Farhad, F. Mashuk, F. Islam and M. H. Imam, "Design of a Bio signal Based Stress
Detection System Using Machine Learning Techniques," 2019 International Conference on Robotics,
Electrical and Signal Processing Techniques (ICREST), Dhaka, Bangladesh, 2019, pp. 364-368, doi:
10.1109/ICREST.2019.8644259.

[2] C. Vuppalapati, M. S. khan, N. Raghu, P. Veluru and S. Khursheed, "A System To Detect Mental Stress
Using Machine Learning And Mobile Development," 2018 International Conference on Machine Learning
and Cybernetics (ICMLC), Chengdu, China, 2018, pp. 161-166, doi: 10.1109/ICMLC.2018.8527004.

[3] R. Katarya and S. Maan, "Stress Detection using Smartwatches with Machine Learning: A Survey," 2020
International Conference on Electronics and Sustainable Communication Systems (ICESC), Coimbatore,
India, 2020, pp. 306-310, doi: 10.1109/ICESC48915.2020.9155568.

[4] M. A. Fauzi, B. Yang and P. K. Yeng, "Examining the Effect of Feature Normalization and Feature
Selection for Logistic Regression Based Multimodal Stress Detection," 2022 International Conference on
Theoretical and Applied Computer Science and Engineering (ICTASCE), Ankara, Turkey, 2022, pp. 90-94,
doi: 10.1109/ICTACSE50438.2022.10009720.

[5] E. Hosseini et al., "A Low Cost EDA-based Stress Detection Using Machine Learning," 2022 IEEE
International Conference on Bioinformatics and Biomedicine (BIBM), Las Vegas, NV, USA, 2022, pp. 2619-
2623, doi: 10.1109/BIBM55620.2022.9995093.

[6] P. S. Ramteke and S. Khandelwal, "Comparing Conventional Machine Learning and Large-Language
Models for Human Stress Detection Using Social Media Posts," 2023 2nd International Conference on
Futuristic Technologies (INCOFT), Belagavi, Karnataka, India, 2023, pp. 1-8, doi:
10.1109/INCOFT60753.2023.10425133.

37
[7] M. S. Hafiy Hilmy et al., "Stress Classification based on Speech Analysis of MFCC Feature via Machine
Learning," 2021 8th International Conference on Computer and Communication Engineering (ICCCE), Kuala
Lumpur, Malaysia, 2021, pp. 339-343, doi: 10.1109/ICCCE50029.2021.9467176.

[8] A. U. G. Sankararao, P. Rajalakshmi, S. Kaliamoorthy and S. Choudhary, "Water Stress Detection in Pearl
Millet Canopy with Selected Wavebands using UAV Based Hyperspectral Imaging and Machine Learning,"
2022 IEEE Sensors Applications Symposium (SAS), Sundsvall, Sweden, 2022, pp. 1-6, doi:
10.1109/SAS54819.2022.9881337.

[9] H. Altaf and P. K. Yadav, "Human Stress Detection in and through Sleep – A Deep Learning Approach,"
2023 International Conference on Next Generation Electronics (NEleX), Vellore, India, 2023, pp. 1-6, doi:
10.1109/NEleX59773.2023.10421056.

[10] F. Akhtar, M. B. Bin Heyat, J. P. Li, P. K. Patel, Rishipal and B. Guragai, "Role of Machine Learning in
Human Stress: A Review," 2020 17th International Computer Conference on Wavelet Active Media
Technology and Information Processing (ICCWAMTIP), Chengdu, China, 2020, pp. 170-174, doi:
10.1109/ICCWAMTIP51612.2020.9317396.

38
9. APPENDICES

A. Software Used

• Coding Language: Python

• IDE: Jupyter Lab or Google Colab

• Libraries: NumPy, Pandas, sklearn, Seaborn

• Operating System: Windows 10/11

B. Methodologies Used

• KNN Visualization

• Cross Validation

• Web application Development

C. Testing Methods

• Unit Testing

• Integration

• System Testing

• Acceptance Testing

39
ACCEPTANCE LETTER

40
PLAGIARISM REPORT

41
42

You might also like