An intelligent health prediction system that uses machine learning to diagnose vitamin deficiency-related diseases based on symptoms and health metrics.
Vitamin deficiencies are a silent epidemic affecting millions worldwide, often going undiagnosed until serious health complications arise. We recognized that early detection could prevent conditions like anemia, night blindness, rickets, and scurvy. Our goal was to create an accessible, AI-powered diagnostic tool that empowers individuals to understand their health risks and seek timely medical intervention.
This application combines machine learning with modern web technologies to predict vitamin deficiency diseases based on lifestyle and symptoms.
User Input Fields:
- Demographics: Age, Gender, BMI
- Lifestyle: Diet Preference, Smoking Status, Alcohol Consumption, Exercise Level, Sun Exposure
- Symptoms: Night Blindness, Fatigue, Bleeding Gums, Bone Pain, Muscle Weakness, Numbness/Tingling, Memory Problems, Pale Skin
Conditions Detected:
- Anemia
- Night Blindness
- Rickets/Osteomalacia
- Scurvy
- Beriberi
- Pellagra
- Healthy (no deficiency)
Backend:
- FastAPI: High-performance Python web framework for API development
- SQLAlchemy: ORM for database management
- PostgreSQL: Robust relational database for user data
- scikit-learn: Machine learning library for model training
- joblib: Model serialization and deployment
- JWT: Secure authentication tokens
Frontend:
- Next.js 16: React framework with server-side rendering
- TypeScript: Type-safe development
- Tailwind CSS: Utility-first styling
- Framer Motion: Smooth animations
- Supabase Client: Authentication and real-time features
Machine Learning Pipeline:
- Data preprocessing and cleaning
- Feature engineering (symptom encoding, age groups, BMI categories)
- Multiple model experiments (Random Forest, Gradient Boosting, XGBoost)
- Hyperparameter tuning for optimal performance
- Label encoding for disease classification
DevOps:
- Git version control
- Environment-based configuration
- Ready for deployment on Heroku/Railway
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Next.js β βββββββΊ β FastAPI β βββββββΊ β PostgreSQL β
β Frontend β REST β Backend β ORM β Database β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β
βΌ
ββββββββββββββββ
β ML Models β
β (joblib) β
ββββββββββββββββ
-
Model Accuracy: Initial models struggled with class imbalance. We addressed this through:
- SMOTE (Synthetic Minority Over-sampling Technique)
- Weighted class balancing
- Feature engineering to capture symptom combinations
-
Real-time Authentication: Integrating Supabase JWT verification with FastAPI required careful middleware implementation to validate tokens server-side
-
Feature Alignment: Ensuring the frontend form submissions matched the exact feature schema expected by the trained model
-
Deployment Considerations: Packaging ML models efficiently and managing environment variables across development and production
- β Built a full-stack ML application from scratch in hackathon timeframe
- β Achieved high prediction accuracy on validation dataset
- β Created a responsive, accessible user interface
- β Implemented secure authentication and data persistence
- β Developed comprehensive Jupyter notebooks documenting the entire ML pipeline
- β Production-ready deployment configuration
- ML Model Deployment: Transitioning from Jupyter notebooks to production APIs
- Feature Engineering: The critical importance of proper data preprocessing
- Type Safety: How TypeScript catches errors early in the development cycle
- User Experience: Balancing technical accuracy with an intuitive interface
- Health Data Privacy: Best practices for handling sensitive medical information
- Enhanced Predictions: Add probability scores and confidence intervals
- Recommendation Engine: Suggest dietary changes and vitamin supplements
- Visualization: Interactive charts showing symptom patterns and trends
- Multi-language Support: Reach global audiences
- Mobile App: Native iOS/Android applications
- Doctor Integration: Connect users with healthcare professionals
- Model Improvements: Incorporate deep learning for better accuracy
- Health Tracking: Monitor vitamin levels over time
- Python 3.11+
- Node.js 18+
- PostgreSQL 14+
- Virtual environment tool (venv/conda)
# Navigate to project root
cd Vitamin-Deficiency-Disease-Prediction
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export SUPABASE_URL="your_supabase_url"
export SUPABASE_SERVICE_ROLE_KEY="your_service_role_key"
export DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
export ALLOWED_ORIGINS="http://localhost:3000"
# Run the backend
cd backend
uvicorn main:app --reload --port 8000# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Set environment variables (.env.local)
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key
NEXT_PUBLIC_API_URL=http://localhost:8000
# Run development server
npm run dev# Navigate to ML directory
cd ml/notebooks
# Launch Jupyter
jupyter notebook
# Run notebooks in order:
# 1. 00_data_form_validation.ipynb
# 2. 01_eda.ipynb
# 3. 02_feature_analysis.ipynb
# 4. 03_model_experiments.ipynb- Sign Up/Login: Create an account or log in with existing credentials
- Access Dashboard: Navigate to the prediction form
- Enter Health Data:
- Basic info: Age, Gender, BMI
- Lifestyle: Diet, smoking, alcohol, exercise, sun exposure
- Symptoms: 8 yes/no symptom questions
- Get Prediction: Submit to receive instant disease prediction
- View Results: See predicted condition and confidence score
POST /predict- Get disease predictionGET /health- Health check endpointPOST /save-state- Save user health stateGET /get-state- Retrieve user health history
Lifestyle factors (diet, smoking, alcohol, exercise, sun exposure)
- Symptom profiles (8 key symptomsset containing:
- Patient demographics (age, gender, BMI)
- Symptom profiles (22+ symptoms)
- Vitamin levels (A, B1, B3, B12, C, D, Iron)
- Disease labels (6 vitamin deficiency conditions + healthy)
We welcome contributions! Please see our DEPLOYMENT.md and TESTING.md for more details.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ at an MLH Hackathon
- Major League Hacking for hosting incredible hackathons
- Supabase for authentication infrastructure
- scikit-learn community for excellent ML tools
- Health professionals who inspired this project