Major New

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

DISTRESS PREDICTION AND MESSAGE

ALERTING SYSTEM

A MAJOR PROJECT REPORT

Submitted by

KAMARAJU MEGHANA (Regd.No.19891A05D9)


MEKALA AMANI (Regd.No.19891A05F3)
BUSI ARYAN REDDY (Regd.No.19891A05H5)

Under the guidance of


Mr.N.Srianjaneya
Associate Professor

In partial fulfillment for the award of the degree of

BACHELOR OF TECHNOLOGY
in
COMPUTER SCIENCE AND ENGINEERING

JUNE 2023
DEPARTMENT OF COMPUTER SCIENCE &ENGINEERING

VISION

To emerge as a premier center for education and research in computer


science and engineering in transforming students into innovative professionals of
contemporary and future technologies to cater to the global needs of human recourses
for IT and ITES companies.

MISSION

 To produce excellent computer science professionals by imparting quality training,


hands-on-experience and value based education.
 To strengthen links with industry through collaborative partnerships in research &
product development and student internships.
 To promote research based projects and activities among the students in the
emerging areas of technology.
 To explore opportunities for skill development in the application of computer
Science among rural and under privileged population.

i
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CERTIFICATE

This is to certify that the thesis work titled ―Distress Prediction and Message
Alerting System” submitted by Ms Kamaraju Meghana (Regd.No.19891A05D9), Ms. Mekala
Amani (Regd.No.19891A05F3), Mr. Busi Aryan Reddy (Regd.No.19891A05H5), in partial
fulfillment of the requirements for the award of the degree of Bachelor of Technology in
Computer Science and Engineering to the Vignan Institute of Technology And
Science, Deshmukhi is a record of bonafide work carried out by us under my guidance and
supervision.

The results embodied in this project report have not been submitted in any university for the
award of any degree and the results are achieved satisfactorily.

Mr.N.Srianjaneya Dr. G. Raja Vikram


Associate Professor Professor & Head of the Department, CSE
GUIDE

External Examiner

ii
DECLARATION

We hereby declare that project entitled ―Distress Prediction and Message Alerting System‖
is bonafide work duly completed by us. It does not contain any part of the project or thesis
submitted by any other candidate to this or any other institute of the university.

All such materials that have been obtained from other sources have been duly acknowledged.

KAMARAJU MEGHANA
(Regd.No.19891A05D9)

MEKALA AMANI
(Regd.No.19891A05F3)

BUSI ARYAN REDDY

(Regd.No.19891A05H5)

iv
ACKNOWLEDGEMENT
Every project big or small is successful largely due to the effort of a number of
wonderful people who have always given their valuable advice or lent a helping hand. We
sincerely appreciate the inspiration; support and guidance of all those people who have been
instrumental in making this project a success.

We thank our beloved Chairman, Dr. L Rathaiah Sir, who gave us great
encouragement to work.

We thank our beloved CEO, Mr. Boyapati Shravan Sir, we remember him for his
valuable ideas and facilities available in college during the development of the project.

We convey our sincere thanks to Dr. G Durga Sukumar Sir, Principal of our
institution for providing us with the required infrastructure and a very vibrant and supportive
staff.

We would like to thank our Head of the Department of Computer Science And
Engineering, Dr. G. Raja Vikram sir, a distinguished and eminent personality, whose strong
recommendation, immense support and constant encouragement has been great help to us. We
intensely thank him for the same.

We would like to express our sincere appreciations to our project coordinators


Dr.G.Janardhan sir & Dr. P. Laxmikanth sir for their guidance, continuous encouragement
and support during the project.

We would like to thank our guide of the project, Mr.N.Srianjaneya sir (Associate
Professor) who has invested his full effort in guiding the team in achieving the goal.

Special thanks go to my team mates, who helped me to assemble the parts and gave
suggestions in making this project. We have to appreciate the guidance given by other
supervisor as well as the panels especially in our project presentation that has improved our
presentation skills thanks to their comment and advice's. We take this opportunity to thank all
our lecturers who have directly or indirectly helped our project. We pay our respects and love to
our parents and all other family members and friends for their love and encouragement
throughout our career.

iv
ABSTRACT

Stress, tension, and misery are undermining the psychological well-being of


individuals. Each individual has a justification behind having an unpleasant life.
Individuals frequently discuss their thoughts via web-based entertainment stages like
on Instagram as posts and stories and on Reddit through requesting ideas about their
life. Stress disorders are quite common among people in various sectors. With
changing lifestyle and work cultures, there is an increase in the risk of stress. Though
many industries and corporate sectors provide many stress relief schemes and try to
ease the workplace atmosphere the issue is far from control. The proposed project
mainly focuses on collecting the data from various platforms from user and
identifying the stress level and depression levels of the user. It also notifies few
suggestions through mails and messages to overcome the stress. The objective is
achieved through vivid technologies.

iv
TABLE OF CONTENTS

ACKNOWLEDGEMENT .................................................................................................. IV

ABSTRACT ......................................................................................................................... V

LIST OF FIGURES .......................................................................................................... VII

1. INTRODUCTION .......................................................................................................... 01

1.1 Purpose of the system .....................................................................................................02

1.2 Scope ..............................................................................................................................03

2. LITERATURE SURVEY .............................................................................................. 04

3.SYSTEM ANALYSIS ...................................................................................................... 08

3.1 Existing system .............................................................................................................. 08

3.1.1Disadvantages of Existing system ................................................................................. 08

3.2Proposed system .............................................................................................................. 08

3.2.1Advantages of Existing system ...................................................................................... 09

3.3Software Requirements Specification .............................................................................. 09

3.3.1Hardware Requirements ............................................................................................... 11

3.3.2 Software Requirements ................................................................................................ 11

4 SYSTEM DESIGN ......................................................................................................... 12

4.1 Introduction..................................................................................................................... 12

4.2 Data Flow Diagrams........................................................................................................ 13

4.2.1Use Case Diagram ........................................................................................................ 15

4.2.2 Sequence Diagram ....................................................................................................... 17

4.2.3 Class Diagram ............................................................................................................. 19

4.2.4 Activity Diagram ......................................................................................................... 22

4.2.5 Object Diagram… ....................................................................................................... 25


4.2.6 Component Diagram .................................................................................................... 27

iv
4.2.7 Collaboration Diagram………………………………………………………………….28

4.2.8 State Chart Diagram .................................................................................................. 30

4.2.9 Block Diagram… ......................................................................................................33

4.2.10 Deployment Diagram… ............................................................................................ 34

5. SYSTEM IMPLEMENTATION… ................................................................................ 36

5.1 Algorithm Description .................................................................................................... 37

5.2 Algorithm Working………………………………………………………………………………...38


5.3 Module Description ........................................................................................................ 39
5.4 Libraries Description ...................................................................................................... 42
6 RESULTS & DISCUSSION............................................................................................. 44
6.1CSV file ........................................................................................................................... 44
6.2Data Preprocessing .......................................................................................................... 44
6.3Wordcloud ....................................................................................................................... 45
6.4Output screen ................................................................................................................... 45
6.5Telegram notification ....................................................................................................... 45
7 TESTING ANALYSIS .................................................................................................... 46
8 CONCLUSION ............................................................................................................... 48

9 FUTURE SCOPE ............................................................................................................ 49

10 REFERENCES……………………………………………………………………………50

iv
LIST OF TABLES AND FIGURES

Fig 1: Current Stress ........................................................................................................................... 1

Fig 2. Stress dataset ............................................................................................................................. 5

Fig 3. AI based emotion recognition .................................................................................................... 6

Fig 4.Incremental Model ..................................................................................................................... 7

Fig 4.0 SRS Characteristics ...............................................................................................................10

Fig 4.1: Use case Diagram of Distress Prediction ...............................................................................16

Fig 4.2: Sequence Diagram of Distress Prediction ...............................................................................19

Fig 4.3: Class Diagram of Distress Prediction ....................................................................................22

Fig 4.4: Activity Diagram of Distress Prediction ................................................................................25

Fig 4.5: Object Diagram of Distress Prediction ..................................................................................26

Fig 4.6: Component Diagram of Distress Prediction ..........................................................................28

Fig 4.7: Collaboration Diagram of Distress Prediction .......................................................................30

Fig 4.8: State Chart Diagram of Distress Prediction ............................................................................33

Fig 4.9: Block Diagram of Distress Prediction ...................................................................................34

Fig 4.10: Deployment Diagram of Distress Prediction .......................................................................35

Fig 5: Bayes Theorem .......................................................................................................................37

Fig 5.1: NLTK package .....................................................................................................................42

Fig 5.2: sklearn package ....................................................................................................................42

Fig 5.3: matplotlib package ...............................................................................................................43

Fig 6.1: CSV File reading ..................................................................................................................44

Fig 6.2: Data prepocessing ................................................................................................................44

iv
Fig 6.3: Wordcloud & output… ............................................................................................. 45

Fig 6.4: Telegram Screens… ..................................................................................................45

Fig 7.1: Various Post tests……………………………………………………………………..47

Fig 7.2: Verification……………………………………………………………………………47

Fig 9.0: Android App… ........................................................................................................ 49

iv
1. INTRODUCTION

Stress can be defined as any type of change that causes physical, emotional or psychological strain.
Stress is your body's response to anything that requires attention or action. Everyone experiences stress to
some degree. The way you respond to stress, however, makes a big difference to your overall well-being.
Stress affects both the brain and body. Little bit of stress is good for people to perform and protect
themselves but too much stress can overwhelm them leading to fight, flight or freeze response. So
learning how to cope with stress is important for our mental and physical wellbeing .

The new realities of working from home, temporary unemployment, home-schooling of children, and
lack of physical contact with other family members, friends and colleagues take time to get used to.
Adapting to lifestyle changes such as these and managing the fear of contracting the virus and worry about
people close to us who are particularly vulnerable, are challenging for all of us. They can be particularly
difficult for people with mental health conditions. It depends on how you react or respond to stress. Most
people manage stress well and continue to function while a few may have difficulty in coping with stress.
Such people should seek help from mental health treatment providers.

The COVID-19 pandemic has had a major effect on our lives. The need for physical distancing and
social restrictions has led to many of us to feeling socially isolated and left to deal with situation on our own.
These challenges that can be stressful, overwhelming and cause strong emotions. It is important for everyone
to understand what stress is, how it affects us and how to manage stress. To benefit from the contagious
nature of stress and its proneness to be influenced by surroundings can help to address this challenge

Fig 1: Current stress in people

1
Range of Expertise Includes:

 Software Development Services


 Engineering Services
 Systems Integration
 Product Development
 Electronic Commerce
 IOT Management

We apply technology with innovation and responsibility to achieve two broad objectives:

 To monitor the stress levels of a person based on their social media posts.
 The system notifies the stress alert using messages in early stage.

1.1 Purpose of the System:

Though the world is in a stage of up gradation, there is yet another problem that has to be
dealt with. Stress! Situations of people being stressful and the consequences of them being
stressed out can be seen all around. This leads to various diseases as large number of nerves get
disrupted inside the brain. A big challenge in the urban cities is stress management. Hence, smart
prediction is a system which can eradicate this problem or at least reduce it to the minimum level.

Though there are few NGO’s that work on reducing stress in people there is a need for the
government to take small steps to help people. Majority of brain and nervous disorders develop
in stressful environment. Safeguarding the levels of stress using technology sources is needed at
present. Majority of the public seem to be disturbed with the unwanted stress. So, predicting the
stress at ealy stage before it results to anxiety and alerting the victim for an emergency is highly
needed. Amounts of stress is largely determined by two factors
1. The social pressures.

2. Understanding patterns.

2
This system assures the cleaning of dustbins soon when the garbage level reaches its
maximum.

1.2 Scope

Waste management is becoming a global concern these days. The world generates almost
a billion tonnes of municipal solid waste annually, with at least 33% of it not managed IN an
environmentally safe manner, per The World Bank report. And it’s further projected to grow to 3.40
billion tonnes by 2050. IoT is one technology that municipalities can employ to better manage
waste. To demonstrate this point, IoT technologies are already main stream for modern supply
chains. Not only has that, but IoT management systems have also proven to be invaluable to
optimize and automate processed in this industry. However, adoption is far greater on the supply
chain side. Though, similar logistic technology can be used to return the waste of those products.
Many IoT based waste management systems are available, but perceived challenges hold them
back.

This has prompted efficiency concerns, considering the growing cries for action on
climate change. IoT is proving to be an effective solution across various areas, but waste
management companies and municipalities haven’t utilized the technology effectively to improve
operational efficiency. The proposed project uses iot equipment such as nodemcu and ultrasonic
sensors in order to detect the minimum threshold level of waste. Later, if there is any fulfillment of
the threshold the notifications are sent using Telegram Bot through which authorities are informed.
Using this kind of a system it is easy for collectors to find the exact location and appropriate bin that
needs to be emptied.

3
2.LITERATURE SURVEY

1. An Efficient Machine Learning Framework for Stress Prediction via Sensor Integrated Keyboard Data
In this paper, an Adaptive Neuro-Fuzzy Inference System aided Fire Works Grey Wolf
Optimization (ANFIS-FWGWO) classification algorithm has been proposed for stress prediction.
In particular, the proposed machine learning framework has been implemented to predict
computer users' stress by using a sensor-integrated keyboard data. Various physiological
parametric data were acquired during two different phases for the experimentation, and the
received data was analyzed using an efficient machine learning framework. Specifically, the
proposed framework encompasses various techniques such as data preprocessing for data
smoothing and the Least Absolute Shrinkage and Selection Operator (LASSO) feature selection
algorithm for identifying the important features on the data set.

2. Internet of Things Based Stress Prediction Model.


In today's busy world time is a vital issue which can't be managed by noticing each
and every phenomenon with our tight schedule. So now a day's Automatic systems are being
preferred over manual system to make life simpler and easier in all aspects. To make it a grand
success Internet of Things is the latest internet technology developed. The number of users of
internet has grown so rapidly that it has become a necessary part of our daily life. Our matter of
concern in this project is development of Internet of Things based Stress Prediction System. As
the lifestyle of world is changing day by day, the levels of stress must be detected for our better
life. Based on the heartbeat, a prediction of whether a person is under stress or not can be made.
The paper presents a model that can predict stress levels based entirely on electrocardiogram
(ECG) data, which can be measured with consumer-grade heart monitors The ECG's spectral
power components, as well as time and frequency domain features of heart rate variability, are
included in the model. The stress detector system takes the real-time data from the IoT device
(sensor). This paper is a review of Stress Detection System based on IOT.

3. Passive Sensor Based Health and Stress Prediction.

In this paper, we built wellbeing prediction models using passively sensed data
from wearable sensors, mobile phones, and weather API, and deep learning methods, and evaluated
the models with the data from new users. We compared deep long short-term memory (LSTM)
network and the combination of convolution neural network (CNN) and the LSTM model. We
found that our deep LSTM model provided performances, in mean absolute error (MAE), as 15.7,
15.6, and 16.8 out of 100 in predicting self-reported mood, health, and stress respectively for new
users.

4
There are many approaches implemented in Stress Detection. In this section, some ofthe
most interesting stress detection methods are presented.

K-Means & IoT Based Stress Management:


Stress is one of the most significant health issues in the modern world. The
importance of detecting is well known, both for economic and ecological reasons, and
the industry demands high efficiency. Current studies towards automatic stress
detection are hardly comparable due to the lack of benchmarks and widely accepted
standards regarding the used metrics and data. Those problems are addressed in this
article by providing a critical analysis of over ten existing waste datasets and a brief
but constructive review of the existing Deep Learning-based stress detection
approaches
An electrocardiogram signal is required to check the state of stress.
Feature points according to the difference between the R-R interval and the R-
Speak value are extracted from the acquired ECG signal. To classify an ECG signal,
the R-S peak value is set to 1.2 as the reference point. If it is greater than this value,
the ECG signal moves to the right, and if it is smaller, it moves to the left. By using
these feature points, how much stress the user is experiencing is indexed. Finally,
K-means clustering is applied and classified into cases of stress and no stress.

Fig 2: Stress dataset

5
2.AI Based Stress Management:

Stress is a natural and common occurrence in humans. It leads to the release of hormones
which help deal with the situation, but chronic stress affects our health and could lead to deleterious
effects like depression, insomnia or headaches and therefore, early detection of stress becomes
imperative to prevent such harmful consequences. This manuscript aims to automate the process of
mental stress detection and help classify a stressed individual from a normal one through the use of
physiological data collected from a wearable device. A publicly available dataset was used to
evaluate our solution. Different Artificial Intelligence models like Artificial Neural Network (ANN),
Hybrid of Artificial Neural Network and Support Vector Machine (ANN-SVM), Stacking Classifier
and Radial Basis Function (RBF) Network were used, and their performance was compared using the
accuracy of predicting correct stress state. During the study, Stacking Classifier gave the highest
accuracy value of 99.92% while the RBF gave the least accuracy of 84.46% for three class
classification of stress. The obtained results indicate the effectiveness of the proposed models in
continuous monitoring of mental stress. The experimental results serve to demonstrate that the
physiological signals can have a significant appositeness in mental stress detection.

Fig 3: AI based emotion recognition

Software Development Life Cycle

 Our project follows incremental model in SDLC.

What is Incremental Model?

Incremental Model is a process of software development where requirements are broken down into
multiple standalone modules of software development cycle. Incremental development is done in steps
from analysis design, implementation, testing/verification, maintenance.

6
Each iteration passes through the requirements, design, coding and testing phases.
And each subsequent release of the system adds function to the previous release until all
designed functionality has been implemented

.
Fig 4: Incremental model

The system is put into production when the first increment is delivered. The
first increment is often a core product where the basic requirements are addressed, and
supplementary features are added in the next increments. Once the core product is analyzed by
the client, there is plan development for the next increment.

Reasons to use Incremental Model:

 Requirements of the system are clearly understood


 When demand for an early release of a product arises
 When software engineering team are not very well skilled or trained
 When high-risk features and goals are involved
 Such methodology is more in use for web application and product-based companies

7
3. SYSTEM ANALYSIS

This part of our project documentation focuses on existing system, proposed system,
advantages of proposed system, modules in the project along with their description and the
system requirements.

3.1 Existing System:


The current system of Predicting Stress is an IoT process that takes data from
physiological elements. The system senses the variable parameters like heart beat, temperature of the
body and based on the threshold, it generates the output whether a person is stressful or not.
This automated system of stress monitoring is based on sensors.A threshold needs to be
set prior and on sensing the elements the detection is done.

3.1.1 Disadvantages of Existing System:

 Cost inefficient
 Devices are required
 Wrong predictions due to variable parameters
 Low rate of detecting
 Misleading activities

3.2 Proposed System:

The proposed system is a smart way in which the stress is predicted and notified. Our
main intention is to take a step forward to reduce the shares of mental issues and raise a
healthy world!!This is an ML based project that uses social media posts to detect the stress
and few other softwares to send SMS. The proposed solution will notify the user when the
stress levels are high in order to prevent dangerous situations. It is effective as it notifies

8
before the person moves into depression. Main objective of the project is to detect stress
based on social media posts and notify the victim online.

3.2.1 Advantages of Proposed System:

 Timely observation of posts

 Sends notification if user is in stress

 Enhances mental health

 Identifies situations that cause more stress

 Saves from entering into depression

 Highly efficient

3.3 Software Requirement Specification:

A System Requirements Specification (abbreviated SRS when need to be distinct from


a Software Requirements Specification SRS) is a structured collection of information that
embodiesthe requirements of a system. A business analyst, sometimes titled system analyst, is
responsible for analysing the business needs of their clients and stakeholders to help identify
businessproblems and propose solutions.
Within the systems development life cycle domain, the BA typically performs a
liaison function between the business side of an enterprise and the information technology
department or external service providers. Software requirements specification establishes the
basis for an agreement between customers and contractors or suppliers (in market-driven
projects, these roles may be played by the marketing and development divisions) on what the
software product is to doas well as what it is not expected to do.
Software requirements specification permits a rigorous assessment of requirements
beforedesign can begin and reduces later redesign. It should also provide a realistic basis for
estimating product costs, risks, and schedules. The software requirements specification
document enlists enough and necessary requirements that are required for the project
development.
To derive the requirements, we need to have clear and thorough understanding of the
products to be developed or being developed. This is achieved and refined with detailed and
continuous communications with the project team and customer till the completion of the
software.

9
Advantages of having a proper SRS Documentation.

 It provides a realistic basis for estimating product costs, risks and schedules. 
 It provides an informed basis for deploying a product to new users or new operational environments.
 It provides a basis for product enhancement.
 It forces a rigorous assessment of requirements before design can begin and minimizes later redesign. 
 It establishes the basis for agreement between the acquirers or suppliers on what the product is to do (in
market driven projects, the user input may be provided by marketing).
 Organizations can use the specifications to develop validation and verification plans.

10
3.3.1 Hardware Requirements:

 Processor : Intel i5 7th GEN

 Ram : 64 GB.

 Computer : Laptop

 Hard disk space : 16 GB for 32-bit OS 20 GB for 64-bit OS

 Display : 800x600

3.3.2 Software Requirements:

 Operating system : Windows 10

 Pycharm IDE : Python.

 Dataset of posts : Redhat posts

 Alerting message : Telegram

 Python Packages : time, requests, json etc.

 Internet : nominal speed

11
4.SYSTEM DESIGN

4.1 Introduction

Software design sits at the technical kernel of the software engineering process and is
applied regardless of the development paradigm and area of application. Design is the first
step in the development phase for any engineered product or system. The designer‘s goal is to
produce a model or representation of an entity that will later be built. Beginning, once system
requirement has been specified and analyzed, system design is the first of the three technical
activities -design, code and test that is required to build and verify software.

The importance can be stated with a single word ―Quality‖. Design is the place
where quality is fostered in software development. Design provides us with representations of
software that can assess for quality. Design is the only way that we can accurately translate a
customer‘s view into a finished software product or system. Software design serves as a
foundation for all the software engineering steps that follow. Without a strong design we risk
building an unstable system – one that will be difficult to test, one whose quality cannot be
assessed until the last stage. The purpose of the design phase is to plan a solution of the
problem specified by the requirement document. This phase is the first step in moving from
the problem domain to the solution domain. In other words, starting with what is needed,
design takes us toward how to satisfy the needs. The design of a system is perhaps the most
critical factor affection the quality of the software; it has a major impact on the later phase,
particularly testing, maintenance. The output of this phase is the design document. This
document is similar to a blueprint for the solution and is used later during implementation,
testing and maintenance. The design activity is often divided into two separate phases System
Design and Detailed Design.

System Design also called top-level design aims to identify the modules that should
be in the system, the specifications of these modules, and how they interact with each other to
produce the desired results. At the end of the system design all the major data structures, file
formats, output formats, and the major modules in the system and their specifications are
decided. During, Detailed Design, the internal logic of each of the modules specified in
system design is decided. During this phase, the details of the data of a module is usually
specified in a high-level design description language, which is independent of the target
language in which the software will eventually be implemented.

In system design the focus is on identifying the modules, whereas during detailed
design the focus is on designing the logic for each of the modules. In other works, in system
design the attention is on what components are needed, while in detailed design how the
components can be implemented in software is the issue. Design is concerned with
identifying software components specifying relationships among components. Specifying
software structure and providing blue print for the document phase. Modularity is one of the
desirable properties of large systems. It implies that the system is divided into several
parts. In such a manner, the interaction between parts is minimal clearly specified.

12
During the system design activities, Developers bridge the gap between the
requirements specification, produced during requirements elicitation and analysis, and the
system that is delivered to the user. Design is the place where the quality is fostered in
development. Software design is a process through which requirements are translated into a
representation of software.

4.2 Data Flow Diagrams:

A graphical tool used to describe and analyse the moment of data through a system
manual or automated including the process, stores of data, and delays in the system. Data
Flow Diagrams are the central tool and the basis from which other components are developed.
The transformation of data from input to output, through processes, may be described
logically and independently of the physical components associated with the system. The DFD
is also known as a data flow graph or a bubble chart.
DFDs are the model of the proposed system. They clearly should show the
requirements on which the new system should be built. Later during design activity this is
taken as the basis for drawing the system‘s structure charts. The Basic Notation used to create
a DFD‘s are as follows:

Dataflow: Data move in a specific direction from an origin to a destination.

Process: People, procedures, or devices that use or produce (Transform) Data.

13
Source: External sources or destination of data, which may be People, programs, organizations or
Other entities.

Data Store: Here data are stored or referenced by a process in the System.

4.2.1 Use Case Diagram

Use case diagrams model the functionality of a system using actors and use cases. Use cases are
services or functions provided by the system to its users. Use case diagram is useful for
representing the functional requirements of the system using various notations like system, use
case, actors, and relationships.

Basic Use Case Diagram Symbols and Notations System

Draw your system's boundaries using a rectangle that contains use cases. Place actors outside
the system's boundaries.

14
Use Case
Draw use cases using ovals. Label with ovals with verbs that represent the system's functions.

Actors
Actors are the users of a system. When one system is the actor of another system, label the
actor system with the actor stereotype.

Relationships

Illustrate relationships between an actor and a use case with a simple line. For relationships
among use cases, use arrows labelled either "uses" or "extends." A "uses" relationship
indicatesthat one use case is needed by another in order to perform a task. An "extends"
relationship indicates alternative options under a certain use case.

15
Fig:4.1 Use case diagram of distress prediction

16

16
4.2.2 Sequence Diagram:

Sequence diagrams describe interactions among classes in terms of an exchange of messages


over time.

Basic Sequence Diagram Symbols and Notations:

Class roles:

Class roles describe the way an object will behave in context. Use the UML object symbol to
illustrate class roles, but don't list object attributes.

Activation
Activation boxes represent the time an object needs to complete a task.

Messages:

Messages are arrows that represent communication between objects. Use half-arrowed lines to
represent asynchronous messages. Asynchronous messages are sent from an object that will not
wait for a response from the receiver before continuing its tasks.

Various message types for Sequence and Collaboration diagrams

17

17
Lifelines:

Lifelines are vertical dashed lines that indicate the objects presence over time.

Destroying Objects:

Objects can be terminated early using an arrow labeled "<< destroy >>" that points to an X.

Given below is the sequence diagram for distress prediction system.

18
Fig 4.2: Sequence Diagram of distress prediction system

4.2.3ClassDiagram

CLASS DIAGRAM gives an overview of a software system by displaying classes, attributes,


operations, and their relationships. This Diagram includes the class name, attributes, and
operation in separate designated compartments.

Essential elements of A UML class diagram

 Class Name
 Attributes
 Operations

19
Class Name

The name of the class is only needed in the graphical representation of the class. It appears in the
topmost compartment. A class is the blueprint of an object which can share the same relationships,
attributes, operations, & semantics. The class is rendered as a rectangle, including its name, attributes,
and operations in separate compartments.

Following rules must be taken care of while representing a class:

1. A class name should always start with a capital letter.


2. A class name should always be in the center of the first compartment.
3. A class name should always be written in bold format.
4. An abstract class name should be written in italics format.

Attributes

An attribute is named property of a class which describes the object being modeled. In the classdiagram,
this component is placed just below the name-compartment.

A derived attribute is computed from other attributes.

Relationships

There are mainly three kinds of relationships in UML:

 Dependencies
 Generalizations
 Associations

Dependency

A dependency means the relation between two or more classes in which a change in one mayforce
changes in the other. However, it will always create a weaker relationship. Dependency indicates that one
class depends on another.

20
Generalization

A generalization helps to connect a subclass to its superclass. A sub-class is inherited from its superclass.
Generalization relationship can't be used to model interface implementation. Class diagram allows
inheriting from multiple superclasses.

Association

This kind of relationship represents static relationships between classes A and B.

The below figure shows the class diagram of our project.

21
Fig 4.3: Class Diagram of dumpster management system.

4.2.4 Activity Diagram

An activity diagram illustrates the dynamic nature of a system by modeling the flow of
control from activity to activity. An activity represents an operation on some class in the system that
results in a change in the state of the system. Typically, activity diagrams are used to model workflow
or business processes and internal operation. Because an activity diagram is a special kindof state chart
diagram, it uses some of the same modeling conventions.

Basic Activity Diagram Symbols and Notations

Action states

Action states represent the non-interruptible actions of objects. You can draw an action state inSmart
Draw using a rectangle with rounded corners.

22
Action Flow

Action flow arrows illustrate the relationships among action states.

Object Flow

Object flow refers to the creation and modification of objects by activities. An object flowarrow
from an action to an object means that the action creates or influences the object. An object flow arrow
from an object to an action indicates that the action state uses the object.

Initial State
A filled circle followed by an arrow represents the initial action state.

Final State
An arrow pointing to a filled circle nested inside another circle represents the final action state.

23
Branching
A diamond represents a decision with alternate paths. The outgoing alternates should be
labeled with a condition or guard expression. You can also label one of the paths "else."

Synchronization

A synchronization bar helps illustrate parallel transitions. Synchronization is also calledforking and
joining.

Swimlanes - Swimlanes group related activities into one column.

24
Fig 4.4 : Activity Diagram for Distress prediction System

4.2.5 Object Diagram

Object diagrams are dependent on the class diagram as they are derived from the class diagram. It
represents an instance of a class diagram. The objects help in portraying a static view of an object-
oriented system at a specific instant. Both the object and class diagram are similar to some extent; the
only difference is that the class diagram provides an abstract view of a system. It helps invisualizing a
particular functionality of a system.

25
Fundamental Object Diagram Symbols Notations

Object Names
Every single object is represented such as a rectangular shape, which provides the name
through the object as well as class underlined along with shared using a colon.

Object Attributes

Just like classes, it is possible to list object attributes within an individual box. Even so, as
opposed to classes, object attributes must have values allocated to them.

Links

We use a link to symbolize a relationship between two objects. You are able to draw the link
when using the lines applied to class diagrams.

26
4.2.6 Component Diagram

UML Component diagrams are used to only demonstrate the behavior as well as the structure of
asystem. Component diagrams are basically diagrams of the class focusing on components of a
system are often used for modeling of the static implementation view of the system.
Component diagrams have many advantages that can help our team in various ways :

 It pays attention to how the system‘s components relate.


 It emphasizes the behavior of service when it relates to the interface.
 It also imagines the physical structure of the system.

Symbols of UML Component Diagram

Component: Component in UML is defined as a modular part of a system. It always


defines its behavior which is in terms of required and given interfaces.

Package: Package in UML can be defined as something that can group elements, and
then givesa namespace for all of those grouped elements.

27
Dependency: Dependency relationship in UML can be defined as a relationship wherein
one of the elements which are the client uses or depends on another element which is the
supplier.

Fig 4.6 Component Diagram for distress prediction

4.2.7 Communication Diagram – Collaboration Diagram

Communication diagrams, like sequence diagrams - a kind of interaction diagram, shows how
objects interact. A communication diagram is an extension of object diagram that shows the
objects along with the messages that travel from one to another. In addition to the associations
among objects, communication diagram shows the messages the objects send each other.

Some commonly used symbols and components of communication diagrams are below.

28
Objects
Objects can be classed as either a supplier or a client. Suppliers call the function that supplies
the message. Clients send the message to the supplier, who receives it.

Object

Link
A straight line connecting two objects indicates a relationship between them. The two objects
area ble to send messages to each other.

Messages

Synchronous message: a sender transmits a message, and must wait for a response before
continuing. This is shown by a straight line and a solid arrowhead.

Asynchronous message: a sender does not need to wait for a response before proceeding.
This is shown by a straight line and a lined arrowhead.

29
Sequence of messages: Typically, messages will have a number and description next to
them. The number determines the order in which messages should be read.

Fig 4.7 : Collaboration Diagram for Distress Prediction

4.2.8 State-Chart Diagram:

A state diagram is used to represent the condition of the system or part of the system at finite instances of
time. It‘s a behavioral diagram and it represents the behavior using finite state transitions. State diagrams
are also referred to as State machines and State-chart Diagrams.

Uses of state chart diagram –

 We use it to state the events responsible for change in state (we do not show what
processes cause those events).
 We use it to model the dynamic behavior of the system.
 To understand the reaction of objects/classes to internal or external stimuli.

30
Basic components of a state chart diagram:

Initial state
We use a black filled circle represent the initial state of a System or a class.

Transition

We use a solid arrow to represent the transition or change of control from one state to another.
Thearrow is labelled with the event which causes the change in state.

State

We use a rounded rectangle to represent a state. A state represents the conditions or


circumstances of an object of a class at an instant of time.

Fork

We use a rounded solid rectangular bar to represent a Fork notation with incoming arrow from
theparent state and outgoing arrows towards the newly created states. We use the fork notation
to represent a state splitting into two or more concurrent states.

31
Self transition

We use a solid arrow pointing back to the state itself to represent a self transition. There might
be scenarios when the state of the object does not change upon the occurrence of an event. We
use self transitions to represent such cases.

Composite state

We use a rounded rectangle to represent a composite state also.We represent a state with internal
activities using a composite state.

Final state

We use a filled circle within a circle notation to represent the final state in a state machine
diagram.

32
Fig 4.8: State Diagram of Distress Prediction

4.2.9 Block Diagram

A Block Diagram is a drawing illustration of a system whose major parts or components are represented
by blocks. These blocks are joined by lines to display the relationship between subsequent blocks.
Block in Block Diagram is the representation of several known properties such that when summed
together, they make up the central block diagram. The blocks portray a system as a collection of
components responsible for specific tasks in a particular setting.

Basic block components are mainly five and include:

Block: it represents the logical and physical components of the system.

Part: it comprises all aspects modeled using aggregation and association.

Reference: it has all the parts which were developed using aggregation and association.

Standard Port: this is the point of interaction between a system block and the corresponding
Environment.

Flow Port: this is the point of interaction where a block can emerge from or to.

Association: it explains the communication amongst the blocks.

33
Fig 4.9 : Block Diagram of distress prediction.

4.2.10 Deployment Diagram

UML Deployment diagram is used to define the hardware requirements for the particular
product to execute the software, basically it maps the software design requirement to the
physical system which executes the software design and visualize how software interact with
hardware to complete the test execution. To design the deployment diagram node, component,
artifact and interface notation are used.

The Main Purpose of the Deployment Diagram

 To represent the hardware topology of a system.


 Represent how different hardware components are inter-connected and how these
hardware components are used to deploy software components.

34
Fig 4.10: Dependency diagram for distress prediction

35
5.SYSTEM IMPLEMENTATION

In the proposed system we have designed an ML model which measures the level of stress. The ML
model is designed based on Naïve Bayesian algorithm. It is one of the prominent classification
algorithms. Social media posts are taken as input to test and when the new post is given, the model
classifies stress victims and notifies them.

The main motto of this project is to detect the stress at early stage and notify the victims at right time.

 Initially, we will start with creating an ML model by t aking


social- media post s as input using few t est dat aset s and
algorit hms.
 Next step is to classify the data using naïve bayes theorem and apply it
to new posts for detection.
 Overall, we will be detecting the stress level with the help of classification model and
send an SMS to the users through Chatbot service of telegram. Below is the schema on
howwe have implemented the same.

1. Install Pycharm from Microsoft store and from app store.


2. Collect posts from social media platforms and place it in a dataset.
3. Choose the appropriate classification algorithm and perform data preprocessing steps
on the data in order to create a word cloud.
4. Create a telegram chatbot and use the id for communication purpose also adds it to
the chatbot module of code in pycharm.

5. Classify the data using wordcloud and algorithm selected. Now, give a new post
and classify whether the user is a stressful person or not.
6. Finally, the user can see the telegram messages in the channel when the stressful posts
are detected.

36
5.1 ALGORITHM DESCRIPTION:

The algorithm chosen for this project of distress prediction and message alerting system is the
ancient NAÏVE BAYESIAN CLASSIFICATION. It is based on probability concepts from mathematics.

o Naïve Bayes algorithm is a supervised learning algorithm, which is based on Bayes theorem and
used for solving classification problems.
o It is mainly used in text classification that includes a high-dimensional training dataset.
o Naïve Bayes Classifier is one of the simple and most effective Classification algorithms which help
in building the fast machine learning models that can make quick predictions.
o It is a probabilistic classifier, which means it predicts on the basis of the probability of an object.
o Some popular examples of Naïve Bayes Algorithm are spam filtration, Sentimental analysis, and
classifying articles.

Bayes' Theorem:
o Bayes' theorem is also known as Bayes' Rule or Bayes' law, which is used to determine the
probability of a hypothesis with prior knowledge. It depends on the conditional probability.
o The formula for Bayes' theorem is given as:

Where,

P(A|B) is Posterior probability: Probability of hypothesis A on the observed event B.

P(B|A) is Likelihood probability: Probability of the evidence given that the probability of a hypothesis.

P(A) is Prior Probability: Probability of hypothesis before observing the evidence.

P(B) is Marginal Probability: Probability of Evidence.

37
Advantages of Naïve Bayes Classifier:
o Naïve Bayes is one of the fast and easy ML algorithms to predict a class of datasets.
o It can be used for Binary as well as Multi-class Classifications.
o It performs well in Multi-class predictions as compared to the other Algorithms.
o It is the most popular choice for text classification problems.

5.2 ALGORITHM WORKING:


Now we will implement a Naive Bayes Algorithm using Python. So for this, we will use the
"user_data" dataset, which we have used in our other classification model. Therefore we can easily
compare the Naive Bayes model with the other models.

Steps to implement:
o Data Pre-processing step
o Fitting Naive Bayes to the Training set
o Predicting the test result
o Test accuracy of the result(Creation of Confusion matrix)
o Visualizing the test set result.

Applications of Naïve Bayes Classifier:


o It is used for Credit Scoring.
o It is used in medical data classification.
o It can be used in real-time predictions because Naïve Bayes Classifier is an eager learner.
o It is used in Text classification such as Spam filtering and Sentiment analysis.

38
5.3 MODULE DESCRIPTION:

 Our module includes two modules:

 classify
 Telegram_bot

Classify:

The main motto of this module is to program a n M L m o d e l t h a t u s e s N a ï v e B a ye s


c l a s s i f i c a t i o n . The coding of this module is done in python language.

 The module allows the program to access social media posts and converts it to database. As well as it
creates a model to train and test using new posts. 

 The functions used in this model are:

 read_csv :
The posts from social media platforms are collected and gathered to a csv file. This file
consists of rows and columns that include each word and character.

 clean:

This is used to clean the csv file. The main objective of this is to remove the unwanted
values, missing values and noisy data. There are few python packages that are used to collect
keywords that are necessary for identification of stress.

 stem:
This function is used to remove the prefixes and suffixes from the root word. Once the dataset
is cleaned, the identification words are separated from the entire file. Later these words are stemmed
inorder to obtain only the root word.

39
 The module includes other basic functions:

 countVectorizer: 

These functions are found in python inbuilt packages. This is used to plot the important keywords
in the form wordclouds. The distance between words and their placements are calculated.

 Test():

This is the function of the module that analyzes the training data and tests the new posts from
user. Another supportive module called sklearn is used here.

 Fit():

This function is used to transform the csv file data after cleaning to an array inorder to fit the
model

 predict():

The model is trained using naïve bayes classification algorithm and this knowledge is used to
predict the test data and new data.

40
Telegram_bot:

The second module of our project is a python based module which is created using Pycharm IDE.
This module is divided into two parts.

 Receive_data

 Chatbot_data

 recieve_data:

The main objective of this module is to receive the output from classification and check whether
the given post is stressful. The binary format is converted to python code for sending telegram messages.

 Chatbot_data:

This python code contains the telegram url and the channel API of the telegram channel as well as
the thingspeak API in order to read data from it. This piece of code is imported as a package into receive_data.

Other important Python Packages:

1. ntlk

2. sklearn.naive_bayes

3. matplotlib

Let us see the detail description of each module and their sub modules.

41
1. NLTK:
Natural language processing (NLP) is a field that focuses on making natural human language usable
by computer programs. NLTK, or Natural Language Toolkit, is a Python package that you can use for
NLP. A lot of the data that you could be analyzing is unstructured data and contains human-readable text.
Before you can analyze that data programmatically, you first need to preprocess it. We use this to create
wordclouds in our project.

Fig:5.1 NLTK Functionality

2. SkLearn:
Scikit-learn (Sklearn) is the most useful and robust library for machine learning in Python. It
provides a selection of efficient tools for machine learning and statistical modeling including classification,
regression, clustering and dimensionality reduction via a consistence interface in Python. This library,
which is largely written in Python, is built upon NumPy, SciPy and Matplotlib.

Fig:5.2 SkLearn Module

42
3.Matplotlib:
Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-
platform data visualization library built on NumPy arrays and designed to work with the broader SciPy
stack. One of the greatest benefits of visualization is that it allows us visual access to huge amounts of data
in easily digestible visuals. Matplotlib consists of several plots like line, bar, scatter, histogram etc.

Fig:5.3 matplotlib

43
6. RESULTS AND DISCUSSIONS

The following images show the working and output of our project.

Fig 6.1 Reading posts file of csv format

 The above code snippet gives the implementation of reading the csv file using panda library. We also
check if there are any null values present in the dataset.

Fig 6.2 Preprocessing data and forming wordcloud

 This code cleans the post by removing punctuations and unwanted affixes using Stemmer. A wordcloud
cloud is created using stopword package.

44
Fig 6.3 NLP Wordcloud and output classification
 The above screenshot shows the output of the project. A wordcloud is created using
stressful words and when a new post is given, classification is performed.

Fig 6.5 telegram notifications

 Finally, if the post is stressful then an alert message is given to the user with the help of telegram.

45
7. TESTING ANALYSIS
Software testing is the process of evaluating and verifying that a software product or application does
what it is supposed to do. The benefits of testing include preventing bugs, reducing development costs
and improving performance.

There are many different types of software tests, each with specific objectives and strategies:

 Acceptance testing: Verifying whether the whole system works as intended.


 Integration testing: Ensuring that software components or functions operate together.
 Unit testing: Validating that each software unit performs as expected. A unit is the smallest testable
component of an application. 
 Functional testing: Checking functions by emulating business scenarios, based on functional
requirements. Black-box testing is a common way to verify functions. 
 Performance testing: Testing how the software performs under different workloads. Load testing, for
example, is used to evaluate performance under real-life load conditions. 
 Regression testing: Checking whether new features break or degrade functionality. Sanity testing can be
used to verify menus, functions and commands at the surface level, when there is no time for a full
regression test.
 Stress testing: Testing how much strain the system can take before it fails. Considered to be a type of
non-functional testing.
 Usability testing: Validating how well a customer can use a system or web application to complete a task.

In our project the basic tests that we have included are:

Unit Testing: The project was divided into various modules and each module was considered as a unit.
Sample codes were made use to test every unit.

Performance Testing: Various levels of workload was given to test the detection. That is different posts
were given as new words to test the working.

Testing Scenarios:

 Verify whether the hardware is in working condition.


 Verify if the softwares are properly installed and ready to use with all packages.
 Verify if the chatbot and bot id are taken without human error.
 Verify if there is no time delay in delivering the messages to user.
 Verify if the codes are working for different words from posts.

46
Fig 7.1 test with various posts

Fig 7.2 verification of chatbot urls and id

47
8. CONCLUSION

Stress management is the most challenging aspect in the present world. If the stress
is not managed or detected properly it will cause a great damage to the personal life. So, we
have to introduce a new mechanism for the stress management. For the purpose of stress
management in our project we have developed a mechanism. This mechanism was used to
predict the early stages of stress. An ML model is built using naïve bayes classification and
the stress is predicted on basis of social media posts. It predicts and alerts the user on
detecting stress. This system will be helpful for eliminating the present-day scenario of
neglecting the early stages of stress if cause huge damage. We are using telegram chatbot for
sending message to the users who are in stress. It will create a good platform to predict the
stress from posts and alert the user so that he or she can visit the nearest psychologist in order
to reduce risks.

The main objectives of our project that were fulfilled are:

• We predict the stress based on social media posts through machine learning model.
• This system assures the accurate prediction and notification system.
• It also reduces the risks of entering into deep stress and helps users by alerting them.

Diseases such as stress, anxiety, depression, and ADHD are commonly found in
the younger generation. This is all contributed to various factors such as lifestyle choices,
social and economic pressure, and low self-esteem. Workload, immense social and economic
pressure, and family responsibilities are other factors that impose increasing levels of stress on
individuals. Hence, detection and analysis of stress at early stages can reduce severe
consequences and risks that may occur in the future. In modern times, advancement in
technology has created a need for evolution in the medical sector. As a result, it is crucial to
predict and analyze various symptoms that cause stress so that it is easier to find their
treatment as soon as possible.

48
9. FUTURE SCOPE

In this project, implementation is done using the social media posts i.e. redhat posts. The
current project takes the posts and takes this dataset as input for machine learning model. After
training and testing it predicts if the person is in stress using natural language and alerts the user
using telegram bot. For the advancement of the current project, an automation can be added were
the algorithm works without database by directly reading posts. One can give their social media
access to the code so that model can run at backend. In order to do so, there is a need to increase
security.
Similarly, addition of AI can be done to the current project so that it can easily detect the
emotion and precautions can be directed to the user. After the prediction, a map can be introduced
along with alert message that shows the address of nearest psychologist. Futher extention can also
be made by introducing voice recognition system to detect stress on calls and videos. An app can
be made that reads chats and text and detect the stress level. Therefore algorithms used are very
basic and can also be modified keeping the time and space complexity in consideration.

Fig 9.0 Android App that reads texts and suggests measures

49
10. REFERENCES

 Kassymova G et al (2019) Impact of stress on creative human resources and psychological


counselling in crisis. Int J Educ Inf Technol 13
 Triguero I et al (2019) Transforming big data into smart data: an insight on the use of the K-nearest
neighbors algorithm to obtain quality data. Wiley Interdisc Rev: Data Min Knowl Disc 9(2):e1289
 Flesia L et al (2020) Predicting perceived stress related to the covid-19 outbreak through stable
psychological traits and machine learning models. J Clin Med
 Zubair M et al (2015) Smart wearable band for stress detection. In: 5th International conference on IT
convergence and security. IEEE
 Sierra A et al (2011) A stress-detection system based on physiological signals and fuzzy logic. IEEE
Trans Ind Electron 58(10)
 Internet of Things Based Stress Monitoring System. (2017)
 Smart Stress Monitoring and Detection System using Internet of Things. (2017)
 IRJET Papers.

50

You might also like