2025

COVID-19 mortality risk — logistic regression from scratch, and a negative result

Logistic regression written from scratch in NumPy — sigmoid, cross-entropy and hand-derived gradients. It scored 75.82% accuracy against a 75.63% baseline, which is to say it learned almost nothing.

PythonNumPyPandasfrom scratch

written from scratch, on purpose

No scikit-learn in the model — the cost function and both partial derivatives are hand-derived. StandardScaler is the only thing borrowed, and only because unscaled age dominates the gradient and skews the cost surface.

the result

75.82% accuracy against a 75.63% majority-class baseline. Recall 2.35%: it found 27 of 1,148 deaths.

Accuracy looks respectable and is almost entirely the baseline. On the metric that matters clinically, the model had learned almost nothing.

diagnosed rather than buried

Severe class imbalance, no class weighting, threshold left at 0.5. Written up in the README as unsuitable for clinical use, because it is.

A model that reports 75.82% accuracy and stops there is a misleading result. The interesting part of this project is the gap between the number that flatters it and the number that condemns it.

all workjosh beira