Explainable Machine Learning for Food Calorie Prediction Using Tree-Based Ensemble Models and SHAP Analysis
DOI:
https://doi.org/10.62411/tc.v25i3.16809Abstract
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
Issue
Section
License
Copyright (c) 2026 Wilsen Grivin Mokodaser, Tonny Irianto Soewignyo, Argha Orion Silitonga, Regi Fernando Najoan

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
License Terms
All articles published in Techno.COM Journal are licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0). This means:
1. Attribution
Readers and users are free to:
-
Share – Copy and redistribute the material in any medium or format.
-
Adapt – Remix, transform, and build upon the material.
As long as proper credit is given to the original work by citing the author(s) and the journal.
2. Non-Commercial Use
-
The material cannot be used for commercial purposes.
-
Commercial use includes selling the content, using it in commercial advertising, or integrating it into products/services for profit.
3. Rights of Authors
-
Authors retain copyright and grant Techno.COM Journal the right to publish the article.
-
Authors can distribute their work (e.g., in institutional repositories or personal websites) with proper acknowledgment of the journal.
4. No Additional Restrictions
-
The journal cannot apply legal terms or technological measures that restrict others from using the material in ways allowed by the license.
5. Disclaimer
-
The journal is not responsible for how the published content is used by third parties.
-
The opinions expressed in the articles are solely those of the authors.
For more details, visit the Creative Commons License Page:
? https://creativecommons.org/licenses/by-nc/4.0/









