Data Integrated K-Means Clustering And Random Forest Classification For Crop Recommendation Based On Environmental Parameters

Authors

DOI:

https://doi.org/10.37802/

Keywords:

K-Means Clustering, Random Forest, Crop Recommendation, Classification, Machine Learning

Abstract

The agricultural sector plays a strategic role in Indonesia’s economy, yet inappropriate crop selection under specific environmental conditions can reduce yields and cause economic losses. Existing studies commonly apply individual classifiers to environmental data, while clustering is often used only for descriptive analysis. This study proposes an integrated two-stage pipeline combining K-Means clustering and Random Forest classification for crop recommendation. First, K-Means groups 22 crop types based on four environmental parameters: temperature, humidity, soil pH, and rainfall. The resulting cluster membership is then encoded as an additional categorical feature and combined with normalized environmental features for Random Forest classification. Experiments using 2,200 samples from Kaggle identified four clusters, achieving a Davies–Bouldin Index of 0.84 and a Silhouette Score of 0.61. The integrated model achieved 97.7% test accuracy, with precision, recall, and F1-score of 0.99, outperforming the Random Forest baseline accuracy of 96.9%. These findings demonstrate the potential benefits of incorporating unsupervised cluster information into supervised classification. This approach offers a reusable feature-augmentation framework for agricultural intelligent decision support systems.

Downloads

Download data is not yet available.

References

[1] M. A. Helmy, M. ElBahnasawy, and G. Fahim, “Crop recommendation model using machine learning for Egyptian agriculture,” Int. J. Adv. Comput. Sci. Appl., vol. 13, no. 5, pp. 512–520, 2022, doi: 10.14569/IJACSA.2022.0130562.

[2] R. Sujatha, P. Isakki, and S. Sivagami, “Smart crop recommendation system using Internet of Things and machine learning,” Sustain. Comput. Informatics Syst., vol. 38, p. 100869, 2023, doi: 10.1016/j.suscom.2023.100869.

[3] A. Aryanti and N. Iryani, “A Smart Recommendation System for Crop Seed Selection Using Gradient Boosting Based on Environmental and Geospatial Data,” vol. 9, no. 6, pp. 2965–2973, 2025.

[4] A. Vij, S. Vijendra, A. Jain, S. Bajaj, A. Bassi, and A. Sharma, “IoT and machine learning approaches for automation of farm irrigation system,” in Procedia Computer Science, 2022, pp. 2250–2257. doi: 10.1016/j.procs.2022.06.305.

[5] M. Abdulazeez, A. Zeebaree, D. Zebari, and H. Haron, “A review of K-means clustering challenges and its proposed solutions,” Int. J. Eng. Technol., vol. 14, no. 2, pp. 422–430, 2022, doi: 10.21817/ijet/2022/v14i2/221402057.

[6] R. Bhosale, R. Patil, S. Patil, and A. Patil, “Crop recommendation system using machine learning,” Int. J. Eng. Res. Technol., vol. 11, no. 4, pp. 1–5, 2022, doi: 10.17577/IJERTV11IS040199.

[7] K. Patel, D. Patel, H. Patel, and M. Shah, “A machine learning approach for crop recommendation based on soil and climatic conditions,” J. Phys. Conf. Ser., vol. 2570, p. 12013, 2023, doi: 10.1088/1742-6596/2570/1/012013.

[8] A. Sharma, “Machine learning applications for precision agriculture,” IEEE Access, vol. 9, pp. 4843–4873, 2021, doi: 10.1109/ACCESS.2020.3048415.

[9] A. A. Durai and S. Abirami, “Application of machine learning in smart agriculture for crop recommendation,” J. Phys. Conf. Ser., vol. 1767, p. 12022, 2021, doi: 10.1088/1742-6596/1767/1/012022.

[10] T. Van Klompenburg, A. Kassahun, and C. Catal, “Crop yield prediction using machine learning: A systematic literature review,” Comput. Electron. Agric., vol. 177, p. 105709, 2022, doi: 10.1016/j.compag.2020.105709.

[11] IRRI, “Rice Knowledge Bank – Climate Requirements,” 2022.

[12] S. A. Ezugwu, A. K. Shukla, R. Nath, O. J. Agbaje, R. Abubakar, and S. Kaur, “Automatic clustering algorithms: A systematic review and bibliometric analysis of relevant literature,” Neural Comput. Appl., vol. 33, pp. 6247–6306, 2022, doi: 10.1007/s00521-021-05869-7.

[13] V. No et al., “Infotek : Jurnal Informatika dan Teknologi Evaluasi Kinerja Algoritma K-Means dan K-Medoids untuk Klasterisasi Destinasi Wisata Bali Provinsi Bali vol. 9, no. 2, pp. 583–594, 2026.

[14] A. Aryanti, F. D. Wulandari, and M. Rafiif, “Segmentasi dan Klasifikasi Risiko Perdarahan dengan Algoritma K-Means dan Naive Bayes Berdasarkan Data Klinis dan Transfusi,” vol. 7, no. 2, pp. 211–219, 2025.

[15] W. Firdaus, P. Aditya, and R. Parlika, “K-Means Algorithm Application for Clustering Recent University Graduates According to Work Readiness Indicators,” vol. 8, no. 1, pp. 95–104, 2026.

[16] H. Tyralis, G. Papacharalampous, and A. Langousis, “A brief review of random forests for water scientists and practitioners and their recent history in water resources,” Water, vol. 11, no. 5, p. 910, 2024, doi: 10.3390/w11050910.

[17] A. M. Prasad, L. R. Iverson, and A. Liaw, “Newer classification and regression tree techniques: Bagging and random forests for ecological prediction,” Ecosystems, vol. 9, no. 2, pp. 181–199, 2023, doi: 10.1007/s10021-005-0054-1.

[18] I. M. A. Sudestra, A. Wahyudi, O. Gama, and G. H. Prathama, “Comparative Performance of Machine Learning Algorithms for Diabetes Prediction,” vol. 8, no. 1, pp. 50–61, 2026.

[19] F. Algorithm Aryanti et al., “Klasifikasi Tempat Wisata Di Yogyakarta Berdasarkan Harga Dan Rating Menggunakan Algoritma Random Forest Classification of Tourist Attractions in Yogyakarta Based on Price and Rating Using the Random,” Juni, vol. 18, no. 2, pp. 192–204, 2026, doi.org/10.22303/csrid.18.2.2026.192-204

[20] C. Sammut and G. I. Webb, Encyclopedia of Machine Learning and Data Mining, 2nd ed. New York, NY: Springer, 2022.

[21] A. Aryanti, A. T. Putri, A. Khairunisya, I. Y. Pratama, and P. N. Azizah, “Klasifikasi Tempat Wisata Di Yogyakarta Berdasarkan Harga Dan Rating Menggunakan Algoritma Random Forest,” vol. 18, no. 2, pp. 192–204, 2026.

[22] N. Sehgal, S. Chaudhary, and H. Bansal, “Crop recommendation using machine learning: A review,” in Proc. Int. Conf. Artificial Intelligence and Smart Systems (ICAIS), 2022, pp. 1022–1027. doi: 10.1109/ICAIS53314.2022.9742957.

[23] F. Ahmed, M. S. Kabir, and M. A. Hossain, “Water availability and crop selection: A machine learning approach for arid regions,” Agric. Water Manag., vol. 281, p. 108258, 2023, doi: 10.1016/j.agwat.2023.108258.

Downloads

Published

2026-10-23