Optimizing Support Vector Machine for Avocado Ripeness Classification Using Moth Flame Optimization
Abstract
Avocado is a fruit from Mexico and Central America that is widely distributed worldwide for production and consumption. In avocados, ripeness is crucial because it is the primary factor consumers consider, significantly influencing their purchasing decisions. The manual ripeness selection is inefficient and inconsistent, so the classification system is essential for determining ripeness due to its effectiveness and efficiency compared to manual selection. In this study, we aim to develop a model that can classify avocado ripeness using machine learning with optimization. The data consists of avocado images categorized into five ripeness stages: underripe, breaking, ripe (first stage), ripe (second stage), and overripe. We utilize a Support Vector Machine (SVM) for the classification. Instead of manually choosing the model’s hyperparameters, we use Moth Flame Optimization (MFO) to optimize the SVM hyperparameters. The MFO ensures that the proposed model has optimal performance. For the input of SVM, we extract the HSV, GLCM, and HOG and apply PCA to the data. In this study, we use three SVM kernels: RBF, polynomial, and sigmoid. The MFO finds the model’s hyperparameters based on kernel requirements, including C, gamma, degree, and coef0. The MFO-SVM obtains optimal performance with an accuracy of 82.55%, 82.68%, and 81.23% for SVM kernel RBF, polynomial, and sigmoid, respectively. The results show that our proposed model demonstrates adequate performance in identifying the ripeness levels of avocados. The MFO increases model performance on all evaluation metrics compared to the baseline model and can be an excellent strategy to improve model performance.
Downloads
References
N. J. Salazar-López et al., “Avocado fruit and by-products as potential sources of bioactive compounds,” Food Research International, vol. 138, p. 109774, 2020, doi: https://doi.org/10.1016/j.foodres.2020.109774.
P. Rodríguez, I. Soto, J. Villamizar, and A. Rebolledo, “Fatty Acids and Minerals as Markers Useful to Classify Hass Avocado Quality: Ripening Patterns, Internal Disorders, and Sensory Quality,” Horticulturae, vol. 9, no. 4, Apr. 2023, doi: 10.3390/horticulturae9040460.
K.-M. Huang, Z. Guan, T. Blare, and A. M. Hammami, “Global Avocado Boom,” Choices, vol. 38, pp. 1–9, 2023.
K. Goyal, P. Kumar, and K. Verma, “Tomato ripeness and shelf-life prediction system using machine learning,” Journal of Food Measurement and Characterization, vol. 18, no. 4, pp. 2715–2730, Apr. 2024, doi: 10.1007/s11694-023-02349-x.
V. L. Tran, T. N. C. Doan, F. Ferrero, T. Le Huy, and N. Le-Thanh, “The Novel Combination of Nano Vector Network Analyzer and Machine Learning for Fruit Identification and Ripeness Grading,” Sensors, vol. 23, no. 2, Jan. 2023, doi: 10.3390/s23020952.
P. Xavier, P. M. Rodrigues, and C. L. M. Silva, “Shelf-Life Management and Ripening Assessment of ‘Hass’ Avocado (Persea americana) Using Deep Learning Approaches,” Foods, vol. 13, no. 8, Apr. 2024, doi: 10.3390/foods13081150.
J. E. de la Cruz and O. J. Vera Ramirez, “Convolutional neural networks for the Hass avocado classification using LabVIEW in an agro-industrial plant,” in 2020 IEEE XXVII International Conference on Electronics, Electrical Engineering and Computing (INTERCON), 2020, pp. 1–4. doi: 10.1109/INTERCON50315.2020.9220246.
C. A. Jaramillo-Acevedo, W. E. Choque-Valderrama, G. E. Guerrero-Álvarez, and C. A. Meneses-Escobar, “Hass avocado ripeness classification by mobile devices using digital image processing and ANN methods,” International Journal of Food Engineering, vol. 16, no. 12, Dec. 2020, doi: 10.1515/ijfe-2019-0161.
S. Adige, R. Kurban, A. Durmuş, and E. Karaköse, “Classification of apple images using support vector machines and deep residual networks,” Neural Comput Appl, vol. 35, no. 16, pp. 12073–12087, Jun. 2023, doi: 10.1007/s00521-023-08340-3.
M. Islam, K. Wahid, and A. Dinh, “Assessment of ripening degree of avocado by electrical impedance spectroscopy and support vector machine,” J Food Qual, vol. 2018, 2018, doi: 10.1155/2018/4706147.
S. U. Rahman, F. Alam, N. Ahmad, and S. Arshad, “Image processing based system for the detection, identification and treatment of tomato leaf diseases.,” Multimed Tools Appl, vol. 82, no. 6, pp. 9431–9445, Mar. 2023, doi: 10.1007/s11042-022-13715-0.
M. E. Pothen and M. L. Pai, “Detection of Rice Leaf Diseases Using Image Processing,” in 2020 Fourth International Conference on Computing Methodologies and Communication (ICCMC), 2020, pp. 424–430. doi: 10.1109/ICCMC48092.2020.ICCMC-00080.
E. Jorge and M. Macas, “Artificial Intelligence-Based Banana Ripeness Detection,” in Applied Technologies, Botto-Tobar, Miguel, Z. V. Marcelo, S. Montes Le’on, P. Torres-Carrion, and B. Durakovic, Eds., Cham: Springer Nature Switzerland, 2023, pp. 197–211. doi: https://doi.org/10.1007/978-3-031-24985-3_15.
X. Zeng, Q. Zhao, Y. Zhang, Y. Zhang, and T. Shen, “Apple Grading Method Based on GA-SVM,” in The 10th International Conference on Computer Engineering and Networks, L. Qi, L. Xiadong, S. Tao, and Q. Xuesong, Eds., Singapore: Springer Singapore, 2021, pp. 79–89. doi: https://doi.org/10.1007/978-981-15-8462-6_9.
M. Y. Pusadan, I. Safitri, and Wirdayanti, “The Image Extraction Using the HSV Method to Determine the Maturity Level of Palm Oil Fruit with the k-nearest Neighbor Algorithm,” Jurnal RESTI (Rekayasa Sistem dan Teknologi Informasi), vol. 7, no. 6, pp. 1448–1456, Dec. 2023, doi: 10.29207/resti.v7i6.5558.
S. K. Behera, A. K. Rath, and P. K. Sethy, “Maturity status classification of papaya fruits based on machine learning and transfer learning approach,” Information Processing in Agriculture, vol. 8, no. 2, pp. 244–250, Jun. 2021, doi: 10.1016/j.inpa.2020.05.003.
L. Yang and A. Shami, “On hyperparameter optimization of machine learning algorithms: Theory and practice,” Neurocomputing, vol. 415, pp. 295–316, 2020, doi: https://doi.org/10.1016/j.neucom.2020.07.061.
A. J. Makrufi and W. F. Al Maki, “Support Vector Machine with Firefly Optimization Algorithm for Apple Fruit Disease Classification,” vol. 22, no. 1, pp. 177–188, 2022, doi: https://doi.org/10.30812/matrik.v22i1.2365.
S. Mirjalili, “Moth-flame optimization algorithm: A novel nature-inspired heuristic paradigm,” Knowl Based Syst, vol. 89, pp. 228–249, 2015, doi: https://doi.org/10.1016/j.knosys.2015.07.006.
A. A. Ewees, A. A. Hemedan, A. E. Hassanien, and A. T. Sahlol, “Optimized support vector machines for unveiling mortality incidence in Tilapia fish,” Ain Shams Engineering Journal, vol. 12, no. 3, pp. 3081–3090, Sep. 2021, doi: 10.1016/j.asej.2021.01.014.
P. Xavier, P. Rodrigues, and C. L. M. Silva, “‘Hass’ Avocado Ripening Photographic Dataset,” Mendeley Data, vol. 1, 2024, doi: 10.17632/3xd9n945v8.1.
S. Jain, G. Seth, A. Paruthi, U. Soni, and G. Kumar, “Synthetic data augmentation for surface defect detection and classification using deep learning,” J Intell Manuf, vol. 33, no. 4, pp. 1007–1020, Apr. 2022, doi: 10.1007/s10845-020-01710-x.
D. Giuliani, “Metaheuristic Algorithms Applied to Color Image Segmentation on HSV Space,” J Imaging, vol. 8, no. 1, Jan. 2022, doi: 10.3390/jimaging8010006.
H. Kim, H. Lee, S. Ahn, W. K. Jung, and S. H. Ahn, “Broken stitch detection system for industrial sewing machines using HSV color space and image processing techniques,” J Comput Des Eng, vol. 10, no. 4, pp. 1602–1614, Aug. 2023, doi: 10.1093/jcde/qwad069.
W. K. Mutlag, S. K. Ali, Z. M. Aydam, and B. H. Taher, “Feature Extraction Methods: A Review,” in Journal of Physics: Conference Series, IOP Publishing Ltd, Aug. 2020. doi: 10.1088/1742-6596/1591/1/012028.
Q. Liu, Y. Song, Q. Tang, X. Bu, and N. Hanajima, “Wire rope defect identification based on ISCM-LBP and GLCM features,” Visual Computer, vol. 40, no. 2, pp. 545–557, Feb. 2024, doi: 10.1007/s00371-023-02800-6.
A. K. Aggarwal, “Learning Texture Features from GLCM for Classification of Brain Tumor MRI Images using Random Forest Classifier,” WSEAS TRANSACTIONS ON SIGNAL PROCESSING, vol. 18, pp. 60–63, Apr. 2022, doi: 10.37394/232014.2022.18.8.
Greeshma K V and Dr. J. Viji Gripsy, “Image Classification using HOG and LBP Feature Descriptors with SVM and CNN,” International Journal of Engineering Research & Technology (IJERT), vol. 8, no. 04, 2020.
L. Zhang, W. Zhou, J. Li, J. Li, and X. Lou, “Histogram of Oriented Gradients Feature Extraction Without Normalization,” in 2020 IEEE Asia Pacific Conference on Circuits and Systems (APCCAS), 2020, pp. 252–255. doi: 10.1109/APCCAS50809.2020.9301715.
U. D. Dixit, M. S. Shirdhonkar, and G. R. Sinha, “Automatic logo detection from document image using HOG features,” Multimed Tools Appl, vol. 82, no. 1, pp. 863–878, Jan. 2023, doi: 10.1007/s11042-022-13300-5.
E. Odhiambo Omuya, G. Onyango Okeyo, and M. Waema Kimwele, “Feature Selection for Classification using Principal Component Analysis and Information Gain,” Expert Syst Appl, vol. 174, Jul. 2021, doi: 10.1016/j.eswa.2021.114765.
X. Wu, T. Oli, J. H. Qian, V. Taylor, M. C. Hersam, and V. K. Sangwan, “An Autotuning-based Optimization Framework for Mixed-kernel SVM Classifications in Smart Pixel Datasets and Heterojunction Transistors,” Jun. 2024, [Online]. Available: http://arxiv.org/abs/2406.18445
L. Zhu and P. Spachos, “Support vector machine and YOLO for a mobile food grading system,” Internet of Things (Netherlands), vol. 13, Mar. 2021, doi: 10.1016/j.iot.2021.100359.
S. M. Al-azzawi, M. A. Deif, H. Attar, A. Amer, and A. A. A. Solyman, “Hyperparameter Optimization of Regression Model for Electrical Load Forecasting During the COVID-19 Pandemic Lockdown Period,” International Journal of Intelligent Engineering and Systems, vol. 16, no. 4, pp. 239–253, 2023, doi: 10.22266/ijies2023.0831.20.
M. Hussain, S. K. Wajid, A. Elzaart, and M. Berbar, “A Comparison of SVM Kernel Functions for Breast Cancer Detection,” in 2011 Eighth International Conference Computer Graphics, Imaging and Visualization, 2011, pp. 145–150. doi: 10.1109/CGIV.2011.31.
M. Pan et al., “Photovoltaic power forecasting based on a support vector machine with improved ant colony optimization,” J Clean Prod, vol. 277, Dec. 2020, doi: 10.1016/j.jclepro.2020.123948.
Copyright (c) 2025 Kemal Crisannaufal, Wikky Fawwaz Al Maki

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Authors who publish with this journal agree to the following terms:
- Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a Creative Commons Attribution-ShareAlikel 4.0 International (CC BY-SA 4.0) that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See The Effect of Open Access).