## 3 Improved DBSCAN Algorithm Based on Sparrow Search Algorithm
### Determine the Parameter Range and the Optimal Number of Clusters
#### 3.2.2 Determine the Optimal Number of Clusters  
Analysis of global data through kernel density estimation can only roughly determine the sparsity of the dataset, but local density analysis can calculate the appropriate number of clusters in the dataset [22]. The DPC algorithm [23] leverages such characteristics to determine cluster centers. However, the DPC algorithm still requires manually specifying a truncation distance (\(d_{c}\)), and the final selection of cluster centers is performed through observation. In this paper, the bandwidth parameter is used to adaptively select the truncation distance, and the clustering centers are determined by analyzing the slope between sample points in the decision diagram, comparing the distances between suspected center points. The specific steps are as follows:  
In the given dataset \(D\), randomly select a point \(g\). The following two values can be defined: \(\rho_{i}\) denotes local density and \(\delta_{i}\) refers to the distance to the point with a higher local density. The local density \(\rho_{i}\) can be defined as follows:  
\[\rho_{i}=\sum_{j\in{I_{g}}\backslash\{i\}}{X(d_{ij}-d_{c})},X(x)=\left\{ \begin{array}{l}1,x<0\\ 0,x\geq 0\end{array} \right. \tag{8}\]  
where \(d_{ij}\) represents the distance between two points and \(d_{c}\) is the truncation distance [24]. If the subscript arrangement of the data point local density \(\{\rho_{i}\}_{i=1}^{n}\) is expressed as \(\{q_{i}\}_{i=1}^{n}\), satisfying \(\rho_{q_{1}}\geq\rho_{q_{2}}\geq\rho_{q_{3}}\geq\cdots\geq\rho_{q_{n}}\), then the distance \(v_{i}\) from point \(g\) to the point with a higher local density can be defined as follows:  
\[\delta_{q_{i}}=\left\{ \begin{array}{l}\min\limits_{\begin{subarray}{c}q_{i} \\ j<i\end{subarray}\\ \max\limits_{j\geq 2}{\delta_{q_{j}}}},i=1\end{array} \right. \tag{9}\]  
Figure 1: Two-dimensional display of SampleD dataset. Each sample point \(x_{i}\) in dataset \(D\) is abstractly represented by \((\rho_{i},\delta_{i}),i\in I_{D}\). To more accurately ascertain the optimal cluster quantity, the influence of \(\rho_{i}\) and \(\delta_{i}\) is taken into account to define \(\gamma_{i}=\rho_{i}\delta_{i},i\in I_{s}\). Greater \(\gamma_{i}\) values suggest a higher probability of representing the cluster's center [25]. \(\{\gamma_{i}\}_{i=1}^{N}\) organizes into a sequence where each value is less than its predecessor. \(p\) represents the point with the greatest degree of change between \(\gamma_{[1\sim p]}\) and \(\gamma_{[p\sim n]}\), and the point \(p\) satisfies the following:  
\[p=\max\{i|||k_{i}|-|k_{i+1}||\geq\varphi,i=1,2,\cdots,n-2\} \tag{10}\]  
\[\varphi=\theta(j)/(n-2) \tag{11}\]  
\[\theta(j)=\sum_{j=1}^{n-2}\bigl{|}|k_{j}|-|k_{j+1}|\bigr{|} \tag{12}\]  
where \(k_{i}\) symbolizes the slope between successive data points, while \(\varphi\) and \(\theta(j)\) denote the mean and aggregate discrepancies in these slopes, respectively. On this basis, this paper theoretically achieves automatic determination of the number of clustering clusters. By analyzing the trend of \(\gamma\) value changes, calculating the slope of adjacent points, and searching for \"mutation points\", the boundary between representative clustering centers and ordinary points can be determined. This mutation point reflects the number of significant density peaks in the data and is the theoretical basis for estimating the number of cluster centers. In addition, establishing the ultimate cluster quantity is also influenced by factors such as the structure of the data itself, bandwidth parameters, and the selection method of truncation distance \(d_{c}\). Specifically, the distance relationship between density centers is also used to eliminate \"pseudo centers\" that are too close in high-density regions, further improving the accuracy and stability of clustering structure recognition.