A small, fully reproducible lab that shows how I build and evaluate a clinical machine-learning model, and how I run data-science analytics on clinical-style data. Everything uses synthetic, seeded data, so it runs anywhere with no private patient information.
-
Modeling (
clinlab.train,clinlab.evaluate)- Leakage-safe pipeline (scaler fit inside cross-validation folds).
- 5-fold stratified cross-validation and a small grid search over logistic-regression and random-forest baselines; model selection by cross-validated ROC-AUC.
- Held-out test metrics: accuracy, precision, recall, F1, ROC-AUC, and Brier score for calibration, plus a best-F1 threshold search and an error analysis of the most confident wrong predictions.
-
Clinical analytics (
clinlab.analytics, via DuckDB SQL)- Overall outcome summary (improvement and readmission rates).
- Subgroup rates by age group.
- A treatment A/B comparison (standard vs intervention) with a two-proportion z-test.
- Data-quality gates (null and duplicate IDs, invalid arms, admission-logic violations).
-
Serving (
clinlab.api)- A FastAPI
/predictendpoint that loads the trained model bundle and returns a probability.
- A FastAPI
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest -q # run the tests
python scripts/run_training.py # train, evaluate, write artifacts/metrics.json
python scripts/run_analytics.py # run the SQL analytics suite
uvicorn clinlab.api:app --reload # serve /health and /predictThe dataset is synthetic and generated by scikit-learn's make_classification; feature names are
clinical only for readability. See reports/MODEL_CARD.md. This is an engineering and evaluation
reference, not a clinically valid model, and must not be used for patient care.
MIT - see LICENSE.