Learning from the machine: is diabetes in adults predicted by lifestyle variables? A retrospective predictive modelling study of NHANES 2007–2018 - Efrain Riveros Perez; Bibiana Avella-Molano (BMJ Open)
Objectives This study aimed to compare the performance of five machine learning algorithms to predict diabetes mellitus based on lifestyle factors (diet and physical activity).Design Retrospective cross-sectional predictive modelling study.Setting This study was conducted using publicly available data from the National Health and Nutrition Examination Survey (NHANES), a nationally representative survey designed to assess the health and nutritional status of the US population.Participants We analysed data from 29 509 non-pregnant adults who participated in NHANES between 2007 and 2018.Primary and secondary outcome measures The primary outcome was the prediction of type 2 diabetes mellitus (T2DM) by self-reported responses based on machine learning models. The performance of five machine learning algorithms (logistic regression, support vector machine, random forest, XGBoost and CatBoost) was evaluated using accuracy, sensitivity, specificity, positive predictive value, negative predictive value, and the area under the receiver operating characteristic curve (AUC). The secondary outcome measures were feature importance and model performance comparison.Results XGBoost exhibited the highest overall predictive performance (AUC 0.8168), followed by random forest and logistic regression (AUCs around 0.79). In terms of accuracy, logistic regression, XGBoost and random forest performed similarly at approximately 85%. While most models demonstrated high specificity (>97%), the SVM stood out for having the highest sensitivity (58.57%), although with a lower accuracy (62.44%). This trade-off underscores the strength of SVM in identifying more true-positive cases, though at the cost of lower overall classification precision. The random forest model, despite having lower sensitivity (7.15%), provided one of the most balanced performances in terms of specificity and interpretability.Conclusion The results support the use of machine learning models, particularly XGBoost, for early identification of individuals at risk for T2DM. Despite their limited sensitivity, the high specificity and accuracy underscore these models’ potential for non-invasive risk assessment. This study is innovative in its integration of machine learning algorithms to predict type 2 diabetes based solely on non-invasive, easily accessible lifestyle and anthropometric variables, demonstrating the potential of data-driven models for early risk assessment without requiring laboratory tests. Despite the lower sensitivity observed in most models, their high specificity makes them valuable for early screening in clinical and public health settings, where they can be complemented with follow-up assessments or ensemble approaches that optimise the balance between sensitivity and specificity for improved risk stratification.