Explainable Machine Learning for Food Calorie Prediction Using Tree-Based Ensemble Models and SHAP Analysis

Authors

  • Wilsen Grivin Mokodaser Universitas Klabat, Sulawesi Utara, Indonesia
  • Tonny Irianto Soewignyo Universitas Klabat, Sulawesi Utara, Indonesia
  • Argha Orion Silitonga Universitas Klabat, Sulawesi Utara, Indonesia
  • Regi Fernando Najoan Universitas Klabat, Sulawesi Utara, Indonesia

DOI:

https://doi.org/10.62411/tc.v25i3.16809

Abstract

Accurate food calorie prediction is essential for nutritional assessment, dietary planning, and intelligent health applications. However, achieving high predictive accuracy while maintaining model interpretability remains a challenge for many machine learning approaches. This study proposes an explainable machine learning framework for food calorie prediction using tree-based ensemble models and SHAP (SHapley Additive exPlanations). A dataset containing 1,346 food samples with three nutritional attributes-proteins, fat, and carbohydrate-was used. Data preprocessing included logarithmic transformation and an 80:20 train-test split. Three machine learning models, namely Linear Regression, Random Forest, and XGBoost, were developed and evaluated using Mean Absolute Error (MAE), Mean Squared Error (MSE), Root Mean Squared Error (RMSE), and the coefficient of determination (R²). Hyperparameter optimization for XGBoost was performed using RandomizedSearchCV with five-fold cross-validation. Experimental results showed that Random Forest achieved the best predictive performance with an MAE of 0.1149, RMSE of 0.2869, and an R² score of 0.9008, outperforming both XGBoost and Linear Regression. Cross-validation further demonstrated the robustness of the selected model, yielding a mean R² of 0.9316 with a standard deviation of 0.0239. Residual analysis indicated prediction errors centered near zero without noticeable systematic bias. SHAP analysis provided both global and local model interpretability, identifying carbohydrate as the most influential feature, followed by fat and proteins. The findings demonstrate that integrating tree-based ensemble learning with SHAP enables accurate and transparent calorie prediction, making the proposed approach suitable for nutritional decision support and explainable artificial intelligence applications.   Keywords - Food calorie prediction, Explainable artificial intelligence, SHAP, Random Forest, XGBoost, Machine learning, Nutritional analysis.

Downloads

Published

2026-08-26