Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

78 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ Vitamin Deficiency Disease Prediction

An intelligent health prediction system that uses machine learning to diagnose vitamin deficiency-related diseases based on symptoms and health metrics.

Built with FastAPI Frontend: Next.js ML: scikit-learn

🌟 Inspiration

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.

πŸ’‘ What It Does

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)

πŸ› οΈ How We Built It

Tech Stack

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

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Next.js    β”‚ ◄─────► β”‚   FastAPI    β”‚ ◄─────► β”‚  PostgreSQL  β”‚
β”‚   Frontend   β”‚  REST   β”‚   Backend    β”‚   ORM   β”‚   Database   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚  ML Models   β”‚
                         β”‚  (joblib)    β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🚧 Challenges We Ran Into

  1. 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
  2. Real-time Authentication: Integrating Supabase JWT verification with FastAPI required careful middleware implementation to validate tokens server-side

  3. Feature Alignment: Ensuring the frontend form submissions matched the exact feature schema expected by the trained model

  4. Deployment Considerations: Packaging ML models efficiently and managing environment variables across development and production

πŸ† Accomplishments We're Proud Of

  • βœ… 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

πŸ“š What We Learned

  • 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

πŸš€ What's Next

  • 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

🎯 Installation & Setup

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • PostgreSQL 14+
  • Virtual environment tool (venv/conda)

Backend Setup

# 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

Frontend Setup

# 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

ML Model Training (Optional)

# 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

πŸ“– Usage

  1. Sign Up/Login: Create an account or log in with existing credentials
  2. Access Dashboard: Navigate to the prediction form
  3. Enter Health Data:
    • Basic info: Age, Gender, BMI
    • Lifestyle: Diet, smoking, alcohol, exercise, sun exposure
    • Symptoms: 8 yes/no symptom questions
  4. Get Prediction: Submit to receive instant disease prediction
  5. View Results: See predicted condition and confidence score

πŸ”— API Endpoints

  • POST /predict - Get disease prediction
  • GET /health - Health check endpoint
  • POST /save-state - Save user health state
  • GET /get-state - Retrieve user health history

πŸ“Š Dataset

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)

🀝 Contributing

We welcome contributions! Please see our DEPLOYMENT.md and TESTING.md for more details.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Team

Built with ❀️ at an MLH Hackathon

πŸ™ Acknowledgments

  • Major League Hacking for hosting incredible hackathons
  • Supabase for authentication infrastructure
  • scikit-learn community for excellent ML tools
  • Health professionals who inspired this project

⚠️ Medical Disclaimer: This application is for educational purposes only and should not replace professional medical advice. Always consult with healthcare providers for proper diagnosis and treatment.

About

An intelligent health prediction system that uses machine learning to diagnose vitamin deficiency-related diseases based on symptoms and health metrics.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages