Predicting diet quality and food consumption using contextual factors: an application of machine learning models
Authors: Tran N.R , Zhang Y. , Leech R.M , McNaughton S.A 
Published: December 2024

Poor diet quality among young adults contributes to increased rates of overweight and obesity(1). Improving diet quality requires small and achievable changes in eating behaviours(2). Personalised nutrition interventions offer a promising strategy to modify behaviour and subsequently enhance diet quality but require input data on individuals past behaviour and their environmental contexts to ensure advice is relevant and effective(3). Machine learning (ML) is a useful tool for predicting behaviours, but few studies have explored the integration of ML capabilities into precision nutrition applications(4–6). Therefore, this study used ML to investigate whether contextual factors occurring at eating occasions (EO) predict food consumption and, consequently, overall daily diet quality.Analyses were conducted on cross-sectional data from the Measuring Eating in Everyday Life Study (MEALS) (7–8). Participants (aged 18-30 years, n = 675) recorded dietary intakes at EO (i.e. meals and snacks) in near-real time (3-4 non-consecutive days) using a Smartphone food diary app. Contextual factors for each EO were recorded via the app and categorised as socialenvironmental factors (e.g. activity, persons present while eating) and physical-environmental factors (e.g. consumption location, purchase location). Person level factors describing participant characteristics were collected during an online survey. Intake (servings per EO) of vegetables, fruits, grains, meat, dairy, and discretionary foods were estimated, as per Australian Dietary Guidelines. Gradient boost decision tree(9) and random forest models(10) were chosen a priori ; decision tree provide explainable ML, while random forest improves accuracy(11). Their performance was evaluated using 10-fold cross-validation, comparing mean absolute error (MAE), root mean square error (RMSE), and R squared. Feature importance analysis was performed to understand important variables for predicting food consumption. All analysis was performed using R.Results indicate that ML can predict most food groups at EO using contextual factors, with an acceptable range in differences between actual consumption and predicted consumption (<1 serving per EO). For instance, MEA values for fruits, dairy, and meat were 0.35, 0.34, and 0.56 servings, respectively. This suggests that, on average, models’ predictions are off by 0.35 servings of fruits per EO using contextual factors (RMSE values for fruit, dairy, and meat were 0.61, 0.50, and 0.80 servings, respectively). Notably, when investigating the influences of different contextual factors on models’ predictions, feature importance analysis indicated that person level factors such as self-efficacy and age were considered highly important, while person presence and purchase locations ranked highly in importance within eating occasion-level factors across most food groups.ML can offer valuable insights into the interplay between contextual factors and food consumption. Future research should investigate which contextual factors, when modified, lead to favourable dietary behaviours, and incorporate these findings into precision nutrition interventions.