Implementation of the K-Means Algorithm for Analyzing Patient Visits at the Kupang Community Health Center
DOI:
https://doi.org/10.36456/gq35bd74Keywords:
K-Means Clustering, Data Mining, Community Health Center, Patient Visits, PyCaret, Elbow MethodAbstract
Patient visit data at community health centers are still managed manually, making it difficult for healthcare workers to identify visit patterns and make informed decisions. This study applies the K-Means Clustering algorithm to group patient visit data at Puskesmas Kupang based on insurance type, visit category, clinic or ward, and patient age group. The dataset consists of thousands of patient visit records, with six key features selected through three feature engineering experiments. Preprocessing involved data cleaning and Label Encoding, while the clustering process was configured using PyCaret with normalization, two-component PCA dimensionality reduction to address inter-feature correlation and enable visual cluster representation and outlier removal. The optimal number of clusters was set to four using the Elbow Method. The best-performing model achieved a Silhouette Score of 0.6558, indicating good clustering quality. The four resulting clusters represent patient segments with distinct profiles: adult BPJS users accessing the general clinic, young productive-age patients utilizing Maternal and Child Health services, patients with unplanned service needs, and elderly patients with routine visit patterns. The findings confirm that K-Means is effective as a patient classification tool at community health centers, supporting data-driven decision-making for healthcare personnel.
References
[1] Q. Cheng et al., “Determinants of healthcare utilization under the Indonesian national health insurance system – a cross-sectional study,” BMC Health Serv. Res., vol. 25, no. 1, p. 48, Jan. 2025, doi: 10.1186/s12913-024-11951-8.
[2] S. Maulia, B. Serasi Ginting, and A. Sihombing, “IMPLEMENTASI DATA MINING PENGELOMPOKAN JENIS PENYAKIT PASIEN MENGGUNAKAN METODE CLUSTERING (STUDI KASUS : PUSKESMAS SAMBIREJO),” JIK), vol. 5, no. 1, 2021.
[3] L. Mayola, M. Hafizhb, and H. S. Syahputra, “Klasterisasi Rumah Sakit berdasarkan Kunjungan Pasien menggunakan Algoritma K-Means: Data 2019-2023,” Jurnal Teknologi Dan Sistem Informasi Bisnis, vol. 7, no. 1, pp. 15–21, Jan. 2025, doi: 10.47233/jteksis.v7i1.1703.
[4] M. Hafiz Ziqrullah, S. Dian Purnamasari, and I. Zuhri Yadi, “Clustering Data Penyakit Pasien Pada Puskesmas Mulyaguna Menggunakan Algoritma K-Means,” 2024.
[5] M. Ahmed, R. Seraj, and S. M. S. Islam, “The k-means algorithm: A comprehensive survey and performance evaluation,” Aug. 01, 2020, MDPI AG. doi: 10.3390/electronics9081295.
[6] W. C. Yang, J. P. Lai, Y. H. Liu, Y. L. Lin, H. P. Hou, and P. F. Pai, “Using Medical Data and Clustering Techniques for a Smart Healthcare System,” Electronics (Switzerland), vol. 13, no. 1, Jan. 2024, doi: 10.3390/electronics13010140.
[7] N. Laila Hasanah, A. Ahadi Ningrum, and F. Dona Marleny, “PENERAPAN K-MEANS CLUSTERING MENENTUKAN LOKASI PROMOSI PENERIMAAN MAHASISWA BARU UNIVERSITAS MUHAMMADIYAH BANJARMASIN,” vol. 12, no. 2, Jun. 2025.
[8] M. Noval, F. Dona Marleny, T. Informatika, U. Muhammadiyah Banjarmasin, and K. Selatan, “Implementasi Algoritma K-Means Untuk Analisis Pola Penjualan Pada Toko Monisa,” Jurnal Media Informatika, vol. 6, no. 3, Aug. 2025.
[9] A. Aljohani, “Optimizing Patient Stratification in Healthcare: A Comparative Analysis of Clustering Algorithms for EHR Data,” International Journal of Computational Intelligence Systems, vol. 17, no. 1, p. 173, Jul. 2024, doi: 10.1007/s44196-024-00568-8.
[10] A. Herlin Lutfiannisa, M. Maimunah, and P. Sukmasetya, “Clustering Data Pasien Berdasarkan Usia di Puskesmas Menerapkan Metode K-Means,” Journal of Information System Research (JOSH), vol. 5, no. 2, pp. 639–647, Jan. 2024, doi: 10.47065/josh.v5i2.4755.
[11] B. Hadi Prakoso et al., “Klasterisasi Puskesmas dengan K-Means Berdasarkan Data Kualitas Kesehatan Keluarga dan Gizi Masyarakat,” 2023.
[12] D. Zerlinda Ardini, “Analisis Pola Penyakit Kronis pada Lansia Menggunakan K-Means Clustering di Puskesmas Kelurahan Semper Barat,” 2025. [Online]. Available: https://journal.stmiki.ac.id
[13] F. Bolikulov, R. Nasimov, A. Rashidov, F. Akhmedov, and Y.-I. Cho, “Effective Methods of Categorical Data Encoding for Artificial Intelligence Algorithms,” Mathematics, vol. 12, no. 16, p. 2553, Aug. 2024, doi: 10.3390/math12162553.
[14] P. P. Pane, Y. Ramadhan Nasution, and Mhd. Furqan, “Implementasi Data Mining dengan K-Means Clustering untuk Memprediksi Pengadaan Obat,” Journal of Computer System and Informatics (JoSYC), vol. 5, no. 2, pp. 286–296, Feb. 2024, doi: 10.47065/josyc.v5i2.4920.
[15] C. Shi, B. Wei, S. Wei, W. Wang, H. Liu, and J. Liu, “A quantitative discriminant method of elbow point for the optimal number of clusters in clustering algorithm,” EURASIP J. Wirel. Commun. Netw., vol. 2021, no. 1, p. 31, Dec. 2021, doi: 10.1186/s13638-021-01910-w.
[16] I. F. Ashari, E. Dwi Nugroho, R. Baraku, I. Novri Yanda, and R. Liwardana, “Analysis of Elbow, Silhouette, Davies-Bouldin, Calinski-Harabasz, and Rand-Index Evaluation on K-Means Algorithm for Classifying Flood-Affected Areas in Jakarta,” Journal of Applied Informatics and Computing, vol. 7, no. 1, pp. 89–97, Jul. 2023, doi: 10.30871/jaic.v7i1.4947.
Downloads
Published
Issue
Section
License
Copyright (c) 2026 Mahendra Adi Kusuma, Finki Dona Marleny, Ayu Ahadi Ningrum

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











