Using machine learning and explainable AI to explore dietary factors associated with type 2 diabetes: a cross-sectional study from the UK NDNS

Introduction Limited studies have applied machine learning and explainable artificial intelligence (XAI) methods to identify dietary factors associated with type 2 diabetes mellitus (T2DM) but none in UK populations. We conducted an exploratory cross-sectional analysis of the UK National Diet and Nutrition Survey (NDNS) data to explore dietary factors alongside anthropometric and demographic measures. Methods Data from NDNS years 1–11 (2008–2019) were analysed for 4460 adults (251 with self-reported T2DM); 24 dietary variables, including total energy intake, age, sex, ethnicity, body mass index and waist circumference were included in the model. K-nearest neighbour (KNN), decision tree (DT), random forest (RF) and XGBoost models were trained on dietary, anthropometric and demographic variables. Performance was reported per class with 95% CIs. Feature importance and model interpretability were assessed using permutation feature importance, SHAP and LIME. Results RF (ROC-AUC 0.77, 95% CI 0.71 to 0.83; diabetic-class recall 0.24, 95% CI 0.12 to 0.36) and XGBoost (ROC-AUC 0.77, 95% CI 0.70 to 0.83; diabetic-class recall 0.34, 95% CI 0.21 to 0.48) achieved comparable performance, both outperforming KNN and DT. Age, waist circumference and BMI were the variables most strongly associated with T2DM classification. Among dietary variables, dietary sugars (free and total) and refined starchy carbohydrates (pasta, rice and other cereals) were most consistently linked to T2DM prevalence. However, SHAP indicated that higher sugar intake was associated with classification towards the non-diabetic class, consistent with reverse causation typical in cross-sectional studies. Most other food groups made small, directionally inconsistent contributions. Conclusion Using machine learning (RF and XGBoost) with explainable AI, this study examined the dietary factors most associated with T2DM classification in NDNS. The cross-sectional design, self-reported T2DM status and predominantly white sample (93%) limit causal inference and generalisability. These dietary associations are therefore hypothesis-generating. Future studies should examine these dietary factors prospectively in larger, more ethnically diverse and externally validated cohorts.

Authors

Institutions

Publication Details

Journal
BMJ Nutrition Prevention & Health
Published
2026-09-04
DOI
https://doi.org/10.1136/bmjnph-2026-001522
Primary Topic
Nutritional Studies and Diet
Type
article
Field-Weighted Citation Impact
0.00

Funders

Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Using machine learning and explainable AI to explore dietary factors associated with type 2 diabetes: a cross-sectional study from the UK NDNS

Grace Farhat, Shokooh Khandan, Matthew Allward
BMJ Nutrition Prevention & Health
Nutritional Studies and Diet
article

Using machine learning and explainable AI to explore dietary factors associated with type 2 diabetes: a cross-sectional study from the UK NDNS

Grace Farhat, Shokooh Khandan, Matthew Allward
article en

Abstract

Introduction Limited studies have applied machine learning and explainable artificial intelligence (XAI) methods to identify dietary factors associated with type 2 diabetes mellitus (T2DM) but none in UK populations. We conducted an exploratory cross-sectional analysis of the UK National Diet and Nutrition Survey (NDNS) data to explore dietary factors alongside anthropometric and demographic measures. Methods Data from NDNS years 1–11 (2008–2019) were analysed for 4460 adults (251 with self-reported T2DM); 24 dietary variables, including total energy intake, age, sex, ethnicity, body mass index and waist circumference were included in the model. K-nearest neighbour (KNN), decision tree (DT), random forest (RF) and XGBoost models were trained on dietary, anthropometric and demographic variables. Performance was reported per class with 95% CIs. Feature importance and model interpretability were assessed using permutation feature importance, SHAP and LIME. Results RF (ROC-AUC 0.77, 95% CI 0.71 to 0.83; diabetic-class recall 0.24, 95% CI 0.12 to 0.36) and XGBoost (ROC-AUC 0.77, 95% CI 0.70 to 0.83; diabetic-class recall 0.34, 95% CI 0.21 to 0.48) achieved comparable performance, both outperforming KNN and DT. Age, waist circumference and BMI were the variables most strongly associated with T2DM classification. Among dietary variables, dietary sugars (free and total) and refined starchy carbohydrates (pasta, rice and other cereals) were most consistently linked to T2DM prevalence. However, SHAP indicated that higher sugar intake was associated with classification towards the non-diabetic class, consistent with reverse causation typical in cross-sectional studies. Most other food groups made small, directionally inconsistent contributions. Conclusion Using machine learning (RF and XGBoost) with explainable AI, this study examined the dietary factors most associated with T2DM classification in NDNS. The cross-sectional design, self-reported T2DM status and predominantly white sample (93%) limit causal inference and generalisability. These dietary associations are therefore hypothesis-generating. Future studies should examine these dietary factors prospectively in larger, more ethnically diverse and externally validated cohorts.

BMJ Nutrition Prevention & Health
Manchester Metropolitan University (GB)
University College London, Public Health England, Medical Research Council
Zero hunger
Openalex Percentile: Top 8%
Nutritional Studies and Diet
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.