# Streamlining Visual UI Design: Mining UI Design Patterns for Top App Bars
## 4 Experimental Design
### Evaluation Metrics
#### 4.4.2 Evaluation Metrics for Clustering  
For clustering assessments, we employ both Internal and External Evaluation methodologies. The Internal Evaluation method operates without data annotation, relying on the assumption of compactness within a class and dispersion between classes. Conversely, the External Evaluation method necessitates data annotation and gauges the alignment between clustering outcomes and human cognition. We utilized three metrics for Internal Evaluation: the Silhouette Score, Calinski Harabasz Index (CH Index), and Davies Bouldin Index (DB Index). Let \(N\) denote the total number of samples and \(K\) represent the number of clusters after clustering. The Silhouette Score gauges the similarity (cohesion) of each sample within the clustering outcome to its corresponding cluster, alongside its distinctiveness from other clusters. As shown in (8), \(a\) signifies the intra-cluster cohesion, while \(b\) denotes the inter-cluster separation. The Silhouette Score ranges from \(-1\) to \(1\), with values closer to \(1\) indicating superior clustering outcomes:  
\[s=\frac{1}{N}\sum_{i=1}^{N}\frac{b_{i}-a_{i}}{\max(a_{i},b_{i})} \tag{8}\]The CH Index also termed the variance ratio criterion, evaluates clustering effectiveness by contrasting within-cluster compactness with between-cluster separation (9). Here, \(tr\) signifies the matrix trace, \(\mathbf{B}\) is the inter-cluster distance difference matrix, and \(\mathbf{W}\) is the intra-cluster distance difference matrix. A higher CH Index suggests tighter clusters and greater cluster dispersion, indicating improved clustering outcomes:  
\[\text{CH}=\frac{tr(\mathbf{B})}{tr(\mathbf{W})}\times\frac{N-K}{K-1} \tag{9}\]  
The DB Index assesses intra-cluster similarity relative to inter-cluster similarity, with smaller values indicating superior clustering performance (10). Here, \(s\) denotes the average distance between samples within a cluster, and \(d\) represents the distance of cluster centroids:  
\[\text{DB}=\frac{1}{K}\sum_{i=1}^{K}\max_{i\
eq j}\frac{s_{i}+s_{j}}{d_{ij}} \tag{10}\]  
In our external evaluation experiment, we utilized five indicators: the Jaccard Coefficient (JC), Follows and Mallors Index (FMI), Rand Index (RI), Purity, and the F-1 score. To support these evaluations, the confusion matrix for clustering was defined, as shown in Table 1. In this matrix, the terms True Positive (TP), False Negative (FN), False Positive (FP), and True Negative (TN) are analogous to their usage in binary classification. The Jaccard similarity coefficient serves as a standard measure for assessing the similarity and dissimilarity between finite sample sets. Higher values of the Jaccard coefficient indicate greater sample similarity, calculated as (11):  
\[\text{JC}=\frac{\text{TP}}{\text{TP}+\text{FN}+\text{FP}} \tag{11}\]  
The FMI is determined as the geometric mean of pairwise precision and recall, represented by (12):  
\[\text{FMI}=\sqrt{\frac{\text{TP}}{\text{TP}+\text{FN}}\cdot\frac{\text{TP}}{ \text{TP}+\text{FP}}} \tag{12}\]  
The Rand index is a metric gauging the similarity between two clustering assignments, accommodating permutations, given by (13):  
\[\text{RI}=\frac{2(\text{TP}+\text{TN})}{N(N-1)} \tag{13}\]  
The F-1 value computation follows (14):  
\[\text{F-1}=\frac{2}{2\text{TP}+\text{FN}+\text{FP}} \tag{14}\]  
In contrast to the aforementioned metrics, Purity assesses the percentage of correct clustering by dividing the highest frequency sample category within each cluster by the \begin{table}
\begin{tabular}{c c c c} \hline \hline  & & \multicolumn{3}{c}{**Clustering into**} \\  & & **Same Cluster** & **Different Cluster** \\ \hline \multirow{2}{*}{Labeled as} & Same Cluster & TP & FN \\  & Different Cluster & FP & TN \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The confusion matrix for clustering total number of samples in the cluster (15), where \(\omega\) denotes the annotated cluster and \(c\) signifies the clustered cluster:  
\[\mathrm{P}=\frac{1}{N}\sum_{k}\max_{j}\lvert\omega_{k}\cap c_{j}\rvert \tag{15}\]