Abstract
BACKGROUND: Eating occasions (EOs) are important moments for dietary decision-making. Tailoring nutrition interventions to individuals’ behaviours and environmental contexts offers a promising way to modify eating habits at EOs and enhance diet quality. While machine learning (ML) is a useful tool for predicting behaviours, its potential in understanding food choices at EOs remains underexplored. This study uses ML to investigate whether contextual factors can predict food consumption at EOs and overall daily diet quality. METHODS: Cross-sectional data from the Measuring Eating in Everyday Life Study (MEALS) were analysed. Participants (18-30y, n = 675) recorded intakes for 3–4 non-consecutive days using a Smartphone food diary app. EO-level contextual factors at each EO were recorded via the app while person-level contextual factors were collected via an online survey. Intakes were calculated as servings of vegetables, fruits, grains, meat, dairy, and discretionary foods, in accordance with the Australian Dietary Guideline. Diet quality was assessed via Dietary Guideline Index (DGI, 0-120). Gradient boost decision tree and random forest algorithms were used for hurdle prediction models, with lowest mean absolute error (MAE) as best performing. Mean absolute SHapley Additive exPlanations (SHAP) values were used to interpret the impact of each factor in explaining food consumption predictions. RESULTS: Predictive models performed robustly, with MAE below half a serving for various food groups: 0.3 servings for vegetables, 0.75 for fruit, 0.28 for dairy, 0.55 for grains, 0.4 for meat, and 0.68 for discretionary foods per EO. This indicates small deviations between the model’s predictions and actual intakes. For overall daily diet quality, the model predictions deviated by 11.86 DGI points from the actual score. From mean absolute SHAP values, the importance of predictive factors varied across the six food groups, while for diet quality, the most influential factors were cooking confidence, self-efficacy, food availability, perceived time scarcity, and activity during consumption. CONCLUSION: ML provided valuable insights into predicting food consumption based on contextual factors. Future research should explore how ML can assist identify key factors that, when adjusted for individual behaviour patterns, encourage healthier eating habits. SUPPLEMENTARY INFORMATION: The online version contains supplementary material available at 10.1186/s12966-025-01818-4.