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.
Introduction.py: Main entry point for the Streamlit applicationpages/: Directory containing the application pages0_Explore_&_Preprocess.py: Data exploration and preprocessing1_Train_&_Evaluate.py: Model training with hyperparameter tuning and evaluation2_Deploy.py: Model deployment and sleep quality prediction
helper_functions.py: Utility functions for the applicationSleep_health_and_lifestyle_dataset.csv: Original datasetPreprocessed_Sleep_Health_Dataset.xlsx: Preprocessed datasetPAML data preprocessing.ipynb: Jupyter notebook for data preprocessingassets/: Directory containing images and other assets
-
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
- Clone the repository:
git clone <repository-url>
cd <repository-directory>- Install the required packages:
pip install -r requirements.txt- Run the Streamlit application:
streamlit run Introduction.py- 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
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)
- 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)
The dataset is split into:
- Training set (default: 55%)
- Validation set (default: 15%)
- Test set (default: 30%)