Development and validation of a machine learning model for prediction of type 2 diabetes in patients with mental illness
Authors: Bernstorff Martin , Hansen Lasse , Enevoldsen Kenneth , Damgaard Jakob , Hæstrup Frida , Perfalk Erik , Danielsen Andreas Aalkjær , Østergaard Søren Dinesen 
Published: September 2023

AbstractBackgroundType 2 diabetes (T2D) is approximately twice as common among individuals with mental illness compared with the background population, but may be prevented by early intervention on lifestyle, diet, or pharmacologically. Such prevention relies on identification of those at elevated risk (prediction). The aim of this study was to develop and validate a machine learning model for prediction of T2D among patients with mental illness.MethodsThe study was based on routinely collected data from electronic health records from the psychiatric services of the Central Denmark Region. A total of 74.880 patients with 1.59 million psychiatric service contacts were included in the analyses. We included 1343 potential predictors covering patient-level information on demographics, diagnoses, pharmacological treatment, and laboratory results. T2D was operationalized as HbA1c ≥48 mmol/mol, fasting plasma glucose >7.0 mmol/mol, oral glucose tolerance test ≥11.1 mmol/mol or random plasma glucose ≥11.1 mmol/mol. Two machine learning models (XGBoost and regularized logistic regression) were trained to predict T2D based on 85% of the included contacts. The predictive performance of the best performing model was tested on the remaining 15% of the contacts.FindingsThe XGBoost model detected patients at high risk 2.7 years before T2D, achieving an area under the receiver operating characteristic curve of 0.84. Of the 996 patients developing T2D in the test set, the model issued at least one positive prediction for 305 (31%).InterpretationA machine learning model can accurately predict development of T2D among patients with mental illness based on routinely collected data from electronic health records. A decision support system based on such a model may inform measures to prevent development of T2D in this high-risk population.FundingThe Lundbeck Foundation, the Central Denmark Region Fund for Strengthening of Health Science and the Danish Agency for Digitisation Investment Fund for New Technologies.Research in contextEvidence before this studyWe searched Pubmed for relevant studies regardless of time of publication using the search query “predict*” AND Diabetes Mellitus, Type 2 [Mesh] AND Mental Disorders [Mesh] AND Patients [Mesh]. We did not identify any studies developing T2D prediction models for patients with mental illness.Added value of this studyTo the best of our knowledge, this study is the first to develop and validate a machine learning model for prediction of T2D among patients with mental illness. The developed model is sensitive and specific - and detects patients at high risk 2.7 years before T2D. Notably, as only routinely collected data from electronic health records were used in the training of the model training, it can be assumed to have similar predictive performance if implemented in clinical practice. This study adds value by offering a T2D prediction model tailored specifically to patients with mental illness, which may facilitate early intervention and prevention strategies.Implications of all the available evidenceThe findings of this study, combined with the absence of existing T2D prediction models for patients with mental illness in the literature, offer a new possibility for identifying and potentially preventing T2D in a high-risk population. Specifically, implementing such a system in clinical practice may inform targeted interventions, such as lifestyle modifications (e.g., exercise and diet) and pharmacological treatment, to reduce the risk of T2D.