Skip to content

Repository files navigation

TIDALHack — Natural Language Symptom Diagnostic

A full-stack medical diagnosis assistant that maps free-form symptom descriptions to structured disease predictions. Natural language input is parsed by a Groq-hosted Llama 3 70B LLM into a controlled symptom vocabulary, then classified by a trained XGBoost model. The front end is a Streamlit web app.

Architecture

User types symptoms (free text)
        │
        ▼
┌───────────────────────┐
│  Streamlit UI         │  chatbot2.py
│  (chatbot2.py)        │
└──────────┬────────────┘
           │ text
           ▼
┌───────────────────────┐
│  processor.py          │
│                       │
│  process_symptoms()   │
│     ┌─────────────┐   │
│     │ Groq API    │   │  →  LLM extracts top 3 symptoms
│     │ (Llama 3    │   │     from controlled vocabulary
│     │  70B)       │   │     of 73 known symptoms
│     └─────────────┘   │
│           │           │
│           ▼           │
│  Symptom names  ───>  │  →  one-hot encoded vector (73-dim)
│                       │
│  inference()          │
│     ┌─────────────┐   │
│     │ XGBoost     │   │  →  predicts disease class label
│     │ classifier  │   │     (41 diseases)
│     └─────────────┘   │
└──────────┬────────────┘
           │ disease name
           ▼
┌───────────────────────┐
│  Streamlit UI         │
│  shows diagnosis      │
└───────────────────────┘

Tech Stack

Layer Technology
Frontend Streamlit
LLM Provider GroqCloudllama3-groq-70b-8192-tool-use-preview
ML Classifier XGBoost — gradient boosted trees
Serialization Joblib
Numerical NumPy

Project Structure

├── chatbot.py                   # Prototype UI (no inference wired — deprecated)
├── chatbot2.py                  # Production Streamlit app
├── processor.py                 # Core logic: NL → vector → disease prediction
├── requirements.txt             # Python dependencies
├── 20241020-DiseasePredictionModelDump.joblib   # Trained XGBoost model
└── data/
    ├── dataset.csv              # Training data (4921 rows, 41 diseases × 17 symptoms)
    ├── symptom_Description.csv  # Disease descriptions (unused — available for enrichment)
    └── symptom_precaution.csv   # Precaution recommendations (unused — available for enrichment)

Setup

Prerequisites

Quick start

# Clone and enter the repo
cd TIDALHack

# Create a virtual environment
python -m venv venv && source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Set your API key
export GROQ_API_KEY="gsk_..."

Edit processor.py to remove the hardcoded key on line 8 and use os.environ.get("GROQ_API_KEY").

Run

streamlit run chatbot2.py

Model

The XGBoost classifier was trained on a dataset of 41 diseases with up to 17 symptoms each. The model accepts a 73-element binary vector (one per symptom in the controlled vocabulary) and outputs one of 41 disease labels:

Vertigo, Acne, AIDS, Alcoholic hepatitis, Allergy, Arthritis, Bronchial Asthma, Cervical spondylosis, Chicken pox, Chronic cholestasis, Common Cold, Dengue, Diabetes, Dimorphic hemorrhoids (piles), Drug Reaction, Fungal infection, Gastroenteritis, GERD, Heart attack, Hepatitis A–E, Hyperthyroidism, Hypoglycemia, Hypertension, Hypothyroidism, Impetigo, Jaundice, Malaria, Migraine, Osteoarthritis, Paralysis (brain hemorrhage), Peptic ulcer disease, Pneumonia, Psoriasis, Tuberculosis, Typhoid, Urinary tract infection, Varicose veins.

Controlled Symptom Vocabulary (73)

The LLM is constrained to extract symptoms from this fixed list — any symptom outside it is ignored:

abdominal_pain, acidity, altered_sensorium, anxiety, back_pain, blackheads, bladder_discomfort, blister, bloody_stool, blurred_and_distorted_vision, breathlessness, bruising, burning_micturition, chest_pain, chills, cold_hands_and_feets, constipation, continuous_feel_of_urine, continuous_sneezing, cough, cramps, dark_urine, dehydration, diarrhoea, dischromic_patches, dizziness, extra_marital_contacts, fatigue, foul_smell_ofurine, headache, high_fever, hip_joint_pain, indigestion, joint_pain, knee_pain, lethargy, loss_of_appetite, loss_of_balance, mood_swings, movement_stiffness, muscle_wasting, muscle_weakness, nausea, neck_pain, nodal_skin_eruptions, obesity, pain_during_bowel_movements, pain_in_anal_region, patches_in_throat, pus_filled_pimples, red_sore_around_nose, restlessness, scurring, shivering, silver_like_dusting, skin_peeling, skin_rash, spinning_movements, stiff_neck, stomach_pain, sunken_eyes, sweating, swelling_joints, swelling_of_stomach, ulcers_on_tongue, vomiting, watering_from_eyes, weakness_in_limbs, weakness_of_one_body_side, weight_gain, weight_loss, yellowish_skin, itching

About

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages