Segmentation of Coffee Purchasing Behavior Based on Transaction Time Using the K-Means Algorithm - Yuslia Devitri; Nining Rahaningsih; Irfan Ali; Willy Prihartono (Journal of Artificial Intelligence and Engineering Applications (JAIEA), 2026)
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.