## 3 Prototype Description
### Global Stability  
With the uncertainty generated by the internal validation indexes, it is necessary to acquire other views on the dataset, so that it is possible to ensure an optimal number of clusters with an acceptable margin of certainty [54]. External validation indices were \begin{table}
\begin{tabular}{c c c} \hline \hline  & RF01 & \begin{tabular}{c} Acquire the transaction data of customers from \\ a database. \\ \end{tabular} \\ \cline{2-3}  & RF02 & Filter out customers with irregular information. \\ \cline{2-3}  & RF03 & Extract the characteristics used in the RFM model \\ \cline{2-3}  & & from the customers. \\ \cline{2-3}  & RF04 & Normalize the data to avoid disparities in \\ \cline{2-3}  & RF05 & Display on a 3D graph the location of the customers \\ \cline{2-3}  & RF05 & from the RFM feature scores. \\ \cline{2-3}  & RF06 & Segm. into clusters the cust. based on the \\ \cline{2-3}  & RFM attributes. \\ \hline \multirow{4}{*}{Non-Feuticements Requirements} & RNF01 & \begin{tabular}{c} Use the K-means clustering algorithm for segm. \\ of clients. \\ \end{tabular} \\ \cline{2-3}  & RNF02 & \
\begin{tabular}{c} Apply the silhouette, Calinski–Harabasz, and \\ Davies–Bouldin internal validation indexes to val. the \\ quality of the clusters. \\ \end{tabular} \\ \cline{2-3}  & RNF03 &
\begin{tabular}{c} Apply the external validation index of global stability, \\ stability per cluster, and SLSa stability. \\ \end{tabular} \\ \cline{2-3}  & RNF04 & Use the Python language for prototype development. \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Requirements. Figure 3: Densities of customer distribution. applied. Since there are no \"true\" clusters or test data with a priori categories to make the external comparison, a global stability measure was used, where the external information is composed of solutions with different amounts of clusters. The external information uses the main concepts: bootstrapping for random sample selection, and the adjusted Rand index (RI) for the similarity measure between the two clustering solutions \(z\) and \(z^{\prime}\). The RI can be defined by:  
\[RI=\ \frac{a+d}{a+b+c+d}, \tag{5}\]  
where \(a\) is the number of element pairs that were assigned to the same cluster. For that, \(b\) is the number of element pairs that were assigned to the same cluster in solution \(z\), but in different clusters in solution \(z^{\prime}\). \(c\) is the number of element pairs that were assigned to different clusters in solution \(z\), but in the same clusters in solution \(z^{\prime}\), and finally, \(d\) is the number of element pairs that are in different clusters in both \(z\) and \(z^{\prime}\)[55]. The RI has some issues, such as not always presenting a value of 0 for completely random solutions and varying positively as the number of clusters in the solutions increases. Different measures have been created to correct such problems; one of these measures is the adjusted Rand index (ARI), given by:  
\[ARI=\frac{Index-Expected\ Index}{Max\ Index-Expected\ Index}. \tag{6}\]  
With Index being the result of RI, Expected Index being the expected RI when observations are randomly assigned to different clusters, and Maximum Index being the maximum possible value of RI. The ARI index ranges between \(-1\) and \(1\), with \(-1\) being a value for high dissimilarity and \(1\) being a value for high similarity between two solutions [56]. From these two concepts presented, it is possible to apply the global stability measure divided into the following steps:  
1. Creating 50 pairs of bootstrap samples with replacements from the data;
2. Performing the clustering of each pair of samples with \(k\) clusters;
3. Calculating the ARI value of the clustered pair, generating a value from \(-1\) to \(1\);
4. Repeating steps \"b\" and \"c\" until the desired number \(k\) is reached [54]. After applying ARI, 50 values are used for each \(k\) analyzed.