Sleep Health and Lifestyle
This synthetic dataset contains sleep and cardiovascular metrics as well as lifestyle factors of close to 400 fictive persons.
The workspace is set up with one CSV file, data.csv
, with the following columns:
Person ID
Gender
Age
Occupation
Sleep Duration
: Average number of hours of sleep per dayQuality of Sleep
: A subjective rating on a 1-10 scalePhysical Activity Level
: Average number of minutes the person engages in physical activity dailyStress Level
: A subjective rating on a 1-10 scaleBMI Category
Blood Pressure
: Indicated as systolic pressure over diastolic pressureHeart Rate
: In beats per minuteDaily Steps
Sleep Disorder
: One ofNone
,Insomnia
orSleep Apnea
Check out the guiding questions or the scenario described below to get started with this dataset! Feel free to make this workspace yours by adding and removing cells, or editing any of the existing cells.
Source: Kaggle
🌎 Some guiding questions to help you explore this data:
- Which factors could contribute to a sleep disorder?
- Does an increased physical activity level result in a better quality of sleep?
- Does the presence of a sleep disorder affect the subjective sleep quality metric?
📊 Visualization ideas
- Boxplot: show the distribution of sleep duration or quality of sleep for each occupation.
- Show the link between age and sleep duration with a scatterplot. Consider including information on the sleep disorder.
🔍 Scenario: Automatically identify potential sleep disorders
This scenario helps you develop an end-to-end project for your portfolio.
Background: You work for a health insurance company and are tasked to identify whether or not a potential client is likely to have a sleep disorder. The company wants to use this information to determine the premium they want the client to pay.
Objective: Construct a classifier to predict the presence of a sleep disorder based on the other columns in the dataset.
Check out our Linear Classifiers course (Python) or Supervised Learning course (R) for a quick introduction to building classifiers.
SELECT *
FROM 'data.csv'
LIMIT 10
First to answer that question. Which factors could contribute to asleep disorder?
We take Gender, Age, Occupation, sleep Duration with Quality of Sleep level and let's see how these factors affect the level of Quality ofSleep.
-- Get Person ID, gender, Age, Occupation with Quality of Sleep
SELECT "Person ID", Gender, Age, Occupation, "Quality of Sleep"
FROM 'data.csv'
WHERE "Quality of Sleep" > 4 AND "Quality of Sleep" <= 8
ORDER BY "Person ID"
In previous table sleep periods range from 5 to 6 hours for all jobs.
What the Occupation do the owners sleep 8 hours
-- Find the number of people sleeping 8 hours.
SELECT "Person ID", Gender, Age, Occupation, "Quality of Sleep"
FROM 'data.csv'
WHERE "Quality of Sleep" = 8
ORDER BY 'Person ID';
import plotly.express as px
fig = px.bar(data_frame=df2, x="Occupation", y="Quality of Sleep", color="Age", title="The number of people sleeping 8 hours")
fig.show()
In previous bar plot most of those who sleep 8 ours are lawyers.
Because most lawyers work during the day.
Now we will see if the duration of sleep and amount of sleep and strees level it's impact on daily activity.
-- Find the factors that affect physical activity level.
SELECT Occupation, "Sleep Duration", "Quality of Sleep", "Physical Activity Level", "Stress Level"
FROM "data.csv"
WHERE "Quality of Sleep" > 4 AND "Quality of Sleep" <= 8
AND ("Sleep Duration" > 5.9) AND ("Sleep Duration" < 7.9)
AND ("Stress Level" > 3) AND ("Stress Level" <= 8)
AND ("Physical Activity Level" > 30) AND ("Physical Activity Level" <= 75)
ORDER BY "Quality of Sleep" DESC;
# Create bos plot to display the minimum, first quartil, median, third quartile and maximum.
import plotly.express as px
fig = px.box(data_frame=df3, x="Occupation", y="Physical Activity Level", hover_data=["Sleep Duration", "Quality of Sleep", "Stress Level"], title="Box plot to declear some factors of Activity level")
fig.show()
Let's take this two factors Physical Activity Level and Stress Level with Occupation to see if that jobs are effected by this two factors.