# Human Clustering Based on Graph Embedding and Space Functions of Trajectory Stay Points on Campus
## 2 Methodology
### Clustering Analysis  
Clustering is one of the important tasks in handling spatio-temporal mobility data. A basic question to answer is what groups there are. As a typical unsupervised clustering algorithm, K-means is designed to minimize the variance in each cluster and maximize differences between clusters based on one threshold value, namely the number of preferred clusters. And this algorithm can produce distinct clusters upon the number of clusters is determined. Here, we use K-means to cluster the feature vectors of nodes that are the learned results from the human network. The suitable number of clusters for each of the three specified scenarios is determined using the elbow method based on the inertia and silhouette scores of clusters. For a specific clustering result of a given set of points, inertia represents how well the points are clustered together. It is an indicator calculating the sum of squared distances between each point and the centroid of the cluster to which the point belongs. In Equation (4), \(n\) is the number of data points, \(x_{i}\) is a data point, and \(\mu_{j}\) is the centroid of cluster j to which \(x_{i}\) belongs. A lower inertia value indicates a better clustering scheme. For each number (\(K\)) of K-means clustering results, changes of inertia can be plotted against \(K\). Then, an \"elbow point\" can be identified, where the rate of decrease in inertia slows down. The corresponding \(K\) can be taken as the suitable number of clusters. \[\text{Inertia}=\sum_{i=1}^{n}\biggl{(}\min_{\mu_{j}}\parallel x_{i}-\mu_{j} \parallel^{2}\biggr{)} \tag{4}\]  
The silhouette score (\(SS\)) is used to measure how similar a point is to its own cluster relative to other clusters. It ranges from \(-1\) to \(1\), where a value close to \(1\) indicates that the point is well matched to a more suitable cluster and poorly matched to neighboring clusters, while a value close to \(-1\) suggests that a point may have been assigned to a less suitable cluster. The silhouette score focuses on balancing intra-cluster cohesion and inter-cluster separation. It is calculated using Equation (5), where \(S(i)\) is the silhouette score of the ith cluster; \(a(i)\) denotes the average distance between the ith point and other data points within the same cluster; and \(b(i)\) represents the average distance between the ith point and the points in the nearest neighboring cluster, reflecting the separation between clusters. \[SS(i)=\frac{b(i)-a(i)}{\max\{a(i),b(i)\}} \tag{5}\]  
Figure 4: Node2 Vec vectors with 16 dimensions. Whereas the silhouette score is used to determine an optimized number of clusters, together with inertia, the Calinski-Harabasz score and Davies-Bouldin score are calculated to evaluate the performances of clustering results. The Calinski-Harabasz score (CHS) evaluates the clustering quality based on the ratio of between-cluster dispersion to within-cluster dispersion. A higher Calinski-Harabasz score indicates that clusters are compact within each cluster and well separated among one another, suggesting better clustering performance. The CHS can be calculated by Equation (6), where \(K\) is the number of clusters; \(n_{k}\) and \(c_{k}\) are the number of points and the centroid of the kth cluster, respectively; \(c\) is the global centroid; and \(N\) is the total number of clustering points. \[CH=\left[\frac{\sum_{k=1}^{K}n_{k}\parallel c_{k}-c\parallel^{2}}{K-1}\right] /\left[\frac{\sum_{k=1}^{K}\sum_{i=1}^{n_{k}}\parallel d_{i}-c_{k}\parallel^{2 }}{N-K}\right] \tag{6}\]  
The Davies-Bouldin score (DBS) measures the average similarity ratio of each cluster relative to its most similar cluster. It indicates similarity between clusters and the tightness within clusters. Lower Davies-Bouldin scores indicate better clustering, suggesting that clusters are more distinct and less similar to each other.