plot graphs for stress detection

parent a7474ea4
#!/usr/bin/env python
# coding: utf-8
# In[18]:
#import libraies
import pandas as pd
import numpy as np
import matplotlib.pyplot as plot
import seaborn as sb
import seaborn as sns
# In[2]:
#insert data set
data=pd.read_csv("C:\\Users\\USER\\Downloads\\archive (1)\\SaYoPillow.csv")
# In[3]:
data.head()
# In[5]:
data.shape
# In[6]:
#renameing the columns
data.columns=['snoring_rate', 'respiration_rate', 'body_temperature', 'limb_movement', 'blood_oxygen', 'eye_movement', 'sleeping_hours', 'heart_rate', 'stress_level']
# In[7]:
data.head()
# In[10]:
sorted(data.stress_level.unique())
# In[11]:
data.stress_level.value_counts()
# In[12]:
print("Average amount of sleep (median):",data.sleeping_hours.median())
# In[13]:
print("Average amount of stress (median):",data.stress_level.median())
# In[14]:
#checking for nulls
# In[15]:
if not data.isnull().values.any():
print("Done!!!")
else:
print("(((")
# In[16]:
#make a simple plots
# In[23]:
sleep_hours_plot = sns.lineplot(data=data, x='stress_level',y='sleeping_hours',color='red')
sleep_hours_plot.axes.set_title("Dependence of stress level on sleep hours", fontsize=16)
sleep_hours_plot.set_xlabel("Stress level", fontsize=14)
sleep_hours_plot.set_ylabel("Sleep hours", fontsize=14)
# In[22]:
heart_rate_plot = sns.lineplot(data=data, x='stress_level',y='sleeping_hours', color='green')
heart_rate_plot.axes.set_title("Dependence of stress level on heart rate", fontsize=16)
heart_rate_plot.set_xlabel("Stress level", fontsize=14)
heart_rate_plot.set_ylabel("Heart rate", fontsize=14)
# In[ ]:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment