PCOS AI Assistant

Inspiration

Women across the world are affected by PCOS/PCOS now more than ever. It is a medical problem that produces symptoms and effects that scale from psychological disturbances to actual physical challenges. While medicines and therapy can control it, there is no real cure to it. As a result, too much effort needs to be put into battling it in all affected domains. Reach of proper care in different parts of the world is another major challenge. based on AI, way better to provide a more holistic and all-round approach. It's easier to reach, too, through an app and website. Medical professionals too can rely on their old patients' and many patients' data to provide advice.


Contributing Participants

This is a solo effort project by Shubhi Sharma. No other person has contributed to this submission.

What it does

The PCOS AI Assistant is an intelligent web app designed for three distinct user groups:

  • Patients → can input their symptoms and lab values to receive personalized counseling and lifestyle guidance.
  • Clinicians (doctors, healthcare providers) → can use the risk probability output and guideline-grounded suggestions to support diagnosis and management decisions.
  • Interns and medical trainees → get structured teaching-oriented recommendations and checklists to learn about PCOS workup and management.

Specifically, the app:

  • Accepts patient details such as age, BMI, lab values, menstrual history, and clinical symptoms.
  • Uses a trained classifier to compute the probability of PCOS and categorize risk into low, medium, or high.
  • Retrieves evidence-based suggestions from guidelines using a retrieval-augmented generation (RAG) pipeline.
  • Generates tailored counseling using an LLM (Ollama) adapted for the selected audience type (patient, clinician, intern).
  • Provides an interactive follow-up flow where medium/high-risk users get further targeted questions and updated recommendations.
  • Runs in a professional-looking web UI with form-based input and chat-style counseling.

How we built it

  • Collected and cleaned the Kaggle PCOS dataset.
  • Built and trained a logistic regression classifier with sklearn to predict PCOS risk.
  • Exposed the model through a Flask REST API (/predict, /counsel, /counsel-interactive).
  • Designed a RAG pipeline with guidelines.csv containing management suggestions linked to risk bands and symptom tags.
  • Integrated an LLM via Ollama (phi3:mini) to convert structured suggestions into conversational counseling.
  • Built a React (Vite) frontend with:
    • Landing page + form to enter patient details.
    • Results panel showing risk, probability, and suggested actions.
    • Chat-style interface for interactive counseling.
  • Styled the UI for a professional medical assistant feel with branding and logos.

Challenges we ran into

  • Dataset limitations: not all Rotterdam criteria were present; required careful preprocessing and imputation.
  • Classifier sensitivity: when too few fields were provided, the model defaulted to “low risk.” Solved with median filling and testing on complete patient rows.
  • LLM integration: Ollama timeouts and model availability issues; added fallback modes to ensure consistent responses.
  • Feature alignment: patient JSON inputs had to exactly match trained model feature names — caused repeated debugging cycles.
  • Frontend polish: transforming a basic form UI into an interactive assistant experience.

Accomplishments that we're proud of

  • Successfully combined ML + RAG + LLM into a unified assistant pipeline.
  • Built a system that works for patients, clinicians, and interns — different tones and purposes from the same backend.
  • Made the assistant interactive, with follow-up questioning for medium/high-risk cases.
  • Delivered a professional web UI that feels like a real medical assistant rather than just a demo script.
  • Integrated open-source tools (Ollama, sklearn, Flask, React) into a cohesive end-to-end system.

What we learned

  • How to build an end-to-end AI product from dataset → classifier → API → LLM → frontend.
  • The importance of data preprocessing and feature normalization in clinical datasets.
  • How to design a retrieval-augmented pipeline that grounds an LLM in authoritative sources.
  • The challenges of frontend-backend integration when field names, formats, and ports don’t align.
  • How to adapt language tone and style for different users (patient, clinician, intern).

What's next for PCOS Assistant Agent

  • Expand the dataset with more clinical features (hormones, imaging results).
  • Extend the app to interact with the user in elaborate human language instead of proceeding with just yes/no questions to counsel
  • Integrate explainable AI (feature importance) to show why a patient is flagged at risk.
  • Add more management pathways into RAG (e.g., fertility treatment options, dermatology care, endocrinology referrals).
  • Deploy on cloud for scalability and multi-user access.
  • Build a mobile app version for direct patient use.
  • Extend to other women’s health conditions beyond PCOS.
    -Make the RAG database more thorough to improve the accuracy of couselling.

Architecture

Components

  1. Classifier (classifier.py)

    • Logistic Regression trained on Kaggle PCOS dataset.
    • Outputs risk probability and classification.
  2. Backend API (app.py)

    • Flask server exposing ML + RAG + LLM.
  3. RAG Retriever (rag.py + guidelines.csv)

    • Supplies structured suggestions from guidelines.
  4. LLM Integration (assistant.py)

    • Builds counseling prompts and calls Ollama.
  5. Frontend (React via Vite)

    • Form input + chat interface for users.

Pipeline Flow

flowchart TD
    User -->|Enter details| UI
    UI --> API[/Flask API/]
    API --> Classifier
    Classifier -->|risk + probability| API
    API --> RAG[Retriever]
    RAG --> LLM
    LLM -->|Counseling| UI

Built With

Share this project:

Updates