King's College London

Research portal

Applying machine learning algorithms to electronic health records to predict pneumonia after respiratory tract infection

Research output: Contribution to journalArticlepeer-review

Original languageEnglish
Pages (from-to)154-163
Number of pages10
JournalJournal of Clinical Epidemiology
Early online date16 Jan 2022
E-pub ahead of print16 Jan 2022
PublishedMay 2022

King's Authors


Objectives: To predict community acquired pneumonia after respiratory tract infection (RTI) consultations in primary care by applying machine learning to electronic health records. Study design and Setting: A population-based cohort study was conducted using primary care electronic health records between 2002 to 2017. Sixteen thousand two hundred eighty-nine patients who consulted with RTIs then subsequently diagnosed with pneumonia within 30 days were compared with a random sample of eligible RTI patients. Variable selection compared logistic regression, random forest and penalized regression models. Prediction models were developed using classification and regression trees (CART) and logistic regression. Model performance was assessed through internal and temporal validations. Results: Older age, comorbidity, and initial presentation with lower respiratory tract infection (LRTIs) were identified as the main predictors of pneumonia diagnosis. Developed models achieved good discrimination accuracy with AUROC for the logistic regression model being 0.81 (0.80, 0.84) and 0.70 (0.69, 0.71) for CART during internal validation, and 0.80 (0.79, 0.81) vs. 0.68 (0.67, 0.69) for temporal validation. Conclusion: From a large number of candidate variables, a small number of predictors of pneumonia were consistently identified through machine learning variable selection procedures. Logistic regression generally provided better model performance than CART models.

View graph of relations

© 2020 King's College London | Strand | London WC2R 2LS | England | United Kingdom | Tel +44 (0)20 7836 5454