Predicting HIV viral non-suppression in Uganda: development and validation of machine learning and risk stratification models using routine EMR data
Background Viral non-suppression is the primary actionable risk state in routine HIV care, yet most individuals are identified after virological failure and/or drug resistance, rather than proactively. In Uganda and similar resource-limited settings, routine electronic medical records (EMR) are collected at scale but remain underused for targeted, data-enabled risk stratification. We aimed to develop and internally validate machine learning and regularized regression models for predicting viral non-suppression using routine monitoring data. Methods We developed and internally validated prediction models for viral non-suppression (viral load ≥1,000 copies/mL) using routinely recorded EMR variables from the TASO Uganda open cohort (2014–2024; n = 33,384). Twenty variables were used across four models: logistic regression (LR), elastic net regularized logistic regression (ENET), random forest (RF), and extreme gradient boosting (XGB), evaluated on a stratified 80:20 test set. Precision-recall AUC (PR-AUC) was the primary metric; ROC-AUC, Brier score, and decision curve analysis were assessed; bootstrap 95% CIs (2,000 replicates) were computed for discrimination metrics. Results On the test set (n = 6,677), RF achieved PR-AUC 0.248 (95% CI 0.207–0.291) and ROC-AUC 0.758 (0.732–0.780); ENET achieved PR-AUC 0.237 (0.198–0.279) and ROC-AUC 0.750 (0.726–0.772); confidence intervals overlapped across all four models. RF and ENET achieved Brier scores of 0.055 (8% below the null of 0.060) and maximum net benefit of 0.055 in decision curve analysis. At the capacity-first threshold (top 5% predicted risk), RF flagged 325 individuals (4.9%; PPV 0.338, NPV 0.949) and ENET flagged 334 (5.0%; PPV 0.305, NPV 0.948). Current ART class (PI-based: OR 11.07; NNRTI-based: OR 4.80), poor adherence (OR 7.71), TB history (OR 2.08), and male sex (OR 1.62) were the strongest predictors. Conclusions Routine EMR data support meaningful, calibrated viral non-suppression risk prediction across a large, multi-site Ugandan HIV program. At a capacity-first threshold, both models achieved approximately five-fold enrichment over background prevalence, with clinical utility confirmed by decision curve analysis. Prospective external validation and workflow integration are required before deployment.