Optimization of Density Peak Clustering Algorithm Based on Improved Black Widow Algorithm

Clustering is an unsupervised learning method. Density Peak Clustering (DPC), a density-based algorithm, intuitively determines the number of clusters and identifies clusters of arbitrary shapes. However, it cannot function effectively without the correct parameter, referred to as the cutoff distance (dc). The traditional DPC algorithm exhibits noticeable shortcomings in the initial setting of dc when confronted with different datasets, necessitating manual readjustment. To solve this defect, we propose a new algorithm where we integrate DPC with the Black Widow Optimization Algorithm (BWOA), named Black Widow Density Peaks Clustering (BWDPC), to automatically optimize dc for maximizing accuracy, achieving automatic determination of dc. In the experiment, BWDPC is used to compare with three other algorithms on six synthetic data and six University of California Irvine (UCI) datasets. The results demonstrate that the proposed BWDPC algorithm more accurately identifies density peak points (cluster centers). Moreover, BWDPC achieves superior clustering results. Therefore, BWDPC represents an effective improvement over DPC.


Introduction
Clustering is a type of unsupervised learning method [1] that plays a crucial role in extracting essential and potentially valuable information from data [2].It is a typical unsupervised learning technique that aggregates data objects into clusters based on some similarity measure without the need for any prior knowledge.Without the need for any prior knowledge about the data, data objects within the same cluster demonstrate high similarity, while those in different clusters exhibit low similarity in the dataset.Leveraging these advantages, clustering has been applied in various fields, such as community detection [3], pattern recognition [4], image processing [5], financial services [6], and security detection [7], and has achieved success in these domains.
With the rapid advancement of data science and machine learning, cluster analysis has evolved into a fundamental technique in the realms of data mining and pattern recognition.The development of clustering algorithms has progressed through several crucial stages.Initially, clustering algorithms primarily revolved around distance-based hierarchical methods like Clustering using representative (CURE) [8], Balanced iterative reducing and clustering using hierarchies (BIRCH) [9], and partition-based approaches such as K-means [10] and K-medoids [11] and Gaussian Mixed Model (GMM) [12].Despite their effectiveness on simple datasets, these algorithms faced limitations in handling large-scale and high-dimensional data.As data sizes and complexity increased, researchers started developing more sophisticated clustering algorithms.A notable advancement came with the introduction of density-based clustering algorithms, exemplified by Density-Based Spatial Clustering of Applications with Noise (DBSCAN) [13] and Or-dering Points to Identify the and achieve automatic optimization of the DPC algorithm's cutoff distance "d c ", this paper proposes a Density Peak Clustering algorithm based on the Black Widow Optimization Algorithm (BWDPC).The BWDPC clustering algorithm aims to select the optimal "d c " value using the Silhouette Coefficient (Sil) as the optimization objective.The algorithm follows a selection process where, within a certain number of iterations, it chooses the "d c " value corresponding to the highest Sil.This process helps to identify the best density centers under a reasonable "d c " setting.The results obtained from synthetic datasets and UCI real datasets demonstrate that the BWDPC algorithm can correctly select density centers.The main contributions of the BWDPC algorithm are as follows: 1. Intelligent Optimization with Sil Objective: By using an intelligent optimization algorithm with the Silhouette Coefficient as the objective, the BWDPC algorithm overcomes the problem of inaccurate density center selection in previous DPC algorithms, which could lead to chain errors in the clustering results.2. Improved Black Widow Algorithm: The traditional Black Widow Algorithm has been modified by incorporating search factors, making it more suitable for optimizing the DPC algorithm.Multiple rounds of swarm intelligence search have been conducted to address issues such as the algorithm's limited search paths and slow convergence.3. Automatic Selection of "d c ": BWDPC requires only the initialization of "d c ", and then it automatically selects the appropriate "d c " value during the clustering process.This feature makes it well-suited for handling large-scale datasets.
The main content of this paper is as follows: Section 2 introduces related works.Section 3 primarily discusses the proposed BWDPC method.Section 4 presents experiments and discussions.Section 5 presents the conclusions.

The DPC Algorithm
The DPC algorithm is based on two intuitive assumptions: 1.
Points around a clustering center have lower densities than the center itself.

2.
Clustering centers are farther away from other points with higher densities.The algorithm requires the input of a cutoff distance parameter d c .It then automatically selects clustering center points on the decision graph based on the given d c value.
Afterward, using a one-step allocation strategy, it assigns the remaining points to the clusters represented by the identified centers to complete the clustering process.

The Relevant Parameters of the DPC Algorithm
In the DPC algorithm, there are two different ways to calculate the local density based on the size of the dataset.When the dataset is large, the calculation of local density is as follows: where d c is a cutoff distance and ρ i represents the local density of point i. d ij denotes Euclidean distance between point i and point j, and x is equivalent to d ij minus d c .χ(x)= 1 when x < 0, χ(x)= 0 when x ≥ 0. d ij is defined as follows: where i represents point i, j represents point j, and k represents the dimension of a certain point.When the dataset size is small, the definition of local density is as follows: where the cutoff distance is the only parameter of DPC.In DPC, d c = M sort (round(pn)).M sort represents an ordered set of all values in the distance matrix M from small to large.The value of p is about 1% to 2%.Set δ as the center deviation distance and δ as the center deviation distance of each point.The center deviation distance represents the minimum distance between point x i and the set of points whose local density is locally larger than x i .For point x i with the largest local density value, δ i represents the maximum distance between that point and other points.The definition of center deviation distance can be expressed as in mathematical Equation (5).
Given a dataset X = {x 1 , x 2 , . .., x n } for ∀x i ∈ X, the decision value for x i is calculated as follows: where ρ i is the local density of x i ,δ i is the relative distance of x i , and γ i is the decision value of point i.
As shown in Figure 1 ( ) where i represents point i, j represents point j, and k represents the dimension of a certain point.When the dataset size is small, the definition of local density is as follows: where the cutoff distance is the only parameter of DPC.In DPC, dc = Msort(round(pn)).Msort represents an ordered set of all values in the distance matrix M from small to large.The value of p is about 1% to 2%.
Set δ as the center deviation distance and δ as the center deviation distance of each point.The center deviation distance represents the minimum distance between point xi and the set of points whose local density is locally larger than xi.For point xi with the largest local density value, i δ represents the maximum distance between that point and other points.The definition of center deviation distance can be expressed as in mathematical Equation ( 5) Given a dataset X = {x1, x2, …, xn} for ∀xi ∈ X, the decision value for xi is calculated as follows: where i ρ is the local density of xi,δi is the relative distance of xi, and i γ is the decision value of point i.
As shown in Figure 1, the blue point is a class cluster, and the red point is another  The clustering process of DPC is as follows: 1. Calculate the local density (ρ) and relative distance (δ) of each sample point using Equations ( 1)-(5).2. Calculate the decision value for each sample point using Equation (6). 3. Select the points with higher decision values as the cluster centers.4. Once the cluster centers are identified, allocate the remaining points in descending order of their local density.Each point is sequentially assigned to the cluster of the nearest preceding point in terms of relative distance.
DPC shows greater sensitivity to the initial selection of cluster centers compared to the K-means.Different initial values can yield diverse clustering results.In contrast to K-means, DPC eliminates the need for initializing cluster centers, rendering its clustering outcomes insensitive to initial conditions.DBSCAN may have poorer clustering results in situations with significant density variations, while DPC excels in handling clusters with different densities because it determines clusters through local density peaks.

The Limitations of DPC
The idea of the DPC algorithm is relatively simple, as it can recognize clusters of arbitrary shapes and intuitively determine the number of clusters.However, it still has the following shortcomings: The cutoff distance d c value needs to be manually set, and its selection is quite sensitive.To illustrate this issue more intuitively, take the clustering results obtained from the Aggregation dataset shown in Figure 2  4. Once the cluster centers are identified, allocate the remaining points in descending order of their local density.Each point is sequentially assigned to the cluster of the nearest preceding point in terms of relative distance.
DPC shows greater sensitivity to the initial selection of cluster centers compared to the K-means.Different initial values can yield diverse clustering results.In contrast to Kmeans, DPC eliminates the need for initializing cluster centers, rendering its clustering outcomes insensitive to initial conditions.DBSCAN may have poorer clustering results in situations with significant density variations, while DPC excels in handling clusters with different densities because it determines clusters through local density peaks.

The Limitations of DPC
The idea of the DPC algorithm is relatively simple, as it can recognize clusters of arbitrary shapes and intuitively determine the number of clusters.However, it still has the following shortcomings: The cutoff distance dc value needs to be manually set, and its selection is quite sensitive.To illustrate this issue more intuitively, take the clustering results obtained from the Aggregation dataset shown in Figure 2    As shown in Figure 2, when the cutoff distance (d c ) is set to 3.1, the DPC correctly divides the Aggregation dataset into seven clusters, yielding satisfactory clustering results.However, with d c set to 3.2, 3.3, and 3.4, the clustering effect diminishes.For instance, with d c = 3.2, points from the same cluster in the upper-left corner are incorrectly assigned to two clusters, and those from two clusters in the lower-left corner are assigned to the same cluster, resulting in suboptimal clustering and performance.Similar issues arise at d c = 3.3, where points belonging to the red cluster are incorrectly assigned to the black cluster.Hence, optimizing the truncation distance d c is crucial for DPC, and the optimal value varies across datasets, influencing clustering outcomes.

BWOA Algorithm 2.2.1. Spider Movement
The movement of spiders in the spiderweb is modeled in two forms: linear and spiral.The position update formula is as follows: where x * is the position of the current best individual, m is a random floating-point number between 0.4 and 0.9, and β is a random floating-point number between −1 and 1. m and β are random parameters, and their purpose is to ensure the randomness of the black widow's movement and to prevent falling into local optimality.t represents the generation of the black widow spider, → x r1 (t) is the position of the r1 black widow, and → x i (t) is the current position of the black widow.The rand value falls within the range of (0, 1), ensuring the randomness of the black widow spider's movement.Assuming the spider moves in a linear and spiral fashion within the grid, it follows Formula (7) when rand <0.3; otherwise, it adheres to Formula (8).

Pheromone
Pheromones play a crucial role in the mating process of spiders.The correlation between spider diet and the variation in pheromone signals affecting the quality and quantity of silk is evident.Male spiders are more sensitive to the sex pheromones secreted by well-nourished females because they indicate higher reproductive capability, but mainly to avoid the cost of mating with potentially starved females.Therefore, male spiders tend to avoid females with low pheromone content.The pheromone deposition rate for black widow spiders can be calculated according to Formula (9).
When the pheromone value is less than or equal to 0.3, the individual will be replaced, and the position update formula is as follows: where x r1 and x r2 are two different individuals, and σ is either 0 or 1.

→
x i (t) indicates the location of a black widow with low pheromone levels in the female.Additionally, σ is a random number in order to randomize the location of black widows with low pheromone levels in females.

→
x r1 (t) is the position of the r 1 black widow, → x r2 (t) is the position of the r2 black widow.It is specified that r1 must not be equal to r2.

Abbreviations and Their Descriptions
In this paper, external clustering evaluation is employed as the objective function, along with several commonly used clustering evaluation metrics, to assess the performance of clustering algorithms.The indices used include the Silhouette Coefficient [27], the Fowlkes-Mallows Index (FMI) [28], the Adjusted Rand Index (ARI) [29], and Adjusted Mutual Information (AMI) [30].The silhouette refers to a method that reflects the consistency of data clustering results and can be used to evaluate the dispersion between clusters after clustering; others are employed to evaluate the performance of clustering algorithms, offering quantitative measures of the agreement between clustering results and true class labels.The Fowlkes-Mallows Index (FMI) exhibits sensitivity to outliers, while the Adjusted Rand Index (ARI) demonstrates robustness in handling random clustering results, rendering it more practical in stochastic scenarios.The Adjusted Mutual Information (AMI) remains insensitive to dataset size, making it suitable for datasets of various scales.The four evaluation indices are described in detail as follows: (1) Silhouette Coefficient (Sil): The Silhouette Coefficient is a method to examine how similar an object is to its own cluster compared to other clusters.A data ser D with n sample points was divided into k clusters: C = (C 1 , C 2 , . .., C K , . .., C N ).a(t) could be the average dissimilarity of sample t in C j .D(t, C i ) was the average dissimilarity of sample point t to all samples in another cluster Ci, then b(t) = min{d(t, C i )}, where i = j.The calculation formula of sample t Silhouette index Sil was shown in Formula (11).
Sil(t) value reflected among cluster Ci with compact classes and separable classes.The average of all the samples Sil(t) values reflect the quality of clustering results.The greater the average Sil value, the more compact the class and the better the quality of clustering is.Sil has a value range of [−1, 1].
Sil represents the average silhouette value of all sample points, and N represents the total number of samples.
(2) Fowlkes-Mallows Index (FMI): The Fowlkes-Mallows Index is defined as follows: TP represents the count of sample pairs correctly assigned to the same cluster.FP represents the count of sample pairs that, according to the true labels, do not belong to the same category but are incorrectly assigned to the same cluster.FN represents the count of sample pairs that, according to the true labels, belong to the same category but are incorrectly not assigned to the same cluster.The value of FMI ranges from 0 to 1, with a higher value indicating a better clustering result.
(3) The Adjusted Rand Index (RI): The Rand Index (RI) is defined as follows: TN represents the number of sample pairs that do not belong to the same category in the true labels and are correctly not assigned to the same cluster.The Adjusted Rand Index (ARI) is adjusted, and its definition is as follows: where E(•) represents the expected value, and the ARI has a range of [−1, 1].The closer the value is to 1, the higher the clustering accuracy is indicated.
Biomimetics 2024, 9, 3 8 of 18 (4) Adjusted Mutual Information (AMI): Similar to ARI, AMI is another widely used cluster evaluation indicator, and its definition is as follows: where H(A) and H(B) denote the entropy of two category labels, and AMI assesses the clustering effect based on mutual information (MI).E(MI) represents the mathematical expectation of MI.MI, as a measure of the coincidence of two data distribution indices, is expressed in its tabulated formula: where k is the total number of clusters, m ij is the number of samples in the intersection of the sample sets for cluster i in the true labels and cluster j in the clustering algorithm, and N is the total number of samples.p i represents the ratio of the number of samples in cluster i in the true labels to the total number of samples N, and p j represents the ratio of the number of samples in cluster j in the clustering algorithm to the total number of samples, N. The AMI has the same range as the ARI, and a higher value indicates more accurate clustering results.
The DPC algorithm, based on density peaks, operates without the need for a predefined number of clusters.It dynamically determines the number of clusters by analyzing density relationships between data points, showcasing adaptability to clusters of diverse shapes and sizes.Furthermore, as DPC identifies clusters through density peaks, it demonstrates strong adaptability to clusters with irregular shapes.Compared to certain agglomerative methods, DPC excels in capturing clusters with varying density distributions.Nevertheless, as illustrated in Figure 2, the DPC algorithm exhibits high sensitivity to the d c parameter.In the subsequent work, the project team successfully conducted experiments by optimizing this parameter.In the subsequent work, the project team optimized this parameter using the Black Widow Algorithm and conducted relevant experiments.

The Clustering of BWDPC
For the traditional DPC algorithm, the selection of the cutoff distance d c heavily relies on manual configuration and lacks intelligent optimization.Therefore, this paper proposes the BWDPC algorithm, which can automatically acquire more optimal values, thereby achieving accurate classification.In this section, the improvements of the BWOA algorithm and its combination with the DPC algorithm are elaborately presented.

The Shortcomings of the BWOA
The Black Widow Algorithm is an innovative population optimization algorithm inspired by the unique mating behavior of black widow spiders.It features minimal control parameters, straightforward operation, and strong optimization performance.Despite showing good performance in certain cases, this algorithm also has some drawbacks and limitations, including difficulties in parameter selection, susceptibility to local optima, problem-specific nature, and slow convergence speed, among others.

The RBWOA Model
The conventional BWOA algorithm exhibits slow convergence, particularly in addressing complex and high-dimensional optimization problems.It is susceptible to entrapment in local optima, with a weak search capability.To tackle these challenges, and informed by the issues identified in the proposed DPC algorithm, we devise a strategy to dynamically update the spider population range, capitalizing on the characteristics of the sigmoid function [30].
where u represents the search factor, t is the number of iterations, S represents the spider population range, and r is a random number between 0 and 1. S i denotes the maximum number of generation i black widow spiders.In this equation, it can be observed that the spider population range decreases with an increase in the number of iterations, and r is introduced to enhance the randomness of the search.In the initial iterations, with small values of t and the objective function u, the spider population range is relatively large.As the number of iterations grows and the objective function u increases, the spider population range nonlinearly decreases, gradually approaching 0. This effectively speeds up convergence while preventing entrapment in local optima.

Regarding the Pseudocode for BWDPC
The RBWOA algorithm (Algorithm 1) is as follows.
Algorithm 1: RBWOA algorithm Input : The value of the initial population S Output : The optimal value of x. 1. Initialize the population and evaluate the fitness function values and population S based on Formula (9).
13. //When → x i (t) is less than or equal to 0, it indicates the current population S i has been searched, and iterate to the next population S i + 1 .14. u = 1 1+ −t

Algorithm Flow Steps
The specific flow of the BWDPC algorithm is presented in the table below, incorporating search factors and path optimization search strategies to enhance the algorithm's convergence speed and efficiency.The BWDPC algorithm (Algorithm 2) is as follows.6) is employed to calculate γi, and the initial m points with the highest γ i values are automatically chosen as the cluster centers 6. Introduce the evaluation metric Sil as the objective function for BWDPC and record the d c value d* corresponding to the maximum Sil 7. Check if the termination condition is met.If t > T, end the iteration and proceed to step 8.If not, go back to step 3 for further optimization 9. Output the optimal d c value and obtain the final clustering results to complete the clustering process

Algorithm Time Complexity
For a data set with a sample size of N, the time complexity of the DPC algorithm mainly consists of calculating the distance matrix D with a complexity of O(N2), sorting the Euclidean distances with a complexity of O(N2log2N), and computing the local density and relative distance δ with a complexity of O(N2).Assuming the maximum range of black widow population is M, and the maximum number of iterations is T, and the dimension for optimizing the cutoff distance d c is 1, the complexity of optimizing d c is O (M × T).During the optimization process, as d c changes, it affects the local density and relative distance δ, resulting in a complexity of O (N2 × T) for this process.In summary, the time complexity of the algorithm mentioned in this chapter is O(N2(log2N+T)).

Experimental Dataset and Experimental Environment
This chapter used 12 datasets, including synthetic and UCI datasets, to validate the proposed clustering algorithm.Table 1 details attributes of the artificial and real datasets, while Table 2 shows the parameter settings for BWDPC, DPC, and K-means algorithms.The experimental environment consists of a LENOVO (Riyadh, Saudi Arabia) desktop computer with Windows 10 64-bit operating system, an Intel i7-10700 processor (Santa Clara, CA, USA), Python 3.9 as the programming environment, PyCharm as the development tool, and 8 GB of RAM.

Experiments on Synthetic Datasets
For the datasets provided in Table 1, BWDPC, DPC, DBSCAN, and K-means were used for clustering.Figures 3-5 show the clustering results of the four algorithms on the R15 dataset, Aggregation dataset, and D31 dataset, respectively.These three datasets have different overall distributions and numbers of clusters, which can more intuitively reflect the clustering performance of the four algorithms.Points with different colors in the figures are assigned to different clusters.The clustering results for the Aggregation dataset in Figure 4 reveal that only the BWDPC algorithm accurately clusters the dataset, while the other three algorithms fall short of achieving precise clustering.Due to an incorrect choice of dc, the DPC algorithm erroneously divides the blue cluster in the top-left corner into two, and the red cluster in the bottom-left corner, originally two clusters, is treated as one, resulting in substantial errors.While K-means correctly determines the number of clusters, it falls short of achieving accurate clustering.Specifically, K-means generates two cluster centers within one cluster and places cluster centers between the black clusters, whereas points in the red and pink clusters should belong to the same cluster.This incorrect setting of cluster centers by K-means results in substantial errors.Even though DBSCAN accurately identifies the number of clusters, some points are erroneously marked as noise.For instance, certain boundary points of the purple cluster in the top-left corner are incorrectly classified as noise, leading to a slightly inferior clustering result.
Figure 3 reveals that only BWDPC and K-means can accurately cluster the R15 dataset.The DPC algorithm exhibits clear errors in choosing cluster centers, leading to unsatisfactory clustering outcomes.DBSCAN erroneously designates certain boundary points as noise, diminishing clustering accuracy.In the D31 dataset, both BWDPC and Kmeans successfully achieve accurate clustering, whereas DBSCAN not only mislabels certain boundary points as noise but also errs in determining the number of clusters.For instance, the red cluster, which originally belongs to two different clusters, is incorrectly consolidated into one by DBSCAN.DPC also faces analogous problems due to the absence of a suitable dc value, leading to substantial errors in cluster centers.In comparison, The clustering results for the Aggregation dataset in Figure 4 reveal that only the BWDPC algorithm accurately clusters the dataset, while the other three algorithms fall short of achieving precise clustering.Due to an incorrect choice of d c , the DPC algorithm erroneously divides the blue cluster in the top-left corner into two, and the red cluster in the bottom-left corner, originally two clusters, is treated as one, resulting in substantial errors.While K-means correctly determines the number of clusters, it falls short of achieving accurate clustering.Specifically, K-means generates two cluster centers within one cluster and places cluster centers between the black clusters, whereas points in the red and pink clusters should belong to the same cluster.This incorrect setting of cluster centers by Kmeans results in substantial errors.Even though DBSCAN accurately identifies the number of clusters, some points are erroneously marked as noise.For instance, certain boundary points of the purple cluster in the top-left corner are incorrectly classified as noise, leading to a slightly inferior clustering result.
Figure 3 reveals that only BWDPC and K-means can accurately cluster the R15 dataset.The DPC algorithm exhibits clear errors in choosing cluster centers, leading to unsatisfactory clustering outcomes.DBSCAN erroneously designates certain boundary points as noise, diminishing clustering accuracy.In the D31 dataset, both BWDPC and K-means successfully achieve accurate clustering, whereas DBSCAN not only mislabels certain boundary points as noise but also errs in determining the number of clusters.For instance, the red cluster, which originally belongs to two different clusters, is incorrectly consolidated into one by DBSCAN.DPC also faces analogous problems due to the absence of a suitable d c value, leading to substantial errors in cluster centers.In comparison, BWDPC not only determines the correct number of clusters but also identifies the positions of cluster centers more accurately, resulting in superior clustering performance.
Figures 6 and 7 show the clustering results of the four algorithms on the Two_cluster dataset and Five_cluster dataset, respectively.These datasets further demonstrate the accuracy of the BWDPC algorithm in clustering.
tions of cluster centers more accurately, resulting in superior clustering performance.
Figures 6 and 7 show the clustering results of the four algorithms on the Two_clus dataset and Five_cluster dataset, respectively.These datasets further demonstrate the curacy of the BWDPC algorithm in clustering.From the clustering results in Figures 6 and 7, it can be seen that BWDPC algorithm, DPC algorithm, and K-means algorithm can accurately cluster the datasets and find cluster centers.However, the DBSCAN algorithm treats the boundary points as noise and produces a wrong classification of the data points in the lower left corner, which indicates that the DBSCAN algorithm may produce incorrect classification when dealing with uneven data density, resulting in suboptimal clustering performance.

BWDPC DPC DBSCAN K-means
Table 3 provides clustering evaluation metrics for BWDPC and other comparison algorithms on six datasets.From the evaluation metrics in Table 3, it can be observed that BWDPC, with the improvement in cluster center selection strategy and the optimization of the cutoff distance using the Black Widow Optimization Algorithm, achieved good results on most datasets.Furthermore, all the clustering metrics of the BWDPC algorithm outperformed those of the DPC algorithm, indicating the significant effect of optimizing the cutoff distance dc in BWDPC.The best results are shown in bold, and the clustering metrics used in this section are FMI, ARI, and AMI.From the clustering results in Figures 6 and 7, it can be seen that BWDPC algorithm, DPC algorithm, and K-means algorithm can accurately cluster the datasets and find cluster centers.However, the DBSCAN algorithm treats the boundary points as noise and produces a wrong classification of the data points in the lower left corner, which indicates that the DBSCAN algorithm may produce incorrect classification when dealing with uneven data density, resulting in suboptimal clustering performance.
Table 3 provides clustering evaluation metrics for BWDPC and other comparison algorithms on six datasets.From the evaluation metrics in Table 3, it can be observed that BWDPC, with the improvement in cluster center selection strategy and the optimization of the cutoff distance using the Black Widow Optimization Algorithm, achieved good results on most datasets.Furthermore, all the clustering metrics of the BWDPC algorithm outperformed those of the DPC algorithm, indicating the significant effect of optimizing the cutoff distance d c in BWDPC.The best results are shown in bold, and the clustering metrics used in this section are FMI, ARI, and AMI.

Experiments on Real-World Datasets
The experiment used six real-world datasets to test the performance of the BWDPC algorithm.These datasets have different sample sizes, feature numbers, and cluster quantities.Table 1 provides specific information for each real dataset.The experiment conducted clustering using BWDPC, DPC, DBSCAN, and K-means on these six datasets, and the results are shown in Table 3, with the best results highlighted in bold.
As shown in Table 4, BWDPC excels over other clustering algorithms in six real datasets and shows substantial improvements on certain UCI datasets.For example, BWDPC performs exceptionally well, securing a leading position in clustering results, especially on widely used Iris and Sym datasets.In comparison to the DPC algorithm, BWDPC improves FMI, ARI, and AMI scores by 0.08, 0.2, and 0.1, respectively, on the Iris dataset.Specifically, the Sym dataset sees improvements of 0.01, 0.02, and 0.01 in FMI, ARI, and AMI scores, respectively.The sensitivity is due to DPC's responsiveness to the truncation distance parameter (d c ) in small-sample datasets.However, on the Segment dataset, despite BWDPC's improved clustering performance over DPC, with increases of 0.10, 0.12, and 0.20 in FMI, ARI, and AMI scores, respectively, the overall clustering performance remains unsatisfactory.This is because BWDPC faces challenges when handling high-dimensional data, which may lead to less satisfying results.Besides the mentioned datasets, the BWDPC algorithm achieves optimal clustering results on the Segment and Zoo datasets.Specifically, on the Zoo dataset, BWDPC outperforms the DPC algorithm with increases of 0.31, 0.34, and 0.2 in FMI, ARI, and AMI scores, respectively, showcasing robust performance in lowdimensional data.In comparison to the PDC algorithm, BWDPC automatically optimizes the d c value, resulting in optimal clustering results.The enhanced BWDPC algorithm can precisely identify true cluster centers.In contrast to the K-means algorithm, both BWDPC and DPC can accurately identify cluster centers in streaming datasets.In certain datasets, DBSCAN might misclassify boundary points as noise, leading to less accurate clustering results.

Conclusions
In this study, BWDPC utilizes the Black Widow Optimization Algorithm to dynamically determine the optimal cutoff distance d c , thereby improving clustering performance.Moreover, by introducing a search factor and dynamically updating the spider population range, the algorithm addresses the challenge of parameter specificity, allowing it to avoid local optima and expedite convergence.The results obtained from six artificial datasets and six UCI real datasets illustrate that, based on the comparison of the Fowlkes-Mallows Index (FMI), Adjusted Rand Index (ARI), and Adjusted Mutual Information (AMI), BWDPC consistently and accurately identifies cluster centers, yielding optimal clustering outcomes in most cases.It can be asserted that BWDPC outperforms existing algorithms on the majority of datasets, demonstrating higher accuracy.While the BWDPC algorithm achieves automatic optimization of the cutoff distance d c , the parameter K for the number of cluster centers still requires manual determination.Consequently, additional research is necessary to implement the adaptive selection of the parameter K, aiming to decrease empirical input and human involvement while preserving algorithm accuracy and robustness, thus enhancing clustering efficiency.Nonetheless, BWDPC has its limitations.While the algorithm demonstrates proficiency on low-dimensional data, its clustering performance diminishes on high-dimensional data, which also constitutes a key area for future research.BWDPC excels in swiftly identifying irregular-shaped clusters and adeptly adjusting to clusters with varying densities in real-world applications.In summary, by leveraging the strengths of DPC and attaining automatic determination of the d c parameter, BWDPC has delivered exceptional clustering results.
, the blue point is a class cluster, and the red point is another class cluster.After calculating the ρ and δ values based on the aforementioned steps for each point, points 1 and 10 have the highest γ values, and it can be seen that sample points 1 and 10 are located at the upper right corner of the decision diagram.Therefore, points 1 and 10 are identified as cluster centers.The black points 26, 27, and 28 have a relatively high δ and a low ρ because they are isolated, and they can be considered outliers.Clustering centers should have large δ and ρ.
as an example.It can be observed that different values of d c lead to significantly different clustering results.Therefore, optimizing the cutoff distance d c becomes particularly important.The "+" in Figures 2-7 represents the cluster center, and samples of different types of clusters are represented by different colors.
as an example.It can be observed that different values of dc lead to significantly different clustering results.Therefore, optimizing the cutoff distance dc becomes particularly important.The "+" in Figures 2-7 represents the cluster center, and samples of different types of clusters are represented by different colors.dc = 3.1 dc = 3.2 dc = 3.3 dc = 3.4

Figure 2 .
Figure 2. Clustering result graphs corresponding to different values of dc.Figure 2. Clustering result graphs corresponding to different values of d c .

Figure 2 .
Figure 2. Clustering result graphs corresponding to different values of dc.Figure 2. Clustering result graphs corresponding to different values of d c .

Algorithm 2 :
BWDPC algorithm Input: Experimental Dataset X = {x 1 , x 2 , . .., x n } Output: Clustering Results C = {c 1 , c 2 , . .., c m }, m Is the Number of Data Cluster Results 1. Set the population size S and the maximum number of iterations T for the BWDPC algorithm 2. Data preprocessing: Calculate the distance matrix for all data points and determine the range of d c values 3. Enter S into BWDPC and set the output x of BWDPC to d c 4. Substitute d c into equations 4 and 5 to calculate the local density ρ i and δ i ; for all points 5. Formula (

Figure 3 .
Figure 3.The clustering results of the four algorithms on the R15 dataset.Figure 3. The clustering results of the four algorithms on the R15 dataset.

Figure 3 .
Figure 3.The clustering results of the four algorithms on the R15 dataset.Figure 3. The clustering results of the four algorithms on the R15 dataset.

Figure 4 .
Figure 4.The clustering results of the four algorithms on the Aggregation dataset.

Figure 4 .Figure 5 Figure 5 .
Figure 4.The clustering results of the four algorithms on the Aggregation dataset.

Figure 5 .
Figure 5.The clustering results of the four algorithms on the D31 dataset.

Figure 6 .
Figure 6.The clustering results of the four algorithms on the Two_cluster dataset.

Figure 6 .Figure 7 .Figure 7 .
Figure 6.The clustering results of the four algorithms on the Two_cluster dataset.

Figure 7 .
Figure 7.The clustering results of the four algorithms on the Five_cluster dataset.

Table 1 .
Description of artificial synthetic datasets and UCI datasets.

Table 3 .
presents the results for artificial datasets.

Table 3 .
Presents the results for artificial datasets.

Table 4 .
Results of the artificial datasets.