Penerapan Algoritma k-Nearest Neighbor untuk Klasifikasi Kondisi Lingkungan Pertanian Berbasis IoT
Penelitian
DOI:
https://doi.org/10.31004/jerkin.v4i3.4566Keywords:
Classification, Internet Of Things, K-Nearest Neighbor, Smart AgricultureAbstract
The development of the Internet of Things (IoT) has encouraged the adoption of smart technologies in agriculture to enable real-time environmental monitoring. This study aims to apply the k-Nearest Neighbor (k-NN) algorithm to classify agricultural environmental conditions into ideal and non-ideal categories based on IoT sensor data. The dataset used in this research was obtained from an open-source repository and consists of several environmental parameters, including temperature, humidity, and soil moisture. The research stages include data preprocessing, attribute and label determination, data normalization using the z-transformation method, and model evaluation through cross validation. The performance of the classification model was assessed using accuracy, precision, recall, and F-measure metrics. The experimental results indicate that the k-NN algorithm is capable of providing good classification performance in identifying agricultural environmental conditions. However, limitations were observed in detecting minority class instances, suggesting the need for further parameter optimization and model enhancement. This research is expected to serve as a foundation for the development of IoT-based smart agriculture systems to support more effective decision-making in agricultural environmental management.
References
P. Sistem, P. Suhu, and D. A. N. Kelembapan, “IMPLEMENTASI ALGORITMA K-NEAREST NEIGHBOR,” vol. 12, no. 3, 2024.
R. Akhter and S. Sofi, “Precision Agriculture using IoT Data Analytics and Machine Learning,” J. King Saud Univ. - Comput. Inf. Sci., vol. 34, Jun. 2021, doi: 10.1016/j.jksuci.2021.05.013.
S. Farming, “Smart Farming,” 2020.
S. Mansoor, S. Iqbal, and S. M. Popescu, “Integration of smart sensors and IOT in precision agriculture : trends , challenges and future prospectives,” no. May, pp. 1–21, 2025, doi: 10.3389/fpls.2025.1587869.
D. Muhammed, E. Ahvar, S. Ahvar, M. Trocan, and M. Montpetit, “Journal of Network and Computer Applications Artificial Intelligence of Things ( AIoT ) for smart agriculture : A review of architectures , technologies and solutions,” J. Netw. Comput. Appl., vol. 228, no. July 2023, p. 103905, 2024, doi: 10.1016/j.jnca.2024.103905.
S. Mehta, “Precision Agriculture Using Internet of Things and Machine Learning,” 2018.
A. R. Kumar, “J OURNAL OF A DVANCED Z OOLOGY Machine learning for IoT-based smart farming,” vol. 44, pp. 1294–1298, 2023.
N. Aziza and R. Y. Astuti, “Application of The K-Nearest Neighbor Algorithm for Food Security Classification In Central Java Province Penerapan Algoritma K-Nearest Neighbor untuk Klasifikasi Ketahanan Pangan di Provinsi Jawa Tengah,” vol. 4, no. April, pp. 404–412, 2024.
L. Syed, “ScienceDirect Smart Agriculture Agriculture using using Ensemble Ensemble Machine Machine Learning Learning Techniques Techniques in in Smart IoT Environment Environment IoT,” Procedia Comput. Sci., vol. 235, pp. 2269–2278, 2024, doi: 10.1016/j.procs.2024.04.215.
E. Sumartono, A. W. Sanjaya, S. Sugiardi, J. Budiasto, and Y. M. Ningsih, “International Journal for Science Review Smart Farming and Precision Agriculture : Leveraging IoT and Data Analytics to Improve Crop Efficiency and Sustainability,” vol. 2, pp. 10–20, 2025.
R. Oryza and S. L. Cultivation, “IoT-Enabled K-Nearest Neighbors ( KNN ) -Based Soil Nutrient Recommendation,” vol. 19, no. 2, pp. 151–165, 2025.
J. Teknologi and D. A. N. Open, “Classification Of Rice Plant Diseases Using K-Nearest Neighbor Algorithm Based On Hue Saturation Value Color Extraction And Gray Level Co-Occurrence Matrix Features,” vol. 7, no. 2, pp. 212–223, 2025, doi: 10.36378/jtos.v7i2.3972.
S. Sahibu, T. Imran, and A. Oktafiandi, “Crop Recommendation Based on Soil and Weather Conditions Using the K-Nearest Neighbors Algorithm,” vol. 6, no. 3, pp. 211–219, 2025.
P. H. Putra, M. S. Novelan, and M. Rizki, “ANALYSIS K-NEAREST NEIGHBOR METHOD IN CLASSIFICATION OF VEGETABLE QUALITY BASED ON COLOR,” vol. 3, no. 2, pp. 126–132, 2022.
I. G. I. Sudipa, R. A. Azdy, I. Arfiani, and N. M. Setiohardjo, “Leveraging K-Nearest Neighbors for Enhanced Fruit Classification and Quality Assessment,” vol. 5, no. 1, pp. 30–36, 2024.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2025 Panji Pangestu Saputra, Hasbi Firmansyah, Rizki Prasetyo Tulodo, Priyo Haryoko, Wahyu Asriyani

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.












