Skip to content
Will Tran - Sleep Quality Analysis
0
  • AI Chat
  • Code
  • Report
  • SleepInc: Helping you find better sleep 😴

    📖 Background

    Your client is SleepInc, a sleep health company that recently launched a sleep-tracking app called SleepScope. The app monitors sleep patterns and collects users' self-reported data on lifestyle habits. SleepInc wants to identify lifestyle, health, and demographic factors that strongly correlate with poor sleep quality. They need your help to produce visualizations and a summary of findings for their next board meeting! They need these to be easily digestible for a non-technical audience!

    Executive Summary

    Objective: Analyze SleepInc's user data to identify factors influencing sleep quality.

    Data: Sleep and lifestyle data for 374 individuals, covering demographics, sleep metrics, health indicators, and lifestyle factors.

    Key Findings:

    • Age range of participants: 27-59 years; average age ~42.
    • Average sleep duration: ~7.1 hours; range: 5.8-8.5 hours.
    • Average sleep quality rating: ~7.3 (scale 1-10).
    • Physical activity, and stress levels also analyzed.

    Analysis Techniques:

    • Basic statistical analysis of sleep-related metrics.
    • Demographic, lifestyle, and health factor correlations with sleep quality.
    • Visualization of data, focusing on age group, occupation, and sleep disorders.

    Recommendations:

    • Focus on demographics and lifestyle habits that correlate with poor sleep for targeted interventions.
    • Utilize findings to enhance app functionality and user guidance.
    !pip install skimpy==0.0.6
    import skimpy
    import pandas as pd
    import seaborn as sns
    import matplotlib.pyplot as plt
    
    raw_data = pd.read_csv('sleep_health_data.csv')
    print(raw_data)
    Hidden output
    #check for null/duplicates and get summary from data
    skimpy.skim(raw_data)

    Numerical Data Summary

    Age

    The participants range from 27 to 59 years old, with an average age of approximately 42 years.

    Sleep Duration

    The average sleep duration is about 7.1 hours, with a range from 5.8 to 8.5 hours.

    Quality of Sleep

    On average, participants rate their sleep quality at around 7.3 (scale not specified), with a range from 4 to 9.

    Physical Activity Level

    The average physical activity level is approximately 59 (scale not specified), ranging from 30 to 90.

    Stress Level

    The average stress level is around 5.4 (scale not specified), with a range from 3 to 8.

    Heart Rate

    The average heart rate is about 70 beats per minute, ranging from 65 to 86 bpm.

    Daily Steps

    Participants take an average of about 6,800 steps per day, with a range from 3,000 to 10,000 steps.

    Analysis Plan

    Basic Statistics: Examine basic statistics for key variables, especially 'Sleep Duration' and 'Quality of Sleep', to understand the overall sleep health of the dataset.

    Demographic Analysis: Explore how sleep health varies with demographic factors like age, gender, and BMI category.

    Lifestyle and Health Analysis: Investigate the relationship between sleep health and factors like physical activity level, stress level, and heart rate.

    Occupation and Sleep Disorders: Examine how occupation and reported sleep disorders relate to sleep health.

    Visualizations: Where applicable, we will create visualizations to help illustrate the findings.

    Basic Statistics of Sleep-Related Variables

    Sleep Duration Stats:

    • Average Sleep Duration: 7.13 hours
    • Min Sleep Duration: 5.8 hours
    • Max Sleep Duration: 8.5 hours

    Sleep Quality Stats:

    • Average Sleep Quality: 7.31
    • Min Sleep Quality: 4
    • Max Sleep Quality: 9

    These initial statistics provide a baseline understanding of the sleep health in the dataset.

    The average sleep duration is within the recommended range (7-9 hours), and the average sleep quality seems relatively high. However, the minimum values indicate that some individuals are experiencing poor sleep health.

    Hidden code overall_analysis

    Demographic Analysis

    Next, let's explore how these sleep health indicators vary across different demographic factors like age, gender, and BMI category.

    Let's start with an analysis by gender.

    Sleep Health by Gender

    Male Participants:

    • Average Sleep Duration: 7.04 hours
    • Average Sleep Quality: 6.97

    Female Participants:

    • Average Sleep Duration: 7.23 hours
    • Average Sleep Quality: 7.66

    From this analysis, it appears that female participants, on average, experience slightly longer and better-quality sleep compared to male participants.

    Unknown integration
    DataFrameavailable as
    gender
    variable
    --sleep health by gender
    SELECT 
        Gender,
        ROUND(AVG("Sleep Duration"),2) as avg_sleep_duration, 
        ROUND(AVG("Quality of Sleep"),2) as avg_sleep_quality
    FROM 
        'sleep_health_data.csv'
    GROUP BY 
        Gender;

    Sleep Health by Age Groups

    It's interesting to note that the youngest age group (20s) has the lowest average sleep duration and quality.

    The sleep duration and quality seem to improve with age, with the 50s age group reporting the highest values for both.

    Sleep Duration

    • Increasing Sleep Duration with Age: The median sleep duration increase with age, particularly in the 50s age group. This could indicate a greater prioritization, or possibly changes in lifestyle and work commitments that allow for longer sleep times.
    • Variability: The 50s age group shows more variability in sleep duration compared to other age groups, as indicated by the larger interquartile range. This might suggest a wider range of sleep patterns or health conditions influencing sleep among individuals in this age group.

    Quality of Sleep

    • Improvement in Sleep Quality with Age: There is a clear trend of improved sleep quality ratings in older age groups. The 50s age group, in particular, has a notably higher median sleep quality rating compared to younger groups. This could imply that older individuals either experience better quality sleep or perhaps have better sleep hygiene practices.
    • Reduced Variability in Older Age: The 50s age group shows less variability in sleep quality (narrower interquartile range) than the younger age groups, suggesting more consistency in sleep quality among older individuals.

    Conclusions

    • Changes in Sleep Patterns with Age: Both sleep duration and quality appear to be influenced by age, with older adults (especially those in their 50s) generally experiencing longer and better-quality sleep. This could be due to a variety of factors, including lifestyle changes, retirement, or biological changes associated with aging.
    • Potential Health Implications: Good quality sleep is crucial for overall health. The improvement in sleep quality with age might be beneficial for the overall health of older adults. However, it's important to consider that individual sleep needs and patterns can vary widely, and these observations are based on aggregate data.
    • Consideration of Other Factors: While the data shows trends, it's important to consider other factors that might influence sleep, such as health conditions, stress levels, lifestyle, and occupation, which could also change with age.
    Hidden code age_group