Skip to content

Repository files navigation

Relevant Priors

A lightweight, fully local service that decides which prior imaging exams are worth showing a radiologist while they read a current exam. Given a current study and a list of the patient's prior studies, it returns a relevance prediction for each prior.

The model is a hand-engineered feature stack (string similarity, anatomy/modality buckets, time deltas) feeding a calibrated logistic regression — no hosted LLM calls, so inference is fast and runs anywhere scikit-learn does.

Why

Radiology worklists often attach a long tail of prior exams to each case. Most are irrelevant to the question being read. Surfacing only the relevant priors saves reading time and reduces clutter. This project is a compact, reproducible baseline for that relevance-ranking problem.

How it works

Component Choice
Features 12-dim mix of token/trigram Jaccard, anatomy overlap, modality match, substring flags, SequenceMatcher ratio, and time deltas between exams
Classifier StandardScaler + LogisticRegression (class_weight="balanced", C=0.3, LBFGS)
Threshold Tuned on out-of-fold predictions via 5-fold GroupKFold (grouped by patient_id), bundled with the pipeline
Serving FastAPI + Uvicorn, fully local inference

See experiments.md for the full experiment log, ablations, and ideas for improvement.

Results (public split)

Metric Value
5-fold grouped OOF accuracy (tuned threshold) 0.912
Positive rate in labels ~0.266

(In-sample on public labels; treat as optimistic versus a held-out private split.)

Quickstart

pip install -r requirements.txt

# Run the API locally
uvicorn priors_relevance.api:app --reload --port 8080

The service exposes:

  • POST /predict (and POST /) — relevance predictions for a case
  • GET /health — health check
  • GET / — service metadata

Train

python train_model.py --data relevant_priors_public.json \
  --out priors_relevance/artifacts/model_bundle.joblib

Evaluate against public labels

python eval_public.py   # requires relevant_priors_public.json in the working dir

Docker

docker build -t relevant-priors .
docker run -p 8080:8080 relevant-priors
# health check: GET http://localhost:8080/health

The container listens on port 8080.

Project layout

priors_relevance/
  api.py          # FastAPI app + prediction handlers
  features.py     # feature engineering for (current, prior) pairs
  artifacts/      # bundled model (pipeline + threshold)
train_model.py    # train + threshold search, writes model_bundle.joblib
eval_public.py    # score predictions against public truth labels
experiments.md    # experiment log and notes

License

MIT © 2026 TheOnlyJason

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages