Classification of Peruvian Cacao Samples from Different Varieties and Geographical Origins Using Near-Infrared Spectroscopy and Machine Learning
Abstract
The rapid and non-destructive identification of cacao varieties and geographical origins is essential for strengthening traceability, authenticity assessment, and quality management in the Peruvian cacao production chain. This study aimed to evaluate the capability of near-infrared (NIR) spectroscopy combined with machine learning to classify Peruvian cacao samples into eight predefined groups associated with different varieties, genetic backgrounds, and geographical origins. Its main contribution is the comparative evaluation of four machine learning algorithms under standardized spectral preprocessing and experimental conditions. A dataset of 12,000 spectral observations was analyzed. The samples were prepared under standardized laboratory conditions, ground, and analyzed using NIR spectroscopy. The spectra were preprocessed using Standard Normal Variate (SNV) normalization to reduce scattering-related variability, followed by Principal Component Analysis (PCA) for dimensionality reduction. Logistic Regression, Support Vector Machine, Random Forest, and Gradient Boosting were evaluated using an 80:20 training-testing partition, with hyperparameter optimization through grid search and cross-validation. Performance was assessed using accuracy, precision, recall, and multiclass area under the receiver operating characteristic curve (ROC-AUC). Gradient Boosting achieved the highest performance, with 98% accuracy, 98% recall, 97% precision, and a ROC-AUC of 0.99, followed by Random Forest (96%), Logistic Regression (83%), and Support Vector Machine (70%) in accuracy. These findings demonstrate the effectiveness of ensemble methods in distinguishing predefined cacao groups based on their spectral profiles. The novelty lies in integrating spectral analysis and machine learning to discriminate Peruvian cacao groups considering varietal, genetic, and geographical distinctions. However, the results represent group classification rather than definitive geographical authentication or direct quality prediction. Further validation using independent batches, geographical sources, and chemical or sensory reference measurements is necessary to establish the model's generalizability.
Keywords
Full Text:
PDFReferences
E. Abt and L. P. Robin, “Perspective on cadmium and lead in cocoa and chocolate,” J. Agric. Food Chem., vol. 68, no. 46, pp. 13008–13015, Nov. 2020, doi: 10.1021/acs.jafc.9b08295.
T. Ouattara, F. Kouamé, C. Zo-Bi, R. Vaudry, and C. Grinand, “Changements d’occupation et d’usage des terres entre 2016 et 2019 dans le Sud-Est de la Côte d’Ivoire: impact des cultures de rente sur la forêt,” Bois For. Trop., vol. 347, pp. 91–106, Mar. 2021, doi: 10.19182/bft2021.347.a31868.
A. J. Ariza-Salamanca et al., “Vulnerability of cocoa-based agroforestry systems to climate change in West Africa,” Sci. Rep., vol. 13, no. 1, p. 10033, Jun. 2023, doi: 10.1038/s41598-023-37180-3.
W. Llerena et al., “Profile of bioactive components of cocoa (Theobroma cacao L.) by-products from Ecuador and evaluation of their antioxidant activity,” Foods, vol. 12, no. 13, p. 2583, Jul. 2023, doi: 10.3390/foods12132583.
B. Luis-Alaya et al., “Evaluation of the presence of arbuscular mycorrhizae and cadmium content in the plants and soils of cocoa plantations in San Martín, Peru,” Diversity, vol. 15, no. 2, p. 246, Feb. 2023, doi: 10.3390/d15020246.
G. A. Collazos-Escobar, Y. F. Barrios-Rodríguez, A. F. Bahamón-Monje, and N. Gutiérrez-Guzmán, “Uses of mid-infrared spectroscopy and chemometric models for differentiating dried cocoa bean varieties,” Rev. Bras. Eng. Agríc. Ambient., vol. 27, no. 10, pp. 803–810, Oct. 2023, doi: 10.1590/1807-1929/agriambi.v27n10p803-810.
E. Bagnulo, G. Strocchi, C. Bicchi, and E. Liberto, “Industrial food quality and consumer choice: Artificial intelligence-based tools in the chemistry of sensory notes in comfort foods (coffee, cocoa and tea),” Trends Food Sci. Technol., vol. 147, p. 104415, May 2024, doi: 10.1016/j.tifs.2024.104415.
M. M. Oliveira, M. V. S. Ferreira, M. Kamruzzaman, and D. F. Barbin, “Prediction of impurities in cocoa shell powder using NIR spectroscopy,” J. Pharm. Biomed. Anal. Open, vol. 2, p. 100015, Dec. 2023, doi: 10.1016/j.jpbao.2023.100015.
E. O. Afoakwa, J. Quao, J. Takrama, A. S. Budu, and F. K. Saalia, “Chemical composition and physical quality characteristics of Ghanaian cocoa beans as affected by pulp pre-conditioning and fermentation,” J. Food Sci. Technol., vol. 50, no. 6, pp. 1097–1105, Dec. 2013, doi: 10.1007/s13197-011-0446-5.
C. Hernández-Hernández et al., “Rapid screening of unground cocoa beans based on their content of bioactive compounds by NIR spectroscopy,” Food Control, vol. 131, p. 108347, Jan. 2022, doi: 10.1016/j.foodcont.2021.108347.
R. F. Alotaibi, H. H. AlTilasi, A. M. Al-Mutairi, and H. S. Alharbi, “Chromatographic and spectroscopic methods for the detection of cocoa butter in cocoa and its derivatives: A review,” Heliyon, vol. 10, no. 11, p. e31467, Jun. 2024, doi: 10.1016/j.heliyon.2024.e31467.
I. A. Santos et al., “NIR and MIR spectroscopy for quick detection of the adulteration of cocoa content in chocolates,” Food Chem., vol. 349, p. 129095, Jul. 2021, doi: 10.1016/j.foodchem.2021.129095.
Agussabti et al., “Data analysis on near infrared spectroscopy as a part of technology adoption for cocoa farmer in Aceh Province, Indonesia,” Data Brief, vol. 29, p. 105251, Apr. 2020, doi: 10.1016/j.dib.2020.105251.
R. Hayati, Z. Zulfahrizal, and A. A. Munawar, “Robust prediction performance of inner quality attributes in intact cocoa beans using near infrared spectroscopy and multivariate analysis,” Heliyon, vol. 7, no. 2, p. e06286, Feb. 2021, doi: 10.1016/j.heliyon.2021.e06286.
A. Pinto et al., “Advances in the individual authentication of cocoa beans: Vis/NIR spectroscopy as a tool to distinguish fermented from unfermented beans and classify genotypes in the eastern Amazonia,” Food Control, vol. 164, p. 110559, Oct. 2024, doi: 10.1016/j.foodcont.2024.110559.
X. Du et al., “Quantitative analysis of soil potassium by near-infrared spectroscopy combined with a three-step progressive hybrid variable selection strategy,” Spectrochim. Acta A Mol. Biomol. Spectrosc., vol. 324, p. 124998, Jan. 2025, doi: 10.1016/j.saa.2024.124998.
M. L. F. Simeone et al., “Portable near-infrared spectroscopy and multivariate calibration for reliable quality control of maize and sorghum grain chemical composition,” J. Food Compos. Anal., vol. 134, p. 106502, Oct. 2024, doi: 10.1016/j.jfca.2024.106502.
R. Abdul, L. Riana, and L. Fajar Aji, “Near-infrared (NIR) and Fourier transform infrared (FTIR) spectroscopy combined with chemometrics for agrifood products analysis,” in Chemometrics, Elsevier, 2024, pp. 125–146. doi: 10.1016/B978-0-443-21493-6.00006-X.
G. Squeo et al., “Considerations about the gap between research in near-infrared spectroscopy and official methods and recommendations of analysis in foods,” Curr. Opin. Food Sci., vol. 59, p. 101203, Oct. 2024, doi: 10.1016/j.cofs.2024.101203.
P. Vargas Jentzsch et al., “Distinction of Ecuadorian varieties of fermented cocoa beans using Raman spectroscopy,” Food Chem., vol. 211, pp. 274–280, Nov. 2016, doi: 10.1016/j.foodchem.2016.05.017.
A. Saeidan et al., “Detection of foreign materials in cocoa beans by hyperspectral imaging technology,” Food Control, vol. 129, p. 108242, Nov. 2021, doi: 10.1016/j.foodcont.2021.108242.
L. Du, “New insights into raw milk adulterated with milk powder identification: ATR-FTIR spectroscopic fingerprints combined with machine learning and feature selection approaches,” J. Food Compos. Anal., vol. 133, p. 106443, Sep. 2024, doi: 10.1016/j.jfca.2024.106443.
D. Schütz et al., “Fourier-transform near-infrared spectroscopy as a fast screening tool for the verification of the geographical origin of grain maize (Zea mays L.),” Food Control, vol. 136, p. 108892, Jun. 2022, doi: 10.1016/j.foodcont.2022.108892.
X. Yu et al., “Rapid discrimination of coal geographical origin via near-infrared spectroscopy combined with machine learning algorithms,” Infrared Phys. Technol., vol. 105, p. 103180, Mar. 2020, doi: 10.1016/j.infrared.2019.103180.
E. Teye et al., “Feasibility study on the use of Fourier transform near-infrared spectroscopy together with chemometrics to discriminate and quantify adulteration in cocoa beans,” Food Res. Int., vol. 55, pp. 288–293, Jan. 2014, doi: 10.1016/j.foodres.2013.11.021.
I. Sa et al., “deepNIR: Datasets for generating synthetic NIR images and improved fruit detection system using deep learning techniques,” Sensors, vol. 22, no. 13, p. 4721, Jun. 2022, doi: 10.3390/s22134721.
N. R. N. Millatina et al., “Detection and quantification of cocoa powder adulteration using Vis-NIR spectroscopy with chemometrics approach,” Food Chem., vol. 449, p. 139212, Aug. 2024, doi: 10.1016/j.foodchem.2024.139212.
G. A. Collazos-Escobar et al., “Mid-infrared spectroscopy and machine learning as a complementary tool for sensory quality assessment of roasted cocoa-based products,” Infrared Phys. Technol., vol. 141, p. 105482, Sep. 2024, doi: 10.1016/j.infrared.2024.105482.
R. A. Casonatto, T. D. P. G. Souza, and A. M. Mariano, “Quality and risk management in data mining: A CRISP-DM perspective,” Procedia Comput. Sci., vol. 242, pp. 161–168, 2024, doi: 10.1016/j.procs.2024.08.257.
C. Schröer, F. Kruse, and J. M. Gómez, “A systematic literature review on applying CRISP-DM process model,” Procedia Comput. Sci., vol. 182, pp. 106–113, 2021, doi: 10.1016/j.procs.2021.01.199.
M. Fantinato, S. M. Peres, and H. A. Reijers, “X-processes: Process model discovery with the best balance among fitness, precision, simplicity, and generalization through a genetic algorithm,” Inf. Syst., vol. 118, p. 102247, 2023, doi: 10.1016/j.is.2023.102247.
A. Géron, Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 2nd ed. Sebastopol, CA, USA: O’Reilly Media, 2019.
T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning: Data Mining, Inference, and Prediction, 2nd ed. New York, NY, USA: Springer, 2009.
C. M. Bishop, Pattern Recognition and Machine Learning, New York, NY, USA: Springer, 2006.
J. Brownlee, “A Gentle Introduction to k-fold Cross-Validation,” Machine Learning Mastery, 2020.
F. Pedregosa et al., “Scikit-learn: Machine learning in Python,” Journal of Machine Learning Research, vol. 12, pp. 2825–2830, 2011.
L. Breiman, “Random forests,” Machine Learning, vol. 45, pp. 5–32, 2001, doi: 10.1023/A:1010933404324.
J. H. Friedman, “Greedy function approximation: A gradient boosting machine,” Annals of Statistics, vol. 29, no. 5, pp. 1189–1232, 2001, doi: 10.1214/aos/1013203451.
C. Cortes and V. Vapnik, “Support-vector networks,” Machine Learning, vol. 20, pp. 273–297, 1995, doi: 10.1007/BF00994018.
H. Abdi and L. J. Williams, “Principal component analysis,” Wiley Interdisciplinary Reviews: Computational Statistics, vol. 2, no. 4, pp. 433–459, 2010, doi: 10.1002/wics.101.
DOI: https://doi.org/10.47738/jads.v7i4.1568
Refbacks
- There are currently no refbacks.

Journal of Applied Data Sciences
| ISSN | : | 2723-6471 (Online) |
| Publisher | : | Bright Publisher |
| Website | : | http://bright-journal.org/JADS |
| : | taqwa@amikompurwokerto.ac.id (principal contact) | |
| support@bright-journal.org (technical issues) |
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0




.png)