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.
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.
| 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.
| 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.)
pip install -r requirements.txt
# Run the API locally
uvicorn priors_relevance.api:app --reload --port 8080The service exposes:
POST /predict(andPOST /) — relevance predictions for a caseGET /health— health checkGET /— service metadata
python train_model.py --data relevant_priors_public.json \
--out priors_relevance/artifacts/model_bundle.joblibpython eval_public.py # requires relevant_priors_public.json in the working dirdocker build -t relevant-priors .
docker run -p 8080:8080 relevant-priors
# health check: GET http://localhost:8080/healthThe container listens on port 8080.
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
MIT © 2026 TheOnlyJason