Segmentation of Coffee Purchasing Behavior Based on Transaction Time Using the K-Means Algorithm
DOI:
https://doi.org/10.59934/jaiea.v5i2.1863Keywords:
K-Means; Transaction Time; Coffee Purchasing Pattern; Clustering; Data MiningAbstract
This studyaims to identify customer behavior patterns based on the time of purchaseof beverages at a coffee shop using the K-Means method.Transaction data includes purchase time, payment type, product name,time category, day, and month. The research stages include data cleaning, time attribute transformation, and numerical feature normalization. The optimal number of clustersis determined through testing k = 2–10 with four evaluation metrics,namely Inertia, Silhouette Score, Davies–Bouldin Index, and Calinski–HarabaszIndex. Based on the validation results, k = 3 was selected because it provided the best balancebetween compactness and cluster separation. The clustering results showedthree main customer groups based on transaction time trends:nighttime buyers with a peak around 10:27 p.m., afternoon to early evening buyerswith a centroid of 7:01 p.m., and morning to noon buyers with a centroid11:13. The frequency distribution indicates that the morning–afternoon buyer groupis the largest, while the early evening–night group is thesmallest. Visualization of scatter plots, boxplots, and time category graphsemphasizes the differences in characteristics between clusters. Overall,this study proves that K-Means is effective in mapping the temporal patternsof customer behavior. These findings can be used to develop time-based marketing strategies, operational arrangements, and product stock management,as well as form the basis for further analysis in the industry.
Downloads
References
D. Giordano, M. Mellia, and T. Cerquitelli, “K-MDTSC: K-multi-dimensional time-series clustering algorithm,” Electronics, vol. 10, no. 10, p. 1166, 2021.
H. Liu, J. Wang, R. Zhang, and O. Liu, “Does the weather still affect me when I shop at home? The impact of weather on online shopping behavior,” J. Theor. Appl. Electron. Commer. Res., vol. 19, no. 3, pp. 2289–2311, 2024.
Z. Liang, “Wake up and search for coffee: Considering the circadian rhythm of consumers on online purchase behavior,” J. Bus. Res., vol. 157, p. 113536, 2024.
K. Tabianan, S. Velu, and V. Ravi, “K-Means clustering approach for intelligent customer segmentation using customer purchase behavior data,” Sustainability, vol. 14, no. 12, p. 7243, 2022.
D. A. Awaliyah, B. Prasetiyo, R. Muzayanah, and A. D. Lestari, “Optimizing customer segmentation in online retail transactions through the implementation of the K-Means clustering algorithm,” Sci. J. Informatics, vol. 11, no. 2, 2024.
A. Silva and M. Wang, “Visual analysis of e-commerce user behavior based on time series logs,” J. Sensors, vol. 2022, p. 4291978, 2022.
R. Autio and et al., “Tensorial principal component analysis in detecting temporal trajectories of purchase patterns in loyalty card data: Retrospective cohort study,” J. Med. Internet Res., vol. 25, no. 1, p. e44599, 2023.
C. Fan, M. Chen, and X. Wang, “A review on data preprocessing techniques toward efficient and reliable knowledge discovery from building operational data,” Front. Energy Res., vol. 9, 2021.
J. Wen, L. Guillen, T. Abe, and T. Suganuma, “A hierarchy-based system for recognizing customer activity in retail environments,” Sensors, vol. 21, no. 14, p. 4712, 2021.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 Journal of Artificial Intelligence and Engineering Applications (JAIEA)

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








