Deep Learning-Based Classification Consisting of Pre-Trained Models and Proposed Model Using K-Fold Cross-Validation for Pistachio Species
Abstract
:1. Introduction
- Since the quality of shelled pistachios is crucial for the economy, export, and marketing efforts according to their type, Kirmizi and Siirt pistachios have been classified using various deep learning-based classification models with k-fold cross-validation. A dataset of 2148 images, consisting of 1232 Kirmizi and 916 Siirt pistachio images, has been used for this classification.
- Seven convolutional neural network (CNN) models, trained through transfer learning, have been utilized for classification, along with the proposed model, MSU-CNN, which also incorporates k-fold cross-validation.
- The k-fold cross-validation technique has been utilized to enhance the generalization ability of the classification model, prevent overfitting, and improve performance reliability.
- The classification performances have been evaluated not only based on classification accuracy but also using sensitivity, specificity, precision, F1-scores, and ROC-AUC values. The results show that the proposed approaches can properly identify pistachio species.
- According to the existing literature, there does not appear to be a study that has utilized such a large number of models and achieved such high classification accuracy rates for pistachio species. Additionally, it seems that the proposed models perform effective and reliable classification and are relatively better and more innovative compared to the existing literature.
2. Materials and Methods
2.1. Pistachio Image Dataset
2.2. Convolutional Neural Networks
2.3. Transfer Learning
2.4. Pre-Trained CNN Models
2.5. K-Fold Cross-Validation
2.6. Confusion Matrix
2.7. Performance Metrics
2.8. ROC and AUC
3. The Proposed Approaches
3.1. Pre-Trained CNN Models with Transfer Learning
3.2. Proposed MSU-CNN Model
4. Results and Discussion
4.1. Comparison of Proposed Models Among Themselves
4.2. Comparison of the Proposed Approaches with the Literature
5. Conclusions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Çinarer, G.; Dogan, N.; Kiliç, K.; Dogan, C. Rapid detection of adulteration in pistachio based on deep learning methodologies and affordable system. Multimed. Tools Appl. 2024, 83, 14797–14820. [Google Scholar] [CrossRef]
- Grace, M.H.; Esposito, D.; Timmers, M.A.; Xiong, J.; Yousef, G.; Komarnytsky, S.; Lila, M.A. Chemical composition, antioxidant and anti-inflammatory properties of pistachio hull extracts. Food Chem. 2016, 210, 85–95. [Google Scholar] [CrossRef] [PubMed]
- Mandalari, G.; Barreca, D.; Gervasi, T.; Roussell, M.A.; Klein, B.; Feeney, M.J.; Carughi, A. Pistachio Nuts (Pistacia vera L.): Production, Nutrients, Bioactives and Novel Health Effects. Plants 2022, 11, 21. [Google Scholar] [CrossRef] [PubMed]
- Nadimi, A.E.; Ahmadi, Z.; Falahati-pour, S.K.; Mohamadi, M.; Nazari, A.; Hassanshahi, G.; Ekramzadeh, M. Physicochemical properties and health benefits of pistachio nuts A comprehensive review. Int. J. Vitam. Nutr. Res. 2020, 90, 564–574. [Google Scholar] [CrossRef]
- Bulló, M.; Juanola-Falgarona, M.; Hernández-Alonso, P.; Salas-Salvadó, J. Nutrition attributes and health effects of pistachio nuts. Br. J. Nutr. 2015, 113, S79–S93. [Google Scholar] [CrossRef]
- Derbyshire, E.; Higgs, J.; Feeney, M.J.; Carughi, A. Believe it or ‘nut’: Why it is time to set the record straight on nut protein quality: Pistachio (Pistacia vera L.) focus. Nutrients 2023, 15, 2158. [Google Scholar] [CrossRef]
- Saglam, C.; Cetin, N. Prediction of Pistachio (Pistacia vera L.) Mass Based on Shape and Size Attributes by Using Machine Learning Algorithms. Food Anal. Meth. 2022, 15, 739–750. [Google Scholar] [CrossRef]
- Mandavi-Jafari, S.; Salehinejad, H.; Talebi, S. A Pistachio Nuts Classification Technique: An ANN Based Signal Processing Scheme. In Proceedings of the International Conference on Computational Intelligence for Modelling, Control and Automation, Vienna, Austria, 10–12 December 2008; pp. 447–451. [Google Scholar]
- Mahmoudi, A.; Omid, M.; Aghagolzadeh, A. Artificial neural network based separation system for classifying pistachio nuts varieties. In Proceedings of the International Conference on Innovations in Food and Bioprocess Technologies, Pathum Thani, Thailand, 12–14 December 2006. [Google Scholar]
- Omid, M.; Firouz, M.S.; Nouri-Ahmadabadi, H.; Mohtasebi, S.S. Classification of peeled pistachio kernels using computer vision and color features. Eng. Agric. Environ. Food 2017, 10, 259–265. [Google Scholar] [CrossRef]
- Farazi, M.; Abbas-Zadeh, M.J.; Moradi, H. A machine vision based pistachio sorting using transferred mid-level image representation of Convolutional Neural Network. In Proceedings of the 2017 10th Iranian Conference on Machine Vision and Image Processing (MVIP), Isfahan, Iran, 22–23 November 2017; pp. 145–148. [Google Scholar]
- Abbaszadeh, M.; Rahimifard, A.; Eftekhari, M.; Zadeh, H.G.; Fayazi, A.; Dini, A.; Danaeian, M. Deep learning-based classification of the defective pistachios via deep autoencoder neural networks. arXiv 2019, arXiv:1906.11878. [Google Scholar]
- Dini, A.; Zadeh, H.G.; Rahimifard, A.; Fayazi, A.; Eftekhari, M.; Abbaszadeh, M. Designing a hardware system to separate defective pistachios from healthy ones using deep neural networks. Iran. J. Biosyst. Eng. 2020, 51, 149–159. [Google Scholar]
- Kumar, S.S.; Sigappi, A.N.; Thomas, G.A.S.; Robinson, Y.H.; Raja, S.P. Classification and Analysis of Pistachio Species Through Neural Embedding-Based Feature Extraction and Small-Scale Machine Learning Techniques. Int. J. Image Graph. 2024, 24, 23. [Google Scholar] [CrossRef]
- Rahimzadeh, M.; Attar, A. Detecting and counting pistachios based on deep learning. Iran J. Comput. Sci. 2022, 5, 69–81. [Google Scholar] [CrossRef]
- Sabah, A.S.; Abu-Naser, S.S. Pistachio Variety Classification using Convolutional Neural Networks. Int. J. Acad. Inf. Syst. Res. (IJAISR) 2024, 8, 113–119. [Google Scholar]
- Singh, D.; Taspinar, Y.S.; Kursun, R.; Cinar, I.; Koklu, M.; Ozkan, I.A.; Lee, H.N. Classification and Analysis of Pistachio Species with Pre-Trained Deep Learning Models. Electronics 2022, 11, 981. [Google Scholar] [CrossRef]
- Avuçlu, E. Classification of pistachio images with the resnet deep learning model. Selcuk. J. Agric. Food Sci. 2023, 37, 291–300. [Google Scholar] [CrossRef]
- Karadag, A.E.; Kiliç, A. Non-destructive robotic sorting of cracked pistachio using deep learning. Postharvest Biol. Technol. 2023, 198, 112229. [Google Scholar] [CrossRef]
- Turkay, Y.; Tamay, Z.S. Pistachio Classification Based on Acoustic Systems and Machine Learning. Elektron. Elektrotech. 2024, 30, 4–13. [Google Scholar] [CrossRef]
- Ozkan, I.A.; Koklu, M.; Saraçoglu, R. Classification of Pistachio Species Using Improved k-NN Classifier. Prog. Nutr. 2021, 23, e2021044. [Google Scholar] [CrossRef]
- Liu, X.Y.; Yang, L.H.; Zhu, H.F.; Zhang, L.Q.; An, Y.Y.; Wei, L.N.; Han, Z.Z. The pistachio quality detection based on deep features plus unsupervised clustering. J. Food Process Eng. 2024, 47, e14519. [Google Scholar] [CrossRef]
- Krizhevsky, A.; Sutskever, I.; Hinton, G.E. ImageNet Classification with Deep Convolutional Neural Networks. Commun. ACM 2017, 60, 84–90. [Google Scholar] [CrossRef]
- Dandil, E.; Polattimur, R. Dog behavior recognition and tracking based on faster R-CNN. J. Fac. Eng. Archit. Gazi Univ. 2020, 35, 819–834. [Google Scholar] [CrossRef]
- Chen, H.Z.; Chen, A.; Xu, L.L.; Xie, H.; Qiao, H.L.; Lin, Q.Y.; Cai, K. A deep learning CNN architecture applied in smart near-infrared analysis of water pollution for agricultural irrigation resources. Agric. Water Manag. 2020, 240, 106303. [Google Scholar] [CrossRef]
- Arsa, D.M.S.; Susila, A.A.N.H. VGG16 in batik classification based on random forest. In Proceedings of the 2019 International Conference on Information Management and Technology (ICIMTech), Jakarta, Indonesia, 19–20 August 2019; pp. 295–299. [Google Scholar]
- Bayar, B.; Stamm, M.C. A deep learning approach to universal image manipulation detection using a new convolutional layer. In Proceedings of the 4th ACM Workshop on Information Hiding And Multimedia Security, Galicia, Spain, 20–22 June 2016; pp. 5–10. [Google Scholar]
- Glorot, X.; Bordes, A.; Bengio, Y. Deep sparse rectifier neural networks. In Proceedings of the Fourteenth International Conference on Artificial Intelligence And Statistics, Fort Lauderdale, FL, USA, 11–13 April 2011; pp. 315–323. [Google Scholar]
- Akhtar, N.; Ragavendran, U. Interpretation of intelligence in CNN-pooling processes: A methodological survey. Neural Comput. Appl. 2020, 32, 879–898. [Google Scholar] [CrossRef]
- Habib, G.; Qureshi, S. Optimization and acceleration of convolutional neural networks: A survey. J. King Saud Univ. Comput. Inf. Sci. 2022, 34, 4244–4268. [Google Scholar] [CrossRef]
- Yosinski, J.; Clune, J.; Bengio, Y.; Lipson, H. How transferable are features in deep neural networks? In Proceedings of the 28th International Conference on Neural Information Processing Systems, Montreal, QC, Canada, 8–13 December 2014; Volume 2, pp. 3320–3328. [Google Scholar]
- Kolar, Z.; Chen, H.; Luo, X. Transfer learning and deep convolutional neural networks for safety guardrail detection in 2D images. Autom. Constr. 2018, 89, 58–70. [Google Scholar] [CrossRef]
- Stegmayer, G.; Milone, D.H.; Garran, S.; Burdyn, L. Automatic recognition of quarantine citrus diseases. Expert Syst. Appl. 2013, 40, 3512–3517. [Google Scholar] [CrossRef]
- Atas, M.; Yardimci, Y.; Temizel, A. A new approach to aflatoxin detection in chili pepper by machine vision. Comput. Electron. Agric. 2012, 87, 129–141. [Google Scholar] [CrossRef]
- Inan, O.; Uzer, M.S. A Method of Classification Performance Improvement Via a Strategy of Clustering-Based Data Elimination Integrated with k-Fold Cross-Validation. Arab. J. Sci. Eng. 2021, 46, 1199–1212. [Google Scholar] [CrossRef]
- Uzer, M.S.; Inan, O.; Yilmaz, N. A hybrid breast cancer detection system via neural network and feature selection based on SBS, SFS and PCA. Neural Comput. Appl. 2013, 23, 719–728. [Google Scholar] [CrossRef]
- Tutuncu, K.; Cataltas, O.; Koklu, M. Occupancy detection through light, temperature, humidity and CO2 sensors using ANN. Int. J. Ind. Electron. Electr. Eng 2016, 5, 63–67. [Google Scholar]
- Koklu, M.; Tutuncu, K. Classification of chronic kidney disease with most known data mining methods. Int. J. Adv. Sci. Eng. Technol. 2017, 5, 14–18. [Google Scholar]
- Acharya, U.R.; Fernandes, S.L.; WeiKoh, J.E.; Ciaccio, E.J.; Fabell, M.K.M.; Tanik, U.J.; Rajinikanth, V.; Yeong, C.H. Automated detection of Alzheimer’s disease using brain MRI images–a study with various feature extraction techniques. J. Med. Syst. 2019, 43, 302. [Google Scholar] [CrossRef] [PubMed]
- Rajinikanth, V.; Joseph Raj, A.N.; Thanaraj, K.P.; Naik, G.R. A customized VGG19 network with concatenation of deep and handcrafted features for brain tumor detection. Appl. Sci. 2020, 10, 3429. [Google Scholar] [CrossRef]
- Koklu, M.; Kursun, R.; Taspinar, Y.S.; Cinar, I. Classification of date fruits into genetic varieties using image analysis. Math. Probl. Eng. 2021, 2021, 4793293. [Google Scholar] [CrossRef]
- Taspinar, Y.S.; Cinar, I.; Koklu, M. Classification by a stacking model using CNN features for COVID-19 infection diagnosis. J. X-Ray Sci. Technol. 2022, 30, 73–88. [Google Scholar] [CrossRef]
Predicted Positive | Predicted Negative | |
---|---|---|
Actual Positive | True Positive (TP) | False Negative (FN) |
Actual Negative | False Positive (FP) | True Negative (TN) |
Performance Metrics | Formulas |
---|---|
Accuracy | |
Sensitivity | |
Specificity | |
Precision | |
F1-score |
Network Models | Training Optimization Algorithms | Epochs | Batch Size | Classification Accuracies of 5-Fold Cross-Validation (%) | |||||
---|---|---|---|---|---|---|---|---|---|
Fold1 | Fold2 | Fold3 | Fold4 | Fold5 | Mean Accuracy | ||||
AlexNet | SGDM | 20 | 9 | 93.94 | 90.47 | 95.81 | 98.84 | 95.34 | 94.88 |
GoogLeNet | SGDM | 10 | 11 | 96.74 | 96.05 | 98.37 | 96.05 | 96.74 | 96.79 |
Proposed MSU-CNN | Adam | 40 | 12 | 96.97 | 96.51 | 97.21 | 96.28 | 96.97 | 96.79 |
VGG-16 | SGDM | 8 | 9 | 96.97 | 98.14 | 97.44 | 99.07 | 97.90 | 97.90 |
EfficientNet-b0 | SGDM | 8 | 9 | 99.53 | 98.60 | 99.30 | 98.60 | 98.37 | 98.88 |
ResNet-18 | SGDM | 17 | 13 | 98.83 | 99.07 | 98.60 | 99.07 | 99.53 | 99.02 |
Inception-v3 | SGDM | 8 | 9 | 99.30 | 99.07 | 98.60 | 99.77 | 99.30 | 99.21 |
ResNet-50 | Adam | 15 | 16 | 100 | 100 | 100 | 99.07 | 99.07 | 99.63 |
Networks | Mean Performance Metrics of 5-Fold CV | |||||
---|---|---|---|---|---|---|
Accuracy | F1-Score | Precision | Sensitivity | Specificity | ROC_AUC | |
AlexNet | 0.9488 | 0.9466 | 0.9553 | 0.9426 | 0.9426 | 0.9936 |
GoogLeNet | 0.9679 | 0.9669 | 0.9712 | 0.9639 | 0.9639 | 0.9957 |
Proposed MSU-CNN | 0.9679 | 0.9672 | 0.9668 | 0.9678 | 0.9678 | 0.9952 |
VGG-16 | 0.979 | 0.9786 | 0.9791 | 0.9784 | 0.9784 | 0.9982 |
EfficientNet-b0 | 0.9888 | 0.9886 | 0.9878 | 0.9894 | 0.9894 | 0.9995 |
ResNet-18 | 0.9902 | 0.99 | 0.9901 | 0.9899 | 0.9899 | 0.9993 |
Inception-v3 | 0.9921 | 0.9919 | 0.9916 | 0.9923 | 0.9923 | 0.9997 |
ResNet-50 | 0.9963 | 0.9978 | 0.9935 | 0.9984 | 0.9956 | 0.9997 |
Fold | Accuracy | Precision | Recall | Specificity | F1-Score | ROC_AUC |
---|---|---|---|---|---|---|
1 | 1 | 1 | 1 | 1 | 1 | 1 |
2 | 1 | 1 | 1 | 1 | 1 | 1 |
3 | 1 | 1 | 1 | 1 | 1 | 1 |
4 | 0.9907 | 0.9945 | 0.9837 | 0.9959 | 0.9891 | 0.9999 |
5 | 0.9907 | 0.9945 | 0.9836 | 0.9959 | 0.989 | 0.9987 |
Mean | 0.9963 | 0.9978 | 0.9935 | 0.9984 | 0.9956 | 0.9997 |
References | Sample Size | Class Count | Classifier | Accuracy (%) |
---|---|---|---|---|
Mahdavi-Jafari, Salehinejad, and Talebi (2008) [8] | 150 | 3 | ANN | 99.89 |
Omid et al. (2017) [10] | 850 | 5 | ANN | 99.40 |
SVM | 99.80 | |||
Farazi, Abbas-Zadeh, and Moradi (2017) [11] | 1000 | 3 | AlexNet + SVM | 98 |
GoogleNet + SVM | 99 | |||
Abbaszadeh et al. (2019) [12] | 305 | 2 | Deep Auto-encoder Neural Networks | 80.30 |
Dini et al. (2020) [13] | 958 | 2 | GoogleNet | 95.80 |
ResNet | 97.20 | |||
VGG16 | 95.83 | |||
Rahimzadeh and Attar (2021) [15] | 3927 | 2 | ResNet50 | 85.28 |
ResNet152 | 85.19 | |||
VGG16 | 83.32 | |||
Ozkan, Koklu, and Saracoglu (2021) [21] | 2148 | 2 | k-NN | 94.18 |
Singh et al.(2022) [17] | 2148 | 2 | AlexNet | 94.42 |
VGG16 | 98.84 | |||
VGG19 | 98.14 | |||
Avuclu (2023) [18] | 2148 | 2 | ResNet | 86.16 |
Kumar et al. (2023) [14] | 2148 | 2 | DNN-based feature extraction and logistic regression | 97.20 |
Karadag, and Kilic (2023) [19] | 3700 | 2 | Deep learning-based object detection for open- and closed-shelled pistachios, respectively | 98 and 85 |
Çinarer et al. (2024) [1] | 1200 | 6 | VGGNet-19 in the LAB color space and applied 5-fold CV, respectively | 100 and 99.16 |
Sabah and Abu-Naser (2024) [16] | 6000 | 2 | Augmentation technique and VGG16 | 99.91 |
Liu et al. (2024) [22] | 2095 | 2 | ResNet18 and clustering | 99.31 |
This study | 2148 | 2 | AlexNet (5-fold CV) | 94.88 |
Proposed MSU-CNN (5-fold CV) | 96.79 | |||
GoogLeNet (5-fold CV) | 96.79 | |||
VGG16 (5-fold CV) | 97.90 | |||
EfficientNet-b0 (5-fold CV) | 98.88 | |||
ResNet-18 (5-fold CV) | 99.02 | |||
Inception-v3 (5-fold CV) | 99.21 | |||
ResNet-50 (5-fold CV) | 99.63 | |||
AlexNet (80% train-20% test) | 98.84 | |||
Proposed MSU-CNN (80% train-20% test) | 97,21 | |||
GoogLeNet (80% train-20% test) | 98.37 | |||
VGG16 (80% train-20% test) | 99.07 | |||
EfficientNet-b0 (80% train-20% test) | 99.53 | |||
ResNet-18 (80% train-20% test) | 99.53 | |||
Inception-v3 (80% train-20% test) | 99.77 | |||
ResNet-50 (80% train-20% test) | 100 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Uzer, M.S. Deep Learning-Based Classification Consisting of Pre-Trained Models and Proposed Model Using K-Fold Cross-Validation for Pistachio Species. Appl. Sci. 2025, 15, 4516. https://doi.org/10.3390/app15084516
Uzer MS. Deep Learning-Based Classification Consisting of Pre-Trained Models and Proposed Model Using K-Fold Cross-Validation for Pistachio Species. Applied Sciences. 2025; 15(8):4516. https://doi.org/10.3390/app15084516
Chicago/Turabian StyleUzer, Mustafa Serter. 2025. "Deep Learning-Based Classification Consisting of Pre-Trained Models and Proposed Model Using K-Fold Cross-Validation for Pistachio Species" Applied Sciences 15, no. 8: 4516. https://doi.org/10.3390/app15084516
APA StyleUzer, M. S. (2025). Deep Learning-Based Classification Consisting of Pre-Trained Models and Proposed Model Using K-Fold Cross-Validation for Pistachio Species. Applied Sciences, 15(8), 4516. https://doi.org/10.3390/app15084516