0% found this document useful (0 votes)
45 views5 pages

Human Stress Detection Based On Sleeping Habits Through Machine Learning Algorithms

Uploaded by

Vidya
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)
45 views5 pages

Human Stress Detection Based On Sleeping Habits Through Machine Learning Algorithms

Uploaded by

Vidya
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/ 5

International Journal of Scientific Research in Engineering and Management (IJSREM)

Volume: 08 Issue: 04 | April - 2024 SJIF Rating: 8.448 ISSN: 2582-3930

HUMAN STRESS DETECTION BASED ON SLEEPING HABITS THROUGH


MACHINE LEARNING ALGORITHMS

Nidubrolu Lakshmi Sandeep1, Munnangi Likhitha2,


Koppula Venkateswarlu3, Manchikanti Vineela4, Akurathi Balaji5
1,2,3,4 Student, Department of Computer Science and Engineering, Tirumala Engineering College
5 Professor, Department of Computer Science and Engineering, Tirumala Engineering College

---------------------------------------------------------------------***---------------------------------------------------------------------
Abstract - Stress is a mental or emotional state data, learn from it, and make informed predictions. In the realm
brought on by demanding or unavoidable circumstances, also of healthcare and well-being, machine learning's ability to parse
referred to as stressors. In order to prevent any unfavorable through large datasets and find patterns can be particularly life-
occurrences in life, it is crucial to understand human stress enhancing. This document will explore how machine learning,
levels. Sleep disturbances are related to a number of physical, through various learning models such as Supervised,
mental, and social problems. Unsupervised, and Ensemble Learning, can be applied to predict
This study's main objective is to investigate how human stress levels during sleep using psychological and physiological
stress might be detected using machine learning algorithms data.
based on sleep-related behaviors. Detecting and understanding
stress patterns during sleep can provide valuable insights into 2. LITERATURE REVIEW
individuals' overall stress levels and aid in the development of
targeted interventions for stress management. This project L. Rachakonda, A. K. Bapatla, S. P. Mohanty, and E.
focuses on the detection of human stress in and through sleep Kougianos, “SaYoPillow: Blockchain-Integrated Privacy-
using various sensing modalities and machine learning Assured IoMT Framework for Stress Management
techniques. The project employs a multimodal approach, Considering Sleeping Habits”, IEEE Transactions on
combining physiological signals, sleep-related data, and Consumer Electronics (TCE), Vol. 67, No. 1, Feb 2021, pp.
contextual information to capture comprehensive stress patterns 20-29.
during sleep. Considering today’s lifestyle, people just sleep forgetting the
Physiological signals such as heart rate, electro dermal benefits sleep provides to the human body. Smart-Yoga
activity, and respiratory patterns are collected using wearable Pillow (SaYoPillow) is proposed to help in understanding the
sensors, while sleep-related data, including sleep stages and relationship between stress and sleep and to fully materialize
sleep quality metrics, are obtained through polysomnography the idea of “Smart-Sleeping” by proposing an edge device.
and actigraphy. This data when given to the web application An edge processor with a model analyzing the physiological
performs the prediction through the ML model and gives the changes that occur during sleep along with the sleeping
predicted output. This project is made on a Decision Tree habits is proposed. Based on these changes during sleep,
Classifier with best hyper parameters. stress prediction for the following day is proposed. A user
interface is provided allowing the user to control the data
accessibility and visibility. SaYoPillow is novel, with
security features as well as consideration of sleeping habits
Key Words: Stress, Sleep disturbances, Human stress,
for stress reduction, with an accuracy of up to 96%.
Physiological signals, Polysomnography, Actigraphy

L. Rachakonda, S. P. Mohanty, E. Kougianos, K.


1.INTRODUCTION Karunakaran, and M. Ganapathiraju, “Smart-Pillow: An
IoT based Device for Stress Detection Considering Sleeping
“Machine Learning” incorporates various classifiers of Habits”, in Proceedings of the 4th IEEE International
Supervised, Unsupervisedand Ensemble Learning which are used Symposium on Smart Electronic Systems (iSES), 2018, pp.
to predict and find the accuracy of the given dataset. Our project 161—166.
can help people predict their stress level in sleep provided the
input data. Psychological data is required as input data to The quality of sleep during the night reflects on productivity
predict the stress level (on a scale of 5) of a person in sleep. during the day.
Psychological data usually include heart rate, blood glucose,
blood pressure, respiration rate, body temperature, blood To make the most out of a day, it is important to
volume, eye tracking, sound pressure, electrocardiogram, blood understanding the factors such as stress which impair sleep.
oxygen saturation, and skin conductance. This data can be Advances in technologies may aid a person to self-analyze
collected by wearable devices of different types. This data when such situations. For this, we propose a system which helps in
given to the web application, performs the prediction through stressfulness of a person based on sleeping habits.
the ML model and gives the predicted output. Physiological parameters such as temperature, blood
Machine learning (ML) is an essential technology in pressure, respiration rate, and heart rate tend to vary during
moderndata analytics, offering tools that can interpret complex the NREM (Non-Rapid Eye Movement) and REM (Rapid

© 2024, IJSREM | www.ijsrem.com DOI: 10.55041/IJSREM31628 | Page 1


International Journal of Scientific Research in Engineering and Management (IJSREM)
Volume: 08 Issue: 04 | April - 2024 SJIF Rating: 8.448 ISSN: 2582-3930

Eye Movement) stages of sleep. Non-physiological Python source code is now available under the GNU General
parameters such as the numberof sleeping hours, the range of Public License (GPL). Python is now maintained by a core
snoring, the sleeping position, and environmental conditions development team at the institute, although Guido van Rossum
can also affect the quality of sleep. These factors are still holds a vital role in directing its progress.
considered here in order to analyze sleeping habits. A
system is defined which can predict stress levels up to four Pandas
states: Low, High, Medium, very high stress.
3. METHODILOGY Pandas is an open-source library that is made mainly for
working with relational or labeled data both easily and
3.1 EXISTING SYSTEM intuitively. It provides various data structures and
operations for manipulating numerical data and time series.
Psychological stress is injurious to health. In existing system, This library is built on top of the NumPy library. It is fast and
stress is identified in face-to-face interview, communication or it has high performance & productivity for users. Pandas were
any other activities, where two or more people are analyzed by initially developed by Wes McKinney in 2008 while he was
another. Most of the existing system works either on person working at AQR Capital Management. He convinced the
interaction or on social networking stress data and not on body- AQR to allow him to open source the Pandas.
based sensor data. Some existing systems detect stress but not in Another AQR employee, Chang She, joined as the second
sleep. major contributor to the library in 2012. Over time many
versions of pandas have been released. The latest version of
the pandas is 1.4.1.
3.2 PROPOSED SYSTEM
NumPy
The proposed system aims to detect and analyze stress levels in
NumPy is a general-purpose array-processing package. It
individuals using machine learning techniques applied to
provides a highperformance multidimensional array object,
various data sources, such as physiological signals, sleep
and tools for working with thesearrays. It is the fundamental
patterns, activity levels, and self-reported data. The system
package for scientific computing with Python.
utilizes machine learning algorithms to analyze the collected
data and identify patterns indicative of stress. The system can
Besides its obvious scientific uses, NumPy can also be used
potentially detect signs of stress at an early stage, enabling
as an efficient multi- dimensional container of generic data.
timely interventions and support. Early detection can help
Array in NumPy is a table of elements (usually numbers), all
individuals proactively manage stress and prevent its escalation
of the same type, indexed by a tuple of positive integers. In
into more severe issues.
NumPy, number of dimensions of the array is called rank of
the array.
4.SYSTEM DESIGN
Streamlit

Streamlit is an open-source python framework for building


web apps for Machine Learning and Data Science in a short
time. It is compatible with major Python libraries such as
scikit-learn, Keras, PyTorch, SymPy(latex), NumPy, pandas,
Matplotlib etc. With Streamlit, no callbacks are needed since
widgets are treated as variables. Data caching simplifies and
speeds up computation pipelines. Streamlit watches for
changes on updates of the linked Git repository and the
application willbe deployed automatically in the shared link.

How to Install Streamlit

1. Make sure you have python installed in your system

System Architecture 2. Use the following command to install streamlit,

pip install streamlit


Python was developed by Guido van Rossum in the late
eighties and early nineties at the National Research Institute for
Mathematics and Computer Science in the Netherlands. Streamlit is a very visually appealing framework that is great
Python is derived from many other languages, including ABC, if you have an already existing Python code base which you
Modula-3, C, C++, Algol-68, Smalltalk, and Unix shell want to turn into an interactive dashboard as quickly and
and other scripting languages. Python is copyrighted. Like Perl, painlessly as possible. Streamlit prides itself on its ease of
© 2024, IJSREM | www.ijsrem.com DOI: 10.55041/IJSREM31628 | Page 2
International Journal of Scientific Research in Engineering and Management (IJSREM)
Volume: 08 Issue: 04 | April - 2024 SJIF Rating: 8.448 ISSN: 2582-3930

use, and rightfully so. an appropriate value for "k" based on experimentation.
• Internally, the KNN algorithm calculates the
distance (e.g., Euclidean distance) between the input
Matplotlib data point and all other data points in the training set.
• It then selects the "k" data points (nearest neighbors)
Matplotlib is an amazing visualization library in Python for 2D with the smallest distances.
plots of arrays. Matplotlib is a multi-platform data visualization • The algorithm counts the occurrences of each stress
library built on NumPy arrays and designed to work with the level category among these "k"neighbors and assigns the
broader SciPy stack. It was introduced by John Hunter in category with the highest count as the predicted stress
theyear 2002. level.
• KNN is a lazy learner, which means it does not build an
One of the greatest benefits of visualization is that it allows us explicit model during training. Instead, it memorizes the
visual access tohuge amounts of data in easily digestible training data and makes predictions based on it.
visuals. Matplotlib consists of several plots like line, bar, scatter,
histogram etc. Windows, Linux and macOS distributions have 5. Training the KNN Model
matplotlib and most of its dependencies as wheel packages.
• Train the KNN model using the training dataset. The
OS model will learn to classify thestress levels based on the
provided features.
Python OS module provides the facility to establish the
interaction between the user and the operating system. It offers
many useful OS functions that are used to perform OS-based 6. Making Predictions
tasks and get related information about operating system.

The OS comes under Python's standard utility modules. This • Use the trained KNN model to make stress level
module offers a portable way of using operating system predictions for the data points in thetesting set.
dependent functionality. • The model will assign a stress level category (e.g.,
Low/Normal, Medium Low,Medium, Medium High,
The Python OS module lets us work with the files and High) to each data point.
directories. To work with the OS module, we need to import the
OS module. IMPORT OS 7. Evaluation
5.IMPLEMENTATION • Evaluate the performance of the KNN model using
metrics such as accuracy,precision, recall, and F1-score.
1. Data Collection and Preprocessing
8. User Interface
• Collect a dataset containing various sleep-related
features, such as Snoring Rate, Respiration Rate, Body • Develop a user-friendly interface where users can input
Temperature, Limb Movement, Blood Oxygen, Eye their sleep-related data, such as Snoring Rate,
Movement, Sleeping Hours, and Heart Rate. Respiration Rate, etc
• The dataset should include labeled stress levels for • When a user submits the data, the KNN model will
each set of features (e.g., Low/Normal, Medium Low, predict the stress level, and the result will be displayed
Medium, Medium High, High). to the user.
• Preprocess the dataset by handling missing values and
outliers, if any. 9. Deployment

2. Feature Extraction • Deploy your Human Stress Detection System to a web


server or a cloud platform so that users can access it
• Extract the relevant features from the dataset, which
online.
will serve as input attributes forthe KNN algorithm.

3. Data Splitting
• Split the dataset into a training set and a testing set.
Typically, you can use a 70-30 or 80-20 split for this
purpose.
4. Building the KNN Model
• Implement the KNN algorithm, which is a
supervised machine learning algorithm used for
classification tasks.
• In KNN, the "k" represents the number of nearest
neighbors to consider for making predictions. Choose

© 2024, IJSREM | www.ijsrem.com DOI: 10.55041/IJSREM31628 | Page 3


International Journal of Scientific Research in Engineering and Management (IJSREM)
Volume: 08 Issue: 04 | April - 2024 SJIF Rating: 8.448 ISSN: 2582-3930

6.TESTING
7.RESULTS
6.1 Introduction

Testing is the debugging program is one of the most critical


aspects of the computerprogramming triggers, without
programming that works, the system would never produce an
output of which it was designed. Testing is best performed
when user development is askedto assist in identifying all errors
and bugs. The sample data are used for testing. It is not quantity
but quality of the data used the matters of testing. Testing is
aimed at ensuring that the system was accurately an efficiently
before live operation commands.

Testing objectives:

The main objective of testing is to uncover a host of errors, It shows the problem of the stress level detector hoe it works
systematically and with minimum effort and time. Stating and what is the problem statement.
formally, we can say, testing is a process of executing a program
with intent of finding an error.

1. A successful test is one that uncovers an as yet


undiscovered error.
2. A good test case is one that has probability of finding
an error, if it exists.
3. The test is inadequate to detect possibly present errors.
4. The software more or less confirms to the quality and
reliable standards.

6.2 Levels of Testing It shows the home page of the dataset of the stress level to
Code testing predict.

This examines the logic of the program. For example,


the logic for updating various sample data and with the sample
files and directories were tested and verified.

Specification Testing

Executing this specification starting what the program


should do and how it should performed under various
conditions. Test cases for various situation and combination of
conditions in all the modules are tested.
It shows the prediction page to enter the details of
Unit testing psychological data to predict the stress.

In the unit testing we test each module individually and


integrate with the overall system. Unit testing focuses
verification efforts on the smallest unit of software design in the
module. This is also known as module testing.

Each Module can be tested using the following two Strategies:

1. Black Box Testing


2. White Box Testing

It visualize the predicted data and the actual data.

© 2024, IJSREM | www.ijsrem.com DOI: 10.55041/IJSREM31628 | Page 4


International Journal of Scientific Research in Engineering and Management (IJSREM)
Volume: 08 Issue: 04 | April - 2024 SJIF Rating: 8.448 ISSN: 2582-3930

8.CONCLUSION
1. The implementation of the KNN algorithm has demonstrated
its effectiveness in detecting stress during sleep. By analyzing • A. Khademi, Y. El-Manzalawy, L. Master, O. M.
various physiological and behavioral parameters such as heart Buxton and V. G. Honavar, "Personalized sleep
rate, respiratory rate, body movement, and sleep patterns, we parameters estimation from actigraphy: A machine
were able to classify instances of stress with a reasonable learning approach", Nat. Sci. Sleep, vol. 11, pp. 387-
degree of accuracy. 399, 2019.

2. The K-Nearest Neighbors (KNN) algorithm is a • A. R. Subhani, W. Mumtaz, M. N. B. M. Saad, N.


straightforward, yet powerful machine learning technique used Kamel and A. S. Malik, "Machine learning framework
for both classification and regression tasks, but in this context, for the detection of mental stress at multiple
it is specifically applied to classify stress levels during sleep. levels", IEEE Access, vol. 5, no. c, pp. 13545-13556,
This approach involves analyzing various physiological and 2017.
behavioral parameters to determine stress states in individuals
during sleep. • R. K. Nath, H. Thapliyal, A. Caban-Holt and S. P.
Mohanty, "Machine Learning Based Solutions for Real-
Time Stress Monitoring", IEEE Consum. Electron.
Mag., vol. 9, no. 5, pp. 34-41, 2020.
9. REFERENCES

• L. Rachakonda, A. K. Bapatla, S. P. Mohanty, and E.


Kougianos, “SaYoPillow: Blockchain-Integrated
Privacy-Assured IoMT Framework for Stress
Management Considering Sleeping Habits”, IEEE
Transactions on Consumer Electronics (TCE), Vol. 67,
No. 1, Feb 2021, pp. 20-29.

• L. Rachakonda, S. P. Mohanty, E. Kougianos, K.


Karunakaran, and M. Ganapathiraju,“Smart-Pillow: An
IoT based Device for Stress Detection Considering
Sleeping Habits”, in Proceedings of the 4th IEEE
International Symposium on Smart Electronic Systems
(iSES), 2018, pp. 161--166.

• Buddi, Padmaja & Prasad, V.V. & Sunitha, K.V.N..


(2018). Machine Learning Approach for Stress
Detection using Wireless Physical Activity Tracker.
International Journal of Machine Learning and
Computing. 8. 33-38. 10.18178/ijmlc.2018.8.1.659.

• N. Schneiderman, G. Ironson and S. D. Siegel, "Stress


and health: Psychological behavioral and biological
determinants", Annu. Rev. Clin. Psychol., vol. 1, pp.
607-628, 2005.

• A. N. Vgontzas, S. Pejovic and M. Karataraki, "Sleep


Sleep Disorders and Stress", Encycl. Stress, pp. 506-
514, 2007.

• G. Fink, "Stress : Concepts Cognition Emotion and


Behavior : Handbook of Stress Stress : Concepts
Definition and History George Fink Florey Institute of
Neuroscience and Mental Health", no. October, 2017,
[online] Available:
https://www.researchgate.net/profile/George-
Fink/publication/317026245_Stress_Concepts_Cogniti
on_Emotion_and_Behavior_Handbook_of_Stress/links
/59d17f1b0f7e9b4fd7fa28b3/Stress-Concepts-
Cognition-Emotion-and-Behavior-Handbook-of-
Stress.pdf.

© 2024, IJSREM | www.ijsrem.com DOI: 10.55041/IJSREM31628 | Page 5

You might also like