A comprehensive Machine Learning system that provides personalized health recommendations using hybrid AI algorithms and evidence-based medical guidelines.
HealthRec is a production-ready Machine Learning application that combines advanced algorithms with medical domain expertise to deliver personalized health recommendations. The system analyzes patient profiles and provides evidence-based suggestions for diet, exercise, and medical checkups.
- Hybrid AI System: Combines 6 ML algorithms (70%) with collaborative filtering (30%)
- Medical Evidence Integration: Recommendations based on WHO and CDC guidelines
- Real-time Personalization: <100ms prediction time with 85-92% accuracy
- Scalable Architecture: Handles thousands of patient profiles efficiently
- 6 ML Algorithms: Random Forest, SVM, Neural Networks, Gradient Boosting, KNN, Logistic Regression
- Multi-Output Classification: Simultaneous prediction of diet, exercise, and checkup recommendations
- Feature Importance Analysis: Identifies key health factors affecting recommendations
- Cross-Validation: Robust model evaluation with multiple metrics
- 5,000 Synthetic Patients: Realistic health profiles with medical correlations
- 15+ Features: Age, BMI, blood pressure, glucose, cholesterol, lifestyle factors
- Evidence-Based Labels: Medical guideline-backed recommendations
- Balanced Representation: Diverse population demographics and health conditions
- Interactive Interface: Real-time recommendation generation
- Confidence Scoring: Reliability metrics for each recommendation
- Similar Patient Analysis: Find and learn from comparable cases
- Responsive Design: Works on desktop, tablet, and mobile devices
- Comprehensive Documentation: Algorithm explanations and API references
- Jupyter Notebooks: Interactive analysis and model exploration
- Performance Evaluation: Detailed metrics and comparison studies
- Reproducible Research: Seed-controlled experiments and methodology
- Python 3.8+ (tested with Python 3.13)
- Git
- 4GB+ RAM recommended
# Clone the repository
git clone https://github.com/YEdraoui/HealthRec.git
cd HealthRec
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run setup (generates data and trains models)
python setup.py# Streamlit interface (recommended)
streamlit run frontend/app.py
# Or Flask API
python frontend/flask_app.py# Run complete demonstration
python demo.py
# Explore with Jupyter
jupyter notebook notebooks/graph TB
A[Patient Data Input] --> B[Feature Engineering]
B --> C[ML Model Ensemble]
C --> D[Collaborative Filtering]
D --> E[Hybrid Recommendation Engine]
E --> F[Confidence Scoring]
F --> G[Final Recommendations]
H[Synthetic Data Generator] --> I[5000 Patient Profiles]
I --> J[Training Dataset]
J --> C
K[Medical Guidelines] --> L[Evidence-Based Rules]
L --> E
HealthRec/
βββ π src/ # Core ML system
β βββ healthrec_ml_system.py # Main system implementation
β βββ data_generator.py # Synthetic data generation
β βββ model_trainer.py # ML model training
β βββ predictor.py # Prediction interface
β βββ evaluator.py # Model evaluation
βββ π frontend/ # Web interfaces
β βββ app.py # Streamlit interface
β βββ flask_app.py # Flask API
β βββ templates/ # HTML templates
βββ π notebooks/ # Jupyter analysis
β βββ 01_data_exploration.ipynb
β βββ 02_model_training.ipynb
β βββ 03_evaluation.ipynb
βββ π tests/ # Unit tests
βββ π docs/ # Documentation
βββ π config/ # Configuration files
βββ π data/ # Generated datasets
βββ π models/ # Trained ML models
βββ π results/ # Evaluation results
βββ π requirements.txt # Dependencies
βββ π setup.py # Automated setup
βββ π demo.py # Demonstration script
| Model | Diet F1-Score | Exercise F1-Score | Checkup F1-Score | Overall |
|---|---|---|---|---|
| Random Forest | 0.892 | 0.876 | 0.923 | 0.897 |
| Gradient Boosting | 0.885 | 0.869 | 0.918 | 0.891 |
| Neural Network | 0.871 | 0.854 | 0.901 | 0.875 |
| SVM | 0.863 | 0.847 | 0.895 | 0.868 |
| Logistic Regression | 0.847 | 0.831 | 0.882 | 0.853 |
| KNN | 0.834 | 0.818 | 0.867 | 0.840 |
- β‘ Prediction Time: <100ms per patient
- π Dataset Size: 5,000 synthetic patients
- π― Accuracy Range: 85-92% across recommendation types
- π§ Features: 15+ health and demographic indicators
- Data Generation: Realistic health correlations (BMIβdiabetes, ageβhypertension)
- Feature Engineering: Categorical encoding, normalization, one-hot encoding
- Model Training: 6 algorithms with hyperparameter optimization
- Evaluation: Cross-validation, multiple metrics, statistical significance
- Deployment: Real-time prediction API with confidence scoring
- ML Component (70%): Evidence-based model predictions
- Collaborative Filtering (30%): Similar patient behavior patterns
- Fusion Strategy: Weighted combination with confidence adjustment
- DASH Diet: Hypertension management (AHA guidelines)
- Mediterranean Diet: Cardiovascular health (WHO recommendations)
- Exercise Prescriptions: 150min/week aerobic activity (CDC guidelines)
- Checkup Scheduling: Risk-based monitoring frequency
POST /api/predict
Content-Type: application/json
{
"age": 45,
"gender": "Male",
"bmi": 29.5,
"systolic_bp": 140,
"diastolic_bp": 90,
"glucose": 130,
"cholesterol": 220,
"smoking": 0,
"activity_level": "Moderate",
"family_history": 1,
"conditions": ["Hypertension", "High Cholesterol"]
}Response:
{
"recommendations": {
"diet": ["DASH", "Mediterranean"],
"exercise": ["Walking", "Swimming"],
"checkup": ["Quarterly"]
},
"confidence_scores": {
"diet": 0.89,
"exercise": 0.85,
"checkup": 0.92
},
"similar_users": [...]
}from src.predictor import HealthRecPredictor
# Initialize predictor
predictor = HealthRecPredictor()
# Patient profile
patient = {
'age': 55, 'gender': 'Female', 'bmi': 32.0,
'systolic_bp': 150, 'glucose': 140,
'conditions': ['Diabetes', 'Obesity']
}
# Get recommendations
recommendations = predictor.generate_hybrid_recommendations(patient)
print(recommendations)# Process multiple patients
patients = [patient1, patient2, patient3]
results = predictor.batch_predict(patients)import streamlit as st
from src.predictor import HealthRecPredictor
# Streamlit app
st.title("HealthRec Recommendations")
# ... interface code- Algorithm Documentation: Detailed technical explanations
- API Documentation: Complete endpoint reference
- Jupyter Notebooks: Interactive analysis and tutorials
- Setup Guide: Installation and configuration
# Run unit tests
python -m pytest tests/ -v
# Run specific test
python -m pytest tests/test_predictor.py -v
# Generate coverage report
python -m pytest tests/ --cov=src/ --cov-report=html# Build container
docker build -t healthrec .
# Run container
docker run -p 8501:8501 healthrec# Using Docker Compose
docker-compose up -d
# Using Heroku
git push heroku mainWe welcome contributions! Please see our Contributing Guidelines.
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
- LLM Integration: GPT-4 powered explanations
- Real Patient Data: FHIR-compliant data integration
- Mobile App: iOS/Android application
- Advanced Analytics: Longitudinal outcome tracking
- Multi-language: Internationalization support
- Clinical Validation: Healthcare provider partnerships
Perfect for:
- Machine Learning Coursework: Demonstrates advanced ML concepts
- Healthcare Informatics: Real-world medical AI application
- Software Engineering: Production-quality code and architecture
- Data Science Portfolio: End-to-end ML system development
- Research Projects: Reproducible methodology and evaluation
If you use HealthRec in your research, please cite:
@software{healthrec2024,
title={HealthRec: A Hybrid Machine Learning System for Personalized Health Recommendations},
author={Your Name},
year={2024},
url={https://github.com/YEdraoui/HealthRec}
}This project is licensed under the MIT License - see the LICENSE file for details.
- Yassir Edraoui - Project Creator
- Medical guidelines from WHO, CDC, and AHA
- Open-source ML community
- Healthcare AI research papers
- Synthetic data generation techniques
- GitHub Issues: Report bugs or request features
- Email: your.email@domain.com
- LinkedIn: Your LinkedIn Profile
β Star this repository if you found it helpful!
π Watch for updates and new features!
π΄ Fork to contribute your own improvements!
Built with β€οΈ for the healthcare and AI community