Skip to content

Repository files navigation

Sleep Health and Lifestyle Analysis

This Streamlit application analyzes sleep health data and predicts sleep quality using machine learning models. The application implements both L1 (Lasso) and L2 (Ridge) regularized linear regression models from scratch.

Project Structure

  • Introduction.py: Main entry point for the Streamlit application
  • pages/: Directory containing the application pages
    • 0_Explore_&_Preprocess.py: Data exploration and preprocessing
    • 1_Train_&_Evaluate.py: Model training with hyperparameter tuning and evaluation
    • 2_Deploy.py: Model deployment and sleep quality prediction
  • helper_functions.py: Utility functions for the application
  • Sleep_health_and_lifestyle_dataset.csv: Original dataset
  • Preprocessed_Sleep_Health_Dataset.xlsx: Preprocessed dataset
  • PAML data preprocessing.ipynb: Jupyter notebook for data preprocessing
  • assets/: Directory containing images and other assets

Features

  • Data Exploration and Preprocessing:

    • Interactive data visualization (histograms, boxplots, scatterplots, correlation heatmaps)
    • Feature engineering and preprocessing (one-hot encoding, scaling, outlier handling)
    • PCA for dimensionality reduction
  • Model Training:

    • Implementation of L1 (Lasso) and L2 (Ridge) regularized linear regression from scratch
    • Interactive hyperparameter tuning (learning rate, iterations, regularization strength)
    • Train/validation/test split with customizable proportions
  • Model Evaluation:

    • Performance metrics: MAE, RMSE, and R²
    • Visualization of actual vs. predicted values
    • Feature importance analysis
  • Model Deployment:

    • Interactive form for entering personal lifestyle and health information
    • Prediction of sleep quality using the trained regression model

Installation

  1. Clone the repository:
git clone <repository-url>
cd <repository-directory>
  1. Install the required packages:
pip install -r requirements.txt

Usage

  1. Run the Streamlit application:
streamlit run Introduction.py
  1. Navigate through the application:
    • Start with the Introduction page to understand the project
    • Go to "Explore & Preprocess" to analyze and preprocess the dataset
    • Train and evaluate models in the "Train & Evaluate" page
    • Use the "Deploy" page to input personal data and receive a sleep quality prediction

Dataset

The application uses the Sleep Health and Lifestyle Dataset, which contains information about:

  • Sleep duration and quality
  • Physical activity levels
  • Stress levels
  • BMI categories
  • Blood pressure
  • Heart rate
  • Daily steps
  • Sleep disorders (insomnia, sleep apnea)

Model Parameters

  • Learning Rate: Controls the step size in gradient descent (default: 0.01)
  • Number of Iterations: Number of training iterations (default: 1000)
  • Regularization Strength (lambda): Controls the strength of L1/L2 regularization (default: 0.1)

Data Split

The dataset is split into:

  • Training set (default: 55%)
  • Validation set (default: 15%)
  • Test set (default: 30%)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages