Application of the K-Nearest Neighbor Algorithm in the Data Mining Process to Predict Drug Sales at Pratama Haji Medan-Pancing Clinic
Keywords:
K-Nearest Neighbor, data mining, sales prediction, drug inventoryAbstract
Pratama Haji Medan-Pancing Clinic is a healthcare facility that routinely sells medications to patients. However, the current manual drug inventory management process poses risks such as delayed procurement and overstocking. To address this issue, this study aims to implement a data mining approach using the K-Nearest Neighbor (KNN) algorithm to predict drug sales at Klinik Pratama Haji Medan-Pancing. A quantitative research method was employed, utilizing historical drug sales data from the past two to three years. The data underwent a thorough process of assessment, cleaning, and transformation before being processed using the K-Neighbor Classifier from the scikit-learn library. The results demonstrated that the KNN method achieved a prediction accuracy rate of 88.9%, indicating its effectiveness in forecasting drug sales. By implementing this predictive system, Klinik Pratama Haji Medan-Pancing can improve the efficiency of inventory management, reduce the risk of stock shortages or surpluses, and support faster, data-driven decision-making. In conclusion, the KNN algorithm proves to be a feasible predictive solution for drug sales systems in clinics and holds potential for further development in intelligent and integrated pharmacy management.
References
[1] U. A. Putri, A. B. Prasetijo, and C. T. Purnami, “Sistem informasi manajemen logistik obat di pelayanan farmasi puskesmas: Literature review,” Media Publ. Promosi Kesehat. Indones., vol. 6, no. 6, pp. 1016–1024, 2023.
[2] F. Farahdinna and M. N. Shofy, “IMPLEMENTASI K-NEAREST NEIGHBOR UNTUK KLASIFIKASI BUNGA IRIS,” JATI (Jurnal Mhs. Tek. Inform., vol. 9, no. 2, pp. 3510–3514, 2025.
[3] A. A. Baihaqi and M. Fakhriza, “K-Nearest Neighbors (KNN) to Determine BBRI Stock Price,” Sist. J. Sist. Inf., vol. 14, no. 2, pp. 969–984, 2025.
[4] A. Andri, “Penerapan Algoritma K-Nearest Neighbor Untuk Prediksi Penjualan Obat Pada Apotek Kimia Farma Atmo Palembang,” in Bina Darma Conference on Computer Science (BDCCS), 2020, pp. 199–208.
[5] R. Rismala, I. Ali, and A. R. Rinaldi, “Penerapan Metode K-Nearest Neighbor Untuk Prediksi Penjualan Sepeda Motor Terlaris,” JATI (Jurnal Mhs. Tek. Inform., vol. 7, no. 1, pp. 585–590, 2023.
[6] R. F. Putra et al., Data Mining: Algoritma dan Penerapannya. PT. Sonpedia Publishing Indonesia, 2023.
[7] S. Sudirwo et al., Artificial Intelligence: Teori, Konsep, dan Implementasi di Berbagai Bidang. PT. Sonpedia Publishing Indonesia, 2025.
[8] A. Wibowo, “Cara Mudah Menganalisis Big Data,” Penerbit Yayasan Prima Agus Tek., pp. 1–159, 2024.
[9] V. P. Virza, G. T. Pranot, and F. E. Putra, “Klasifikasi Kebutuhan Sparepart Dengan Algoritma K-Nearest Neighbor Untuk Meningkatkan Penjualan Sparepart,” Bull. Inf. Technol., vol. 4, no. 3, pp. 287–293, 2023.
[10] M. S. Safira, N. Rahaningsih, and R. D. Dana, “Penerapan Data Mining Untuk Klasifikasi Penjualan Obat Menggunakan Metode K-Nearest Neighbor,” JATI (Jurnal Mhs. Tek. Inform., vol. 8, no. 1, pp. 380–385, 2024.
[11] P. H. Putra and M. S. Novelan, “PERANCANGAN APLIKASI PENENTUAN KUALITAS SAYURAN BERDASARKAN WARNA MENGGUNAKAN DATA MINING,” in Scenario (Seminar of Social Sciences Engineering and Humaniora), 2021, pp. 103–109.
[12] D. W. Azhari, Z. Sitorus, and Z. Zulfahmi, “APPLICATION OF K-NEAREST NEIGHBOR METHOD IN CLASSIFICING THE RATE OF PAPAYA MURABILITY BASED ON FRUIT COLOR FORM,” INFOKUM, vol. 10, no. 02, pp. 1247–1255, 2022.
[13] F. Amalini and A. M. L. Harefa, “Application of Linear Regression Method in Predicting Veil Sales (Case Study: Fauzan Kerudung Shop),” J. Data Sci. Technol. Artif. Intell., vol. 1, no. 1, pp. 13–17, 2024.
[14] J. C. Mestika, M. O. Selan, and M. I. Qadafi, “Menjelajahi Teknik-Teknik Supervised Learning untuk Pemodelan Prediktif Menggunakan Python,” vol, vol. 99, pp. 216–219, 2022.
[15] W. Yustanti, “Algoritma K-Nearest Neighbour untuk Memprediksi Harga Jual Tanah,” J. Mat. Stat. dan Komputasi, vol. 9, no. 1, pp. 57–68, 2012.
[16] A. A. Nababan, M. Jannah, and A. H. Nababan, “Prediction Of Hotel Booking Cancellation Using K-Nearest Neighbors (K-Nn) Algorithm And Synthetic Minority Over-Sampling Technique (Smote),” INFOKUM, vol. 10, no. 03, pp. 50–56, 2022.
[17] M. Jannah, A. A. Nababan, and Y. S. Ningsi, “Penerapan Metode K-Nearest Neighbor Dalam Identifikasi Jenis Ikan Salmon Yang Dapat Dikomsumsi Untuk Bahan Mpasi Bayi,” J. Teknol. Sist. Inf. dan Sist. Komput. TGD, vol. 6, no. 2, pp. 636–644, 2023.
[18] S. Mulyati, S. M. Husein, and R. Ramdhan, “Rancang bangun aplikasi data mining prediksi kelulusan ujian nasional menggunakan Algoritma (Knn) K-Nearest Neighbor dengan metode Euclidean Distance pada SMPN 2 Pagedangan,” JIKA (Jurnal Inform., vol. 4, no. 1, pp. 65–73, 2020.
[19] D. Normawati and S. A. Prayogi, “Implementasi Naïve Bayes classifier dan confusion matrix pada analisis sentimen berbasis teks pada Twitter,” J-SAKTI (Jurnal Sains Komput. dan Inform., vol. 5, no. 2, pp. 697–711, 2021.
[20] A. A. Putri, “Perbandingan Metode Naive Bayes, KNN dan SVM pada Analisis Sentimen Jasa Transportasi Online= Comparison of Naive Bayes, KNN dan SVM for Sentiment Analysis of Online Transportation Services.” Universitas Hasanuddin, 2023.
[21] S. F. Amrilah, D. Krisbiantoro, and A. Prasetyo, “Penerapan Metode K-Nearest Neighbors dan Naïve Bayes pada Analisis Sentimen Pengguna Aplikasi Bstation melalui Platform Playstore,” 2024.
[22] F. Sulianta, Dasar & Konsep Data Science. Feri Sulianta, 2024.
[23] R. G. Whendasmoro and J. Joseph, “Analisis Penerapan Normalisasi Data Dengan Menggunakan Z-Score Pada Kinerja Algoritma K-NN.” 2022.
[24] S. E. Saqila, I. P. Ferina, and A. Iskandar, “Analisis Perbandingan Kinerja Clustering Data Mining Untuk Normalisasi Dataset,” J. Sist. Komput. dan Inform. Hal, vol. 356, p. 365, 2023.
[25] M. R. A. Prasetya and A. M. Priyatno, “Penanganan Imputasi Missing Values pada Data Time Series dengan Menggunakan Metode Data Mining,” J. Inf. Dan Teknol., pp. 52–62, 2023.
[26] A. Pratiwi, A. T. Sasongko, and D. K. Pramudito, “ANALISIS PREDIKSI GILINGAN PLASTIK TERLARIS MENGGUNAKAN ALGORITMA K-NEAREST NEIGHBOR DI CV MENEMBUS BATAS,” J. Inform. Teknol. dan Sains, vol. 5, no. 3, pp. 437–445, 2023.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2025 Jurnal Publikasi Ilmu Komputer dan Multimedia

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