Deep LearningPyTorchHealthcareResearch

Predicting Dementia Risk with PyTorch: A Gweru Cohort Study

How I compared PyTorch DNN and LSTM models estimating dementia risk from 24,000 clinical records, with leakage control and reproducible artifacts.

Tinotenda Linton
3 min read
Predicting Dementia Risk with PyTorch: A Gweru Cohort Study

Dementia screening is a data problem before it is a clinical one. This research project trains deep learning models to estimate dementia probability in adults aged 60 and over, using a clinical cohort of 24,000 records with 35 columns collected in Gweru, Zimbabwe between 2020 and 2025. This post covers the data, the architectures, and the actual numbers.

The data is messy on purpose

The cohort arrives deliberately noisy: five different interview-date formats, categorical label chaos ("Rual", "Urbn", "maried"), per-column missingness from 0.5% to 12.8%, blood-pressure transposition errors, and about 7% of records under the age-60 protocol threshold. Raw dementia prevalence sits at 38.2%; after cleaning, 24,000 rows become 22,855 (1,145 rejected — 90 with unverifiable ages, 1,055 protocol violations) with a 40.0% event rate.

The 35 columns follow the Lancet Commission 2024 modifiable-factor set: demographics, vascular markers (systolic/diastolic BP, diabetes, prior stroke), sensory deficits, sleep problems, physical activity, depression screening (GDS-15), cognitive screen scores, and more — each documented with type, units, and clinical basis in a data dictionary.

Two architectures, one protocol

DNN architecture: 64-feature input, two hidden blocks with batch norm and dropout, sigmoid output — 6,465 parameters

  • DNN (primary) — a 64 → 64 → 32 → 1 MLP with BatchNorm, ReLU, and Dropout(0.2). Just 6,465 parameters. AdamW at lr 3e-4 with weight decay 1e-4, batch size 512, early stopping at epoch 17. Validation ROC-AUC: 0.8477.
  • LSTM (secondary) — tabular-as-sequence: 27 continuous/binary features pass through a shared linear layer with explicit missingness flags, 11 categoricals use size-16 embeddings with a dedicated "Missing" level, plus a learned feature-identity embedding — producing a 38×16 token sequence for a 2-layer LSTM (hidden 64). 55,985 parameters. Validation ROC-AUC: 0.8482.

LSTM architecture: 38 feature tokens, 2-layer LSTM with LayerNorm head — 55,985 parameters

The actual results

On the untouched hold-out set (n = 4,571, 1,830 events):

MetricDNNLSTM
ROC-AUC0.851090.85094
PR-AUC (chance = 0.40)0.780430.77857
Screening sensitivity0.8230.790
Screening specificity0.7340.776
Screening PPV0.6740.702

A bootstrap ΔAUC of +0.0001 (95% CI −0.0029 to +0.0033) says the discrimination is statistically identical. But McNemar's test on the frozen screening decisions (89 vs 144 discordant pairs, p = 0.0004) shows the models disagree at the operating point: the DNN catches more cases (recall 0.823), the LSTM raises fewer false alarms (PPV 0.702). Deployment reading: DNN for case-finding, LSTM when false alarms are costly.

Leakage control, explicitly

Three rules carried the analysis:

  1. cognitive_screen_score was quarantined from the predictor pool — it participates in how the outcome is ascertained
  2. Split-first preprocessing — imputation, standardisation, and one-hot encoding fitted on the training split only, after the stratified 80/20 split (seed 42)
  3. Thresholds and the isotonic calibrator were frozen on train out-of-fold predictions — the hold-out set was evaluated exactly once

Permutation importance puts age first (0.103), followed by a cognitive-reserve composite (age × education, 0.029) and sleep problems (0.009) — consistent with the epidemiology, which is reassuring. Subgroup ROC-AUCs hold steady across sex (0.845–0.860) and residence (0.847–0.859).

The honest caveats

The repo's newest document is a QA plan that lists its own limits: tuned-CV numbers may be slightly optimistic because selection folds were reused; the hold-out has now been inspected, so further analyses are exploratory; and the dataset's provenance (collected vs synthetic) is explicitly unresolved. A screening model you can't be honest about is worse than no model at all — the artifacts (checkpoints with MD5 sidecars, metrics JSON, hold-out predictions with sex and residence columns) are committed so every number above can be verified.