# Improved Honey Badger Algorithm and Its Application to K-Means Clustering
## 5 Simulation Experiment and Analysis
### Simulation Analysis of K-Means for Improved Honey Badger Algorithm  
To further validate the practicality of IHBA, this study selected K-means, IHBA-KM, and K-means algorithm based on Honey Badger Algorithm (HBA-KM) for a clustering experiment comparison. This experiment selected three data sets from the UCI database. For details, see Table 8.  
Figure 6: Convergence curves of each algorithm on different test functions. In this paper, the error sum of squares (SSE), accuracy, and \(F\)-score were employed as metrics for evaluating clustering results. SSE is a widely used metric for assessing the quality of clustering, referred to as fitness. It evaluates the sum of the squared distances between each data point and the center of its corresponding cluster. A lower fitness value signifies that a data point's proximity to the clustering center correlates with improved clustering quality. The specific calculation formula is shown in Equation (16). \[SSE=\sum_{k=1}^{k}\sum_{\alpha_{i}\in\mathbb{C}_{k}}||x_{i}-u_{k}||^{2} \tag{16}\]  
\(k\) denotes the number of clusters; \(C_{k}\) represents all data points within the kth class; \(x_{i}\) refers to the data points in the kth cluster; and \(u_{k}\) signifies the center of that cluster. Accuracy refers to the ratio of correctly clustered elements to the total number of elements, as expressed by the following equation. A higher accuracy indicates superior clustering results:  
\[Accuracy=\frac{N_{r}}{N} \tag{17}\]  
\(N_{r}\) represents the number of samples assigned to the correct cluster, and \(N\) represents the number of samples. The \(F\)-score is a widely used metric for evaluating clustering results, with a value range from 0 to 1. It reflects the degree of similarity between the clustering outcomes and the true classifications. A higher \(F\)-score, closer to 1, indicates a more effective clustering performance. Given the issue of class imbalance present in the data set utilized in this study, we employed the weighted \(F\)-score as a metric to evaluate the clustering outcomes. The specific formula is as follows. \[\left\{ \begin{array}{c}F-score=\left(1+\beta^{2}\right)\times\frac{P\times r }{(\beta^{2}\times p)+r}\\ P=\frac{TP}{TP+FP}\\ r=\frac{TP}{TP+FN}\end{array} \right. \tag{18}\]  
where \(TP\) is a true-false example, \(FP\) is a false-positive example, and \(FN\) is a negative-false example. \(\beta=2\) when the data set is a class-unbalanced data set, which focuses more on small class recall, and \(\beta=1\) when the data set is a class-balanced data set, which is the traditional \(F\)-score. To ensure fairness, the parameters were kept consistent across all experiments: The number of populations was established at \(N=20\), with a maximum iteration limit set to \(t_{max}=100\). Each algorithm was executed independently a total of 30 times. The best, worst, and average values, along with the standard deviation, were recorded for each run. Experimental results are summarized in Tables 9-11, while the convergence plots are shown in Figure 7. \begin{table}
\begin{tabular}{c c c c} \hline
**Data Sets** & **Iris** & **Wine** & **Glass** \\ \hline Class & 3 & 3 & 6 \\ Attributes & 4 & 13 & 9 \\ Sample size & 150 & 178 & 214 \\ \hline \end{tabular}
\end{table} 
Table 8: Data sets. \begin{table}
\begin{tabular}{c c c c c c c c c c c c} \hline  & \multicolumn{4}{c}{**Iris (\%)**} & \multicolumn{4}{c}{**Wine (\%)**} & \multicolumn{4}{c}{**Glass (\%)**} \\ \cline{2-11}
**Algorithms** & **Mean** & **Best** & **Worst** & **Mean** & **Best** & **Worst** & **Mean** & **Best** & **Worst** \\ \hline K-means & 80.73 & 85.33 & 66.66 & 87.68 & 93.82 & 59.55 & 56.65 & 59.34 & 48.13 \\ HBA-KM & 88.00 & 92.00 & 86.00 & 97.18 & 97.57 & 97.19 & 64.11 & 67.75 & 59.34 \\ IHBA-KM & 89.63 & 96.66 & 86.67 & 97.46 & 97.71 & 97.19 & 67.62 & 69.69 & 59.27 \\ \hline \end{tabular}
\end{table} 
Table 10: Clustering accuracy comparison for 30 runs of each algorithm.