Stress Detection from Sensor Data using Machine Learning

Stress is commonly defined as a feeling of strain and pressure which occurs from any event or thought that makes you feel frustrated, angry, or nervous. In the present situation, many people have succumbed to stress especially the adolescent and the working people. Stress increase nowadays leads to many problems like depression, suicide, heart attack, and stroke. The current technology, using Galvanic skin response (GSR), Heart rate variability (HRV), and Skin temperature are being used individually to detect stress.

In this project data set is created using five features age, gender, body temperature, heartbeat, and blood pressure, and four stages of labels are used for detecting the level of stress.  A decision tree algorithm is used to train the data set and create a model and use the Flask framework to take input data and predict the stress level of the user. 


 Existing systems were designed to detect stress by taking tweets as input from the Twitter or Facebook data set and machine learning algorithms are applied to detect stress from tweets.


  • Most of the existing system works were on social networking stress data not on body-based sensor data.
  • Stress level is calculated based on tweets posted by users.


The proposed system is designed by collecting data from sensors and preparing data set on three features (temperature, heartbeat, age, male or female). Using this data set machine learning Decision tree algorithm is applied using and the model is saved. Front end web application is designed to collect new user features and passed them to the model to predict stress stages which are divided into 4 stages.


  • Data is collected from real-time sensors and a data set is created for different ages and male and female users.
  • Data is trained using machine learning which helps automate the process of stress detection.
  • The web applications can help users to easily check their stress state based on their features.

Data collection:

  • In this state data is collected from real-time sensors and stored in an excel sheet with five features age, gender, temperature, heartbeat, and this data is applied for machine learning, and a model is created.

Data preprocessing:

  • Features are extracted from the data set and stored in the variable as train variable and labels are stored in y train variable. Data is preprocessing by standard scalar function and new features and labels are generated. 

Testing training:

  • In this stage, data is sent to the testing and training function and divided into four parts x test train, and y test train. Train variables are used for passing to the algorithm whereas tests are used for calculating the accuracy of the algorithm. 

Initializing Decision tree Algorithm:

  • In this stage, the decision tree algorithm is initialized and train values are given to the algorithm by this information algorithm will know what are features and label. Then data is modeled and stored as a pickle file in the system which can be used for prediction. 

Predict data:

  • In this stage, new data is taken as input and trained models are loaded using pickle and then values are preprocessed and passed to predict function to find out a result which is shown on the web application.


 Operating system:           Windows XP/7/10

  • Coding Language:           Html, JavaScript,  
  • Development Kit:        Flask Framework
  • IDE:           Anaconda prompt
  • Dataset:          Stress dataset

6 Replies to “Stress Detection from Sensor Data using Machine Learning”

  1. Sir iam poor family i want to submit my project . I need computer but i couldn’t have sir . In past 2 yrs i will use collage computer . During lockdown i should not unable to go college plzz counceder sir

Leave a Reply

Your email address will not be published. Required fields are marked *