# Spatio-Temporal Heterogeneous Ensemble Learning Method for Predicting Land Subsidence
## 2 Methods
### Two-Stage Hybrid Spatio-Temporal Clustering Method
#### 2.1.2 Discovery of Spatio-Temporal Patterns Based on REDCAP  
The REDCAP algorithm, which considers both attribute similarity and adjacency relationships of spatial points, is more efficient in large data sets compared to other regionalization methods. Therefore, to identify spatio-temporal clusters of complex morphology, the REDCAP algorithm was employed in the second-stage to cluster the small spatio-temporal clusters obtained from BBAC_I. The REDCAP algorithm adopts a hierarchical agglomerative-partitioning strategy to discover complex cluster structures.  
The REDCAP algorithm first constructs a minimum spanning tree (MST) connecting all points based on adjacency relationships, using first-order (direct connection between points) or full-order (indirect connection between points) strategies. In this study, the adjacency relationships among spatial points in different spatio-temporal clusters are computed based on the union of their K-Nearest Neighbor (KNN) adjacency relations. If two spatio-temporal clusters have adjacent spatial points, they are considered adjacent; otherwise, they are considered non-adjacent. This rule defines the adjacency relationships among the intermediate spatio-temporal clustering results.  
To ensure strong spatio-temporal consistency, the full-order strategy is used to construct adjacency relationships among small spatio-temporal clusters. The REDCAP algorithm can be classified into six strategies based on the chosen adjacency relationship determination and inter-cluster distance metric: first-order-SLK, first-order-ALK, first-order-CLK, full-order-SLK, full-order-ALK, and full-order-CLK. Among these, full-order-CLK generally provides high clustering quality and is therefore chosen for agglomerative clustering in this study, generating a spatial connectivity tree using a bottom-up approach [30].  
The REDCAP algorithm segments the edges of the spatial connectivity tree in a top-down manner to obtain the final clustering results. This study selects the optimal cut-edge result based on the principle of regional homogenization optimization, using the sum of squared errors (SSE) as the heterogeneity measure:  
\[H(R)=\sum_{j=1}^{d}\sum_{i=1}^{n_{r}}\big{(}x_{ij}-\overline{x_{j}}\big{)}^{2} \tag{6}\]  
where \(R\) is the subtree containing the spatial objects, \(H(R)\) represents its heterogeneity, \(d\) is the attribute dimension of each spatial object, \(n_{r}\) is the number of objects in \(R\), \(x_{ij}\) is the \(j\)-th attribute value of the \(i\)-th object, and \(\overline{x_{j}}\) is the mean value of the \(j\)-th attribute value of all objects in \(R\).  
When the number of clusters \(k\) is set for the REDCAP algorithm, it should include \(k\) subtrees obtained from the segmentation. The overall heterogeneity \(H_{k}\) of the partitioning result is the sum of the heterogeneity of the \(k\) subtrees:  
\[H_{k}=\sum_{j=1}^{k}H\big{(}R_{j}\big{)} \tag{7}\]  
During each split, the REDCAP algorithm divides the region \(R\) into two sub-regions, \(R_{a}\) and \(R_{b}\), identifying the edge with the maximum homogeneity gain \(h_{g}^{*}(R)\) (i.e., the reduction in heterogeneity), calculated as:  
\[h_{g}^{*}(R)=max(H(R)-H(R_{a})-H(R_{b})) \tag{8}\]  
By iteratively finding the optimal cut-edge based on the principle of maximum homogeneity gain, the MST is segmented until the number of subtrees reaches \(k\). At this point, the REDCAP algorithm is complete, and the spatial objects in each subtree form a spatial cluster. The REDCAP algorithm can produce clustering results with varying numbers of clusters. The optimal number of clusters is determined using the silhouette coefficient [32]. The average silhouette coefficient of all points in the clustering result is taken as the silhouette coefficient. Typically, the \(k\) value corresponding to the maximum silhouette coefficient is chosen.