Skip to content
sifat2200Public

About

🩺 A full-stack PCOS screening and suggestion system with ML prediction, personalized recommendations, batch CSV analysis, and a modern medical dashboard.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

Repository files navigation

PCOSense β€” PCOS Detection & Suggestion Website

A deployable FastAPI + vanilla HTML/CSS/JavaScript website built around the schema and suggestion engine in the uploaded PCOS_Detection_and_Suggestion_System.ipynb.

The UI is designed as a medical-style dashboard: dark by default, light-blue accent system, responsive layout, multi-step screening, batch CSV analysis, model transparency, browser-only result saving, print report, and no patient-record database.

Important project limitation

The active notebook configuration uses a synthetic pcos_prediction_dataset.csv. The notebook's own signal audit reports that the target has no meaningful learnable signal. The website therefore treats the model as a research/demo screening component and clearly warns that the probability is not a clinical risk estimate.

For real clinical use, replace the training data with a validated clinical dataset and complete external validation, privacy/security review, clinical governance, and any required regulatory review.

Project structure

pcos_webapp/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.py
β”‚   β”œβ”€β”€ ml_service.py
β”‚   └── schemas.py
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html
β”‚   └── static/
β”‚       β”œβ”€β”€ app.js
β”‚       └── styles.css
β”œβ”€β”€ scripts/
β”‚   └── train_model.py
β”œβ”€β”€ data/
β”‚   └── pcos_prediction_dataset.csv   # put your source CSV here
β”œβ”€β”€ artifacts/
β”‚   └── model.joblib                  # generated after training
β”œβ”€β”€ .env.example
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.txt
└── README.md

Local launch β€” Windows

  1. Create a virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
  1. Install dependencies:
pip install -r requirements.txt
  1. Put your dataset at:
data\pcos_prediction_dataset.csv

The CSV needs the same active columns as the notebook, especially:

Age
BMI
Menstrual Regularity
Hirsutism
Acne Severity
Family History of PCOS
Insulin Resistance
Lifestyle Score
Stress Levels
Urban/Rural
Socioeconomic Status
Awareness of PCOS
Fertility Concerns
Undiagnosed PCOS Likelihood
Ethnicity
Diagnosis

Country may be present; the training pipeline drops it just like the notebook.

  1. Train the saved deployment artifact:
python scripts\train_model.py
  1. Launch the website:
uvicorn backend.app:app --host 0.0.0.0 --port 8000

Open http://127.0.0.1:8000.

FastAPI docs are available at http://127.0.0.1:8000/api/docs.

Docker launch

Put the dataset in data/pcos_prediction_dataset.csv, then:

docker build -t pcosense .
docker run --rm -p 8000:8000 pcosense

The image will train automatically at startup only when artifacts/model.joblib is missing and the dataset exists. For a production deployment, pre-train the artifact and bake it into the deployment image where appropriate.

Website features

Screening

The main screening flow is a 3-step form that mirrors the active notebook's pcos schema. It returns:

  • model probability and binary prediction
  • LOW / MODERATE / HIGH distribution-derived band
  • triggered notebook-style rule findings
  • grouped suggestions by domain
  • recommended next step
  • supportive non-diagnostic summary
  • model metrics and signal-gate status
  • printable report
  • browser-side JSON export

Batch analysis

Upload a CSV of up to 500 rows / 5 MB. The API validates the schema, runs the same prediction path per row, and returns a downloadable result CSV. The server does not persist the uploaded file.

Model & safety

Shows the saved classifier, augmentation method, rows used, evaluation metrics, signal-gate result, and NiWo diagnostics so the website can double as a project-demo dashboard.

API

GET /api/health

Returns server and model readiness.

GET /api/schema

Returns the form schema, options, and descriptions.

GET /api/model-info

Returns model metadata from the saved artifact.

POST /api/predict

Accepts the same feature names shown in the UI and returns a screening report.

POST /api/batch

Accepts a multipart CSV upload and returns row-level results.

POST /api/train

Retrains and replaces the saved artifact. Set TRAIN_TOKEN and send X-TRAIN-TOKEN in any remotely exposed deployment if this endpoint is enabled.

Notes on the notebook mapping

The backend preserves the active synthetic-dataset schema, fixed ordinal/binary mappings, train/test split, StandardScaler, the notebook's NiWo weighting logic, class-balance budget allocation, ROS-style augmentation, Random Forest deployment classifier, risk stratification concept, and the active synthetic rule-based suggestion categories.

The optional heavy Hugging Face NLP/LLM stack from the notebook is intentionally not a default runtime dependency because it makes a public web deployment much slower and more memory-intensive. The website's supportive-summary layer works without an LLM and can be replaced later with an approved local or hosted model behind a controlled provider interface.

Production hardening checklist

Before exposing a public domain to real users, add HTTPS at the hosting layer, authentication for any administrative training operation, centralized monitoring without storing patient inputs, rate limiting, a proper privacy notice, an audited clinical dataset, external validation, and a documented threat model. Do not store identifiable health information in browser localStorage for real patient deployments.

About

🩺 A full-stack PCOS screening and suggestion system with ML prediction, personalized recommendations, batch CSV analysis, and a modern medical dashboard.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages