Stress Detection Using Machine Learning and Deep L
Stress Detection Using Machine Learning and Deep L
Stress Detection Using Machine Learning and Deep L
zanariah86@gmail.com, shafaatunnur@utm.my
Abstract. Stress is a normal phenomenon in today's world, and it causes people to respond to a
variety of factors, resulting in physiological and behavioural changes. If we keep stress in our
minds for too long, it will have an effect on our bodies. Many health conditions associated with
stress can be avoided if stress is detected sooner. When a person is stressed, a pattern can be
detected using various bio-signals such as thermal, electrical, impedance, acoustic, optical, and
so on, and stress levels can be identified using these bio-signals. This paper uses a dataset that
was obtained using an Internet of Things (IOT) sensor, which led to the collection of information
about a real-life situation involving a person's mental health. To obtain a pattern for stress
detection, data from sensors such as the Galvanic Skin Response Sensor (GSR) and the
Electrocardiogram (ECG) were collected. The dataset will then be categorised using Multilayer
Perceptron (MLP), Decision Tree (DT), K-Nearest Neighbour (KNN), Support Vector Machine
(SVM), and Deep Learning algorithms (DL). Accuracy, precision, recall, and F1-Score are used
to assess the data's performance. Finally, Decision Tree (DT) had the best performance where
DT have accuracy 95%, precision 96%, recall 96% and F1-score 96% among all machine
learning classifiers.
1. Introduction
Stress is something that concerns our lives. There are many variables in our day-to-day life that are
tension. Human environments, like worksite, home, or society, may somehow inflict stress on a person.
According to Palmer [1], "Stress is defined as a complex psychological and behavioural condition when
the person's demands are imbalanced and the way demands are met."
Also, the American Institute of Stress found that 80% of workers experience stress in their everyday
work and need support in managing stress. Based on Ahuja and Banga [2], study recorded major suicide
cases among students aged 15-29 due to stress. There are 8934 cases recorded in 2015, and study was
inspired to identify stress in early stages. These figures and stress effects on people, which has been the
leading cause of many diseases like hypertension, sleep deprivation, and others. Stress that cannot be
adequately treated can lead to serious cases where one person committed suicide. This is vital to identify
and control stress before it becomes severe. Many researchers investigate stress detection in many fields.
This paper will elaborate on stress identification based on five conditions using data obtained using IoT
sensors. Early detection can help track tension, and different machine learning and deep learning
approaches have been explored and compared.
Content from this work may be used under the terms of the Creative Commons Attribution 3.0 licence. Any further distribution
of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.
Published under licence by IOP Publishing Ltd 1
Asian Conference on Intelligent Computing and Data Sciences (ACIDS) 2021 IOP Publishing
Journal of Physics: Conference Series 1997 (2021) 012019 doi:10.1088/1742-6596/1997/1/012019
2
Asian Conference on Intelligent Computing and Data Sciences (ACIDS) 2021 IOP Publishing
Journal of Physics: Conference Series 1997 (2021) 012019 doi:10.1088/1742-6596/1997/1/012019
3. Research Methodology
The research methodology used to conduct the analysis for this paper is detailed below. The paper's
primary contribution is the identification of stress using machine learning and deep learning. The flow
diagram below illustrates the proposed work on stress detection using machine learning and deep
learning. This can be summarised in five steps.
3
Asian Conference on Intelligent Computing and Data Sciences (ACIDS) 2021 IOP Publishing
Journal of Physics: Conference Series 1997 (2021) 012019 doi:10.1088/1742-6596/1997/1/012019
using a machine learning classifier to predict the users' mental states and to comprehend their
physiological characteristics under various conditions. This dataset is referred to as the Stress Analysis
using IOT Device Data Set (SAID).
Classification algorithm been used in this paper are Multilayer Perceptron (MLP), Decision Tree
(DT), K- Nearest Neighbour (KNN), Support Vector Machine (SVM) and Deep Learning (DL). The
dataset is split into two parts: 70% for training and 30% for research. The following subsection will
discuss the machine learning algorithms used in this experiment and how their parameters were set for
each classifier.
3.3.1. Multilayer Perceptron (MLP). MLP is the popular and mostly used in most research area. MLP
has input and will be transmitted inside MLP layer called as hidden layer in one direction to be classified
as output. There are no loops, thus it will not affect the output of each neurons. The parameter setting
for MLP is summarized below using Table 2.
Table 2. MLP Parameter Setting.
4
Asian Conference on Intelligent Computing and Data Sciences (ACIDS) 2021 IOP Publishing
Journal of Physics: Conference Series 1997 (2021) 012019 doi:10.1088/1742-6596/1997/1/012019
3.3.2. Decision Tree (DT). Decision tree builds classification models in the form of a tree structure. It
breaks down a dataset into smaller and smaller subsets while at the same time an associated decision
tree is incrementally developed. The final result is a tree with decision nodes and leaf nodes based on
their class dataset [3]. The parameter setting for DT is summarized below using Table 3.
3.3.3. K- Nearest Neighbour (KNN). KNN is a class membership where it will group the dataset based
on their classes whether it belong to group a or group b. KNN works by allocated data based on the
nearest neighbours which one is its k closest neighbours (k is a positive number and a small number). If
k = 1, then the data will be allotted to the group a or b based on closest neighbour [2]. Table 4 shows
parameter setting for KNN.
3.3.4. Support Vector Machine (SVM). SVM works upon the ideal hyper plane and still effective in high
dimensional spaces. In 2-Dimensional data, SVM will try to classify based on dataset classes [2]. Table
5 shows parameter setting for SVM.
3.3.5. Deep Learning (DL). Deep learning has many layers of the processing units for the input of the
dataset. Each layer has massive sub-layers of hidden layers. This algorithm is not only for supervised
but also applicable for unsupervised classification problem [3]. The deep learning layer architecture are
show in Figure 5 below:
5
Asian Conference on Intelligent Computing and Data Sciences (ACIDS) 2021 IOP Publishing
Journal of Physics: Conference Series 1997 (2021) 012019 doi:10.1088/1742-6596/1997/1/012019
_________________________________________________________________
dropout_59 (Dropout) (None, 100) 0
_________________________________________________________________
dense_404 (Dense) (None, 4) 404
=================================================================
Total params: 2,114
Trainable params: 2,114
Non-trainable params: 0
_________________________________________________________________
Figure 5. Deep learning layer architecture.
(1)
Accuracy =
(2)
Precision =
(3)
Recall =
∗ (4)
F1-Scorel =2x
Figure 6. Training/Testing and Cross Validation use in these experiments to overcome overfitting
problem.
6
Asian Conference on Intelligent Computing and Data Sciences (ACIDS) 2021 IOP Publishing
Journal of Physics: Conference Series 1997 (2021) 012019 doi:10.1088/1742-6596/1997/1/012019
In can be concluded that using Decision Tree give the best result compared to other machine learning
techniques. Decision Tree have several advantages such as the output are easy to read and assign specific
values to each problem, decision path and the outcome of the output. Based on the learning curve it also
show that using Decision Tree are suitable for this dataset where there is no underfitting and overfitting
cases when training the model using Decision Tree algorithm. From the previous study, Tiwari et.al,
2019 [12], using Artificial Neural Network as the classifier and getting result Mean of Accuracy 73.58%
and Standard Deviation of ANN model accuracy is 11.38%. From this, we can make a conclusion that
using other machine learning from our experiments are better compared to previous studies. By choose
a better classifier could improve the efficiency when training the model.
Figure 7. Learning curve for training (Cross Validation=10) and confusion matrix using
Decision Tree.
5. Conclusion
In this paper, it can conclude that using suitable classifier will get better result in accuracy, precision,
recall and F1-Score. From experiments results, it shows some significant value where DT achieved the
best resulting on accuracy 95%, precision 96%, recall 96% and F1-score 96%. The results prove that the
using DT has a competitive performance compared to the others classifiers for detecting stress and non-
stress and classifying stress levels. Further work can be done by using more classifier and applied 10-
fold cross validation.
Acknowledgment
This work is supported by Ministry of Education (MOE), Malaysia, Universiti Teknologi Malaysia
(UTM), Malaysia and “ASEAN- India Science & Technology Development Fund (AISTDF)”, SERB,
Sanction letter no. – IMRC/AISTDF/R&D/P-6/2017. This paper is financially supported by University
Grant No. 04G48. The authors would like to express their deepest gratitude to all researchers in IITA
Allahabad for their support in providing the SAID datasets to ensure the success of this research, as well
as School of Computing, Faculty of Engineering for their continuous support in making this research
possible.
7
Asian Conference on Intelligent Computing and Data Sciences (ACIDS) 2021 IOP Publishing
Journal of Physics: Conference Series 1997 (2021) 012019 doi:10.1088/1742-6596/1997/1/012019
References
[1] Palmer S 1989 The Health and Safety Practitioner, 8 16-18
[2] Ahuja R and Banga A 2019 International Conference on Pervasive Computing Advances and
Applications – PerCAA 2019 125 349-353
[3] Bobade P and Vani M 2020 Proceedings of the Second International Conference on Inventive
Research in Computing Applications (ICIRCA-2020) 51-58
[4] Vaikole S Mulajkar S More A Jayaswal P and Dhas S 2020 International Journal of Creative
Research Thoughts (IJCRT) 8 5 2239-44
[5] Schmidt P Reiss A Duerichen R Marberger C and Laerhoven K V 2018 Proceedings of the 20th
ACM International Conference on Multimodal Interaction 400-408
[6] Padmaja B Rama Prasad V V and Sunitha K V N 2018 International Journal of Machine Learning
and Computing 8 1 33-38
[7] Pandey P S 2017 2017 17th International Conference on Computational Science and Its
Applications (ICCSA)
[8] Ghaderi A Frounchi J and Farnam A 2015 22nd Iranian Conference on Biomedical Engineering
(ICBME) 93-98
[9] Sandulescu V Andrews S Ellis D Bellotto N and Mozos O M 2015 International Work-Conference
on the Interplay Between Natural and Artificial Computation 526-532
[10] Zhang X Xu C Xue W Hu J He Y and Gao M 2018 Sensors 2018 18 11 3886
[11] Ferdinando H Ye L Seppӓnen T and Alasaarela E 2014 Australian Journal of Basic and Applied
Sciences. 8 14 50-55
[12] Tiwari S Agarwal S Muhammad Syafrullah and Adiyarta K 2019 Proc. EECSI 2019 - Bandung,
Indonesia 6 107-111
[13] Zainudin Z Shamsuddin S M and Hasan S 2019 The International Conference on Advanced
Machine Learning Technologies and Applications (AMLTA2019) 921 43-51