## 1 Introduction  
With the evolution of information technology in the 1990s, large companies adopted management systems in the form of enterprise resource planning (ERP) software [1]. This software helps in their routines at the operational level, whether in inventory control, tax, financial, transactions, and even human resources. As a result of this, a level of efficiency never conceived was reached, since records previously made on paper and pen began to be produced automatically. In parallel with the computerization of these processes, there was also a growth in the amount of data stored relating to products, customers, transactions, expenses, and revenues [2]. In this context, direct marketing tactics were also advanced, such as sending catalogs by mail, up to highly targeted offers to selected individuals whose transaction information was present in the database. The focus of company-customer relationships then turned to customers who already have a record with the company, since the cost of acquiring a new customer through advertising is much higher than the cost of nurturing an existing relationship [3]. With the increase in the amount of data and the manual work required for segmentation [4], [PERSON] et al. [5] state that the automation of this process has become indispensable, and one of its main techniques is clustering. This technique consists of categorizing unlabeled data into groups called clusters, whose members are similar to each other and different from members of other clusters, based on the characteristics analyzed. The cluster methods are increasingly being used for several applications [6; 7; 8; 9]. As presented in [10; 11], state-of-the-art clustering methods can be inspired by the behaviors of animals. Among the clustering algorithms, the K-means algorithm is one of the most popular, being simple to implement and having extensive studies on its behaviors. In the context of evaluation, [PERSON], [PERSON], and [PERSON] [12] point out that the quality of a solution can be measured through validation indices, which consider the compactness of the cluster data and their separation with other clusters, allowing a higher degree of certainty to be obtained when evaluating a segmentation result coming from a clustering algorithm. Given the importance of customer segmentation, and extracting their behavioral characteristics effectively, this paper presents the creation of a prototype that uses the attributes of recency, frequency, monetary value (RFM) with the K-means clustering algorithm. It automatically extracts information from a real retail database to identify different customer segments based on their behavior. To validate the number of clusters, three internal indexes and three external indexes: global stability, stability per cluster, and segment-level stability across solutions (SLSa), were used to highlight the quality of the solutions obtained [13]. The main contribution of this work concerns the application of external validation algorithms, since internal validation algorithms proved to be incoherent in their suggestions for the database used. Furthermore, in the research process of references for the work, few works were found that use even one external validation algorithm, and this work used three, establishing a line of reasoning between the results presented by the indices. Part of the value of this work resides in the evolution process between the choices for validating the number of clusters, as well as its application in a set of data coming from customers and real purchases. This paper presents an alternative for when the internal indexes fail in their congruence; in this context, K-means clustering (with external indexes) presents better replicability and stability of clusters, focusing on analyzing the optimal number of clusters. Considering the evaluation of the number of clusters, the K-medoids and MiniBatch K-means were compared to the standard K-means. The K-medoids algorithm differs from K-means on the issue of centroids for calculating the center point of the cluster.