Implementation of RFM Method and K-Means Algorithm for Customer Segmentation in E-Commerce with Streamlit

Farrikh Alzami(1*); Fikri Diva Sambasri(2); Mira Nabila(3); Rama Aria Megantara(4); Ahmad Akrom(5); Ricardus Anggi Pramunendar(6); Dwi Puji Prabowo(7); Puri Sulistiyawati(8);

(1) Universitas Dian Nuswantoro
(2) Universitas Dian Nuswantoro
(3) Universitas Dian Nuswantoro
(4) Universitas Dian Nuswantoro
(5) Universitas Dian Nuswantoro
(6) Universitas Dian Nuswantoro
(7) Universitas Dian Nuswantoro
(8) Universitas Dian Nuswantoro
(*) Corresponding Author



E-commerce is selling and buying goods through an online or online system. One of the business models in which consumers sell products to other consumers is the Customer to Customer (C2C) business model. One thing that needs to be considered in the business model is knowing the level of customer loyalty. By knowing the level of customer loyalty, the company can provide several different treatments to its customers to maintain good relationships with customers and increase product purchase revenue. In this study, the author wants to segment customers on data in E-commerce companies in Brazil using the K-Means clustering algorithm using the RFM (Recency, Frequency, Monetary) feature and display it in the form of a dashboard using the Streamlit framework. Several stages of research must be carried out. Firstly, taking data from the open public data site (Kaggle), then merging the data to select some data that needs to be used, understanding data by displaying it in graphic form, and conducting data selection to select features/attributes. The step follows the proposed method, performs data preprocessing, creates a model to get the cluster, and finally displays it as a dashboard using Streamlit. Based on the results of the research that has been done, the number of clusters is 4 clusters with the evaluation value of the model using the silhouette score is 0.470.


E-Commerce; Customer Segmentation; K-Means; RFM; Streamlit


Full Text:


Article Metrics

Abstract view: 758 times
PDF view: 271 times

Digital Object Identifier




S. Palingi and E. C. Limbongan, “Pengaruh internet terhadap industri E-Commerce dan regulasi perlindungan data,” in Seminar Nasional Riset dan Teknologi (SEMNAS RISTEK), 2020.

APJII, “Penetrasi & profil perilaku pengguna internet Indonesia,” in Asosiasi Penyelenggara Jasa Internet Indonesia, 2018.

G. Liu, “An ecommerce recommendation algorithm based on link prediction,” Alexandria Engineering Journal, vol. 61, no. 1, pp. 905–910, Jan. 2022, doi: 10.1016/j.aej.2021.04.081.

S. Monalisa, P. Nadya, and R. Novita, “Analysis for Customer Lifetime Value Categorization with RFM Model,” Procedia Comput Sci, vol. 161, pp. 834–840, 2019, doi: 10.1016/j.procs.2019.11.190.

Huynh T. K., le H.-D, Nguyen S. V., and Tran H. M., “Applying Peer-to-Peer Networks for Decentralized Customer-to-Customer Ecommerce Model,” in International Conference on Future Data and Security Engineering, 2020.

Olist, “About Olist,” Available:, Jul. 18, 2022.

Latifah N, Widayani A, and Normawati R. A, “Pengaruh perceived usefulness dan trust terhadap kepuasan konsumen pada E-Commerce Shopee,” Jurnal Bisnis dan Manajemen, vol. 14, p. 84, 2020.

R. Heldt, C. S. Silveira, and F. B. Luce, “Predicting customer value per product: From RFM to RFM/P,” J Bus Res, vol. 127, pp. 444–453, Apr. 2021, doi: 10.1016/j.jbusres.2019.05.001.

M. A. Rahim, M. Mushafiq, S. Khan, and Z. A. Arain, “RFM-based repurchase behavior for customer classification and segmentation,” Journal of Retailing and Consumer Services, vol. 61, p. 102566, Jul. 2021, doi: 10.1016/j.jretconser.2021.102566.

V. Holý, O. Sokol, and M. Černý, “Clustering retail products based on customer behaviour,” Appl Soft Comput, vol. 60, pp. 752–762, Nov. 2017, doi: 10.1016/j.asoc.2017.02.004.

Puspitasari N, Widians J. A, and Setiawan N. B, “Segmentasi pelanggan menggunakan algoritme Bisecting K-Means berdasarkan model Recency, Frequency, dan Monetary (RFM),” Jurnal Teknologi dan Sistem Komputer, vol. 8, pp. 78–79, 2020.

P. Anitha and M. M. Patil, “RFM model for customer purchase behavior using K-Means algorithm,” Journal of King Saud University - Computer and Information Sciences, vol. 34, no. 5, pp. 1785–1792, May 2022, doi: 10.1016/j.jksuci.2019.12.011.

Y. Li, X. Chu, D. Tian, J. Feng, and W. Mu, “Customer segmentation using K-means clustering and the adaptive particle swarm optimization algorithm,” Appl Soft Comput, vol. 113, p. 107924, Dec. 2021, doi: 10.1016/j.asoc.2021.107924.

Boentarman M, Rostianingsih S, and Setiawan A, “Penerapan segmentasi pelanggan dengan menggunakan metode K-Means Clustering pada Sistem Customer Relationship Management di PT Titess,” Jurnal Infra, p. 2, 2021.

Berahmana R, Mohammed F. A, and Chairuang K, “Customer segmentation based on RFM model using K-Means, K-Medoids, and DBSCAN methods,” Lontar Komputer, vol. 11, pp. 32–38, 2022.


  • There are currently no refbacks.

Copyright (c) 2023 Farrikh Alzami, Fikri Diva Sambasri, Mira Nabila, Rama Aria Megantara, Ahmad Akrom, Ricardus Anggi Pramunendar, Dwi Puji Prabowo, Puri Sulistiyawati

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