Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Mental Health Prediction Using Deep Learning

Project Overview

This comprehensive project implements multiple machine learning and deep learning approaches to predict mental health status based on technology usage patterns and lifestyle factors. The project explores various models including traditional ML algorithms, ensemble methods, and advanced neural networks to classify mental health into four categories: Excellent, Good, Fair, and Poor.

Dataset

Mental Health and Technology Usage 2024 dataset contains behavioral and lifestyle data:

  • Total samples: ~10,000 records
  • Features: Technology usage, lifestyle, and demographic factors
  • Target: Mental Health Status (4 classes)
  • Format: CSV with mixed numerical and categorical features

Feature Categories:

Technology Usage

  • Technology_Usage_Hours
  • Social_Media_Usage_Hours
  • Gaming_Hours
  • Screen_Time_Hours

Health & Lifestyle

  • Sleep_Hours
  • Physical_Activity_Hours
  • Stress_Level (Low/Medium/High)

Demographics & Support

  • Age, Gender
  • Support_Systems_Access (Yes/No)
  • Work_Environment_Impact (Positive/Neutral/Negative)
  • Online_Support_Usage (Yes/No)

Target Variable

  • Mental_Health_Status: Excellent(0), Good(1), Fair(2), Poor(3)

Model Architectures

1. Deep Neural Networks

Standard Neural Network

NeuralNet:
├── Linear(input_size128) + BatchNorm + ReLU + Dropout(0.3)
├── Linear(12864) + BatchNorm + ReLU + Dropout(0.3)
├── Linear(6432) + BatchNorm + ReLU + Dropout(0.3)
└── Linear(324)  # 4 mental health classes

Advanced Neural Network

AdvancedNN:
├── Linear(input_size384) + BatchNorm + ReLU
├── Linear(384256) + BatchNorm + ReLU + Dropout(0.3)
├── Linear(256128) + BatchNorm + ReLU + Dropout(0.3)
├── Linear(12864) + BatchNorm + ReLU + Dropout(0.3)
├── Linear(6432) + BatchNorm + ReLU
└── Linear(324)

2. Traditional ML Models

  • Random Forest: Ensemble of decision trees
  • Gradient Boosting: Sequential weak learner improvement
  • XGBoost: Optimized gradient boosting with GPU support
  • LightGBM: Fast gradient boosting framework
  • CatBoost: Categorical feature handling
  • SVM: Support Vector Machine with RBF kernel
  • Logistic Regression: Multinomial classification
  • KNN: K-Nearest Neighbors
  • Extra Trees: Extremely randomized trees

3. Ensemble Methods

  • Voting Classifier: Soft voting across multiple models
  • Feature Extraction + ML: Deep features + traditional ML
  • Advanced Ensemble: Best performing models combination

Implementation Details

Data Preprocessing Pipeline

1. Missing Value Handling

# Numerical features: Median imputation
# Categorical features: Mode imputation
# Advanced: Domain-specific imputation strategies

2. Feature Encoding

# Label Encoding: Categorical variables
# One-Hot Encoding: Gender, Work Environment Impact
# Ordinal Encoding: Stress Level (Low=0, Medium=1, High=2)
# Binary Encoding: Support access variables

3. Feature Scaling

# StandardScaler: Mean=0, Std=1 normalization
# MinMaxScaler: 0-1 range normalization
# Applied to: Age, usage hours, activity hours

4. Feature Engineering

# Derived Features:
├── Total_Screen_Time = Tech + Social + Gaming hours
├── Screen_to_Sleep_Ratio = Screen_Time / Sleep_Hours
├── Activity_to_Screen_Ratio = Physical / Screen_Time
├── Health_Balance = (Sleep + Activity) / (Total_Tech + 1)
├── Stress_WorkImpact_Interaction = Stress × Work_Impact
└── Age_Category = Binned age groups

Training & Evaluation

Training Configuration

  • Train/Test Split: 80/20 stratified split
  • Cross-Validation: 5-fold CV for model selection
  • Batch Size: 64 (Neural Networks)
  • Epochs: 100-1000 with early stopping
  • GPU Acceleration: CUDA support for compatible models

Hyperparameter Optimization

# Grid Search CV for traditional ML
# Optuna optimization for XGBoost
# Manual tuning for neural networks
# Ensemble weight optimization

Performance Metrics

  • Accuracy: Overall classification accuracy
  • F1-Score: Weighted F1 for class imbalance
  • Classification Report: Precision, recall per class
  • Confusion Matrix: Detailed error analysis

Key Features

1. Comprehensive Data Analysis

# Statistical analysis:
├── Correlation analysis
├── Chi-square tests for categorical variables
├── Feature importance ranking
├── Distribution analysis by mental health status
└── Visualization suite (heatmaps, bar plots, box plots)

2. Advanced Feature Selection

# Multiple selection strategies:
├── SelectKBest (f_classif)
├── Recursive Feature Elimination (RFE)
├── Random Forest feature importance
└── Correlation-based filtering

3. Model Comparison Framework

# Systematic evaluation:
├── Multiple algorithm comparison
├── Hyperparameter optimization
├── Cross-validation results
├── Performance visualization
└── Best model selection

4. Production-Ready Pipeline

# Complete workflow:
├── Data validation and cleaning
├── Automated preprocessing
├── Model training and selection
├── Prediction generation
└── Results interpretation

Project Structure

Titanic---Machine-Learning-from-Disaster/
├── Titanic---Machine-Learning-from-Disaster.ipynb
├── README.md
├── .gitignore
└── README.md

Usage

Prerequisites

pip install torch tensorflow scikit-learn xgboost lightgbm catboost
pip install pandas numpy matplotlib seaborn optuna

Running the Analysis

1. Data Exploration

# Comprehensive EDA:
├── Missing value analysis
├── Class distribution visualization
├── Feature correlation analysis
├── Statistical significance testing
└── Relationship exploration

2. Model Training

# Multi-model approach:
├── Traditional ML with GridSearchCV
├── Neural networks with PyTorch/TensorFlow
├── Ensemble methods
└── Performance comparison

3. Evaluation & Selection

# Model assessment:
├── Cross-validation scores
├── Test set evaluation
├── Feature importance analysis
└── Best model identification

Technical Highlights

1. Advanced Neural Architecture

  • Batch Normalization: Accelerated training and stability
  • Dropout Regularization: Overfitting prevention
  • Progressive layer sizing: Optimal information flow
  • GPU Acceleration: CUDA optimization

2. Sophisticated Feature Engineering

# Complex feature interactions:
├── Ratio features: Screen/Sleep, Activity/Screen
├── Interaction terms: Stress × Work_Environment
├── Polynomial features: Screen_Time²
├── Categorical interactions: Age × Screen_Time
└── Domain-specific indicators: Excessive_Screen_Flag

3. Ensemble Intelligence

# Multiple ensemble strategies:
├── Simple voting: Equal weights
├── Weighted voting: Performance-based weights
├── Stacking: Meta-learner combination
└── Feature-based ensemble: Different feature subsets

4. Robust Evaluation Framework

# Comprehensive assessment:
├── Stratified cross-validation
├── Multiple random seeds
├── Statistical significance testing
└── Confidence interval estimation

Results & Insights

Model Performance Ranking:

  1. Ensemble Methods: Highest accuracy and robustness
  2. XGBoost/LightGBM: Strong individual performance
  3. Neural Networks: Good with proper regularization
  4. Random Forest: Reliable baseline performance

Key Insights:

  • Technology usage patterns strongly correlate with mental health
  • Sleep and physical activity are crucial protective factors
  • Work environment significantly impacts mental wellbeing
  • Support systems show measurable benefits

Feature Importance:

  1. Screen_Time_Hours
  2. Sleep_Hours
  3. Stress_Level
  4. Physical_Activity_Hours
  5. Social_Media_Usage_Hours

Future Improvements

1. Advanced Architectures

  • Transformer models for sequence modeling
  • Graph Neural Networks for relationship modeling
  • Attention mechanisms for feature importance
  • Multi-modal learning for diverse data types

2. Enhanced Features

  • Temporal patterns: Time-series analysis
  • Social network data: Relationship patterns
  • Biomarker integration: Physiological data
  • External factors: Weather, economic indicators

3. Deployment Optimizations

  • Model compression: Pruning and quantization
  • Edge deployment: Mobile/IoT optimization
  • Real-time inference: Streaming predictions
  • Explainable AI: SHAP/LIME integration

Dependencies

Core Libraries:

  • PyTorch/TensorFlow: Deep learning frameworks
  • Scikit-learn: Traditional ML algorithms
  • XGBoost/LightGBM/CatBoost: Gradient boosting
  • Pandas/NumPy: Data manipulation
  • Matplotlib/Seaborn: Visualization

Specialized Tools:

  • Optuna: Hyperparameter optimization
  • SHAP: Model interpretability
  • Imbalanced-learn: Class imbalance handling
  • PyCaret: Automated ML pipeline

Key Achievements

  • Multi-algorithm comparison across 10+ models
  • Advanced feature engineering with domain expertise
  • Comprehensive ensemble methods implementation
  • GPU-accelerated training for efficiency
  • Production-ready pipeline with full automation
  • Statistical rigor with proper validation
  • Interpretable results with feature importance analysis

Learning Outcomes

This project demonstrates:

  • End-to-End ML Pipeline: Complete workflow implementation
  • Model Selection Strategy: Systematic algorithm comparison
  • Feature Engineering Expertise: Domain-driven feature creation
  • Ensemble Methods: Advanced combination techniques
  • Deep Learning: Modern neural network architectures
  • Statistical Analysis: Rigorous evaluation methodology

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages