Skip to content

Repository files navigation

Sleep Health A/B Testing Project

A data science project analyzing the impact of sleep duration on health outcomes using real-world lifestyle data. We conduct exploratory data analysis (EDA) and apply A/B testing to investigate correlations and statistically significant differences across groups.


Project Summary

  • Cleaned and analyzed a dataset of 374 individuals
  • Explored trends using histograms, pie charts, and correlation heatmaps
  • Applied Welch's t-test to compare health outcomes between:
  • Treatment group: Sleep ≥ median hours
  • Control group: Sleep < median hours

Sample EDA Visuals

Sleep Duration Distribution

Stress Level Distribution

Sleep Disorder Category Breakdown

Correlation Matrix


A/B Testing

Participants were split based on median sleep duration:

  • Treatment Group: Sleep ≥ median
  • Control Group: Sleep < median

We tested whether sleep duration affects:

  • Stress Level
  • Heart Rate
  • Quality of Sleep
  • Physical Activity Level

Results were statistically tested using Welch's t-test.

Why Welch's T-Test?

We chose Welch's t-test over the standard Student's t-test because:

  • Unequal sample sizes between treatment and control groups
  • Different variances across health outcome variables
  • Welch’s t-test does not assume equal variance or group size
  • More robust for real-world, observational data like ours

A/B Test Results

We split the dataset into two groups based on median sleep duration and ran Welch’s t-test on each key metric:

Metric T-statistic P-value Significant
Stress Level -16.299 0.0000 Yes
Heart Rate -7.962 0.0000 Yes
Quality of Sleep 23.309 0.0000 Yes
Physical Activity Level 7.068 0.0000 Yes

A/B Test Impact Ranking

I ranked each metric based on the absolute value of the t-statistic — the higher the value, the stronger the observed effect from increased sleep duration.

Rank Metric T-statistic Interpretation
1 Quality of Sleep 23.309 Most impacted — people who sleep more report dramatically higher sleep quality.
2 Stress Level -16.299 Strong inverse relationship — more sleep means lower stress.
3 Heart Rate -7.962 Moderate effect — better sleep linked to lower resting heart rate.
4 Physical Activity Level 7.068 Still significant — slightly higher physical activity with more sleep.

Insights

  • Sleep Quality shows the strongest positive effect from longer sleep duration.
  • Stress Levels notably decrease with more sleep — highlighting mental health benefits.
  • Heart Rate and Activity Level also benefit, but with comparatively smaller effects.

Run It Yourself

  1. Clone the repo:

    git clone https://github.com/yourname/sleep-ab-test.git
    cd sleep-ab-test
    
  2. Add your kaggle.json file to the root.

  3. Install dependencies (recommended: uv):

    uv venv
    uv pip install -r pyproject.toml
    
  4. Run data download script:

    python src/download_data.py
    

Dataset

Sleep Health and Lifestyle Dataset – Kaggle

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages