Your new experience awaits. Try the new design now and help us make it even better

ORIGINAL RESEARCH article

Front. Artif. Intell.

Sec. AI in Finance

Volume 8 - 2025 | doi: 10.3389/frai.2025.1661989

This article is part of the Research TopicDigital Agricultural Technologies for Improving Food Security OutcomesView all 6 articles

Predicting Food Prices in Kenya using Machine Learning: A Hybrid Model Approach with XGBoost and Gradient Boosting

Provisionally accepted
  • 1Strathmore University, Nairobi, Kenya
  • 2African Population and Health Research Center, Nairobi, Kenya
  • 3International Centre of Insect Physiology and Ecology (ICIPE), Nairobi, Kenya

The final, formatted version of the article will be published soon.

Food price volatility continues to be a significant field of concern in Kenya's economic development and presents challenges to the stability of the country's economy. This study investigates the application of machine learning methods, using a hybrid approach of XGBoost and gradient boosting to help predict food prices in Kenya. The food prices data from the World Food Program from January 2006 to September 2024, currency exchange rates data from the Central Bank of Kenya in US dollars (USD), and inflation rates data were collated and pre-processed to be analytics and machine learning ready. The augmented data were preprocessed and transformed, then used to train XGBoost, gradient boosting, LightGBM, decision tree, random forest, and linear regression. A hybrid model was then developed by stacking XGBoost and gradient boosting as the base models, with linear regression serving as the meta-model used to combine their predictions. This model was then tuned by the hyperparameter random search method, achieving a mean absolute error of 0.1050, a mean squared error of 0.0261, a root mean square error of 0.1615, and an R-square of 0.9940, thereby surpassing the performances of all standalone models. We then applied cross-validation using 5–folds and Diebold–Mariano to check for model overfitting and model superiority analysis. Feature importance analysis using SHapley Additive exPlanations (SHAP) indicated that intuitive features impacting food prices are unit quantity, price type, commodity, and currency, while geographical factors like county have less impact. Finally, the model and the important features were then saved as pickle files to help deploy the model on a web application to facilitate food price predictions. This data-driven decision support system can help policymakers and agricultural stakeholders (such as the Kenyan government) plan for future trends in food prices. This can help prevent food insecurity in Kenya.

Keywords: Agricultural stakeholders, Food insecurity, machine learning, Malnutrition, policymakers, volatility

Received: 09 Jul 2025; Accepted: 30 Sep 2025.

Copyright: © 2025 Ogol, Omondi, OLUKURU, Muriithi and Senagi. This is an open-access article distributed under the terms of the Creative Commons Attribution License (CC BY). The use, distribution or reproduction in other forums is permitted, provided the original author(s) or licensor are credited and that the original publication in this journal is cited, in accordance with accepted academic practice. No use, distribution or reproduction is permitted which does not comply with these terms.

* Correspondence: Kennedy Senagi, ksenagi@icipe.org

Disclaimer: All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher.