# Applying Spectral Clustering to Decode Mobility Patterns in Athens, Greece
## 2 Data and Methods
### Spectral Clustering Analysis  
In k-means clustering, the distances between homogeneous groups can be calculated by determining the distance of each examined item from the center of each cluster. The center of each cluster is represented by a vector of means--called the cluster center--and corresponds to the variables used for grouping the candidates. Each examined item is assigned to a cluster by calculating the distance between the item and each cluster and assigning it to the nearest cluster. K-mean makes strong assumptions from the beginning of the estimation process. Yet, the application of the k-means cluster analysis seems to not be effective in high-dimensional problem due to the increased sparsity of data. At the same time, hierarchical clustering techniques cannot be seen as an alternative that ensures higher flexibility. Indeed, these techniques require much time and computational storage [23]. Therefore, it is essential to precede to a dimensionality reduction process, such as the technique of spectral clustering. Spectral clustering is a graph-based clustering method derived from graph theory. This technique transforms the data into a spectral domain. Spectral domain refers to the space where data points are represented using eigenvalues and eigenvectors. This \"space transformation\" makes clusters more distinguishable. Spectral clustering groups observations based on the graph connectivity, which refers to the \"strength\" of relationships between data points. In this analysis, the measure of \"strength\" is the similarity of two data points (i.e., trips). This is beneficial because many real-world datasets do not conform to simple spherical distributions (like in k-means clustering), presenting complex mathematical challenges. In graph-based representation, nodes represent data points connected by edges, which often represent the similarity level [31]. Spectral clustering excels in handling data that is non-linearly separable and does not conform to specific cluster shapes, making it ideal for data dispersed in multiple directions. That is why this method is characterized by its flexibility. Although computationally demanding, this method prevents the mergingof discrete clusters that lack significant similarities [32]. According also to [PERSON] et al. [23], compared to k-means and DBSCAN--a density-based clustering technique--spectral clustering offers greater scalability. This attribute is particularly useful in this case, as the size of the trip dataset can vary significantly, with additional trips continuously being added. A significant challenge of this method is the interpretation of the output clusters. Although spectral clustering is a flexible method, it does not guarantee high interpretability [23]. This means that the applicability of this method cannot be evaluated beforehand. This technique includes the following steps: The first step of the algorithm is the calculation of distances between observations based on Manhattan distance (see Equation (1)). The Manhattan distance between two points is the sum of the absolute differences in their coordinates. It works better than the Euclidean distance, when data contain many zeros (e.g., in dummy coding schemes) or small values. Yet, it treats the continuous variables in a very \"linear\" way. In this case, the most important continuous variable is trip distance, which can reasonably be assumed to have a more linear impact on travel choices. What is more, Manhattan distance is a less sensitive to outliers and datasets with much noise. It does not increase the computational cost. Nevertheless, this distance metric may not be able to capture complex interaction between dummy and continuous variables. \[d(p,q)=\sum_{i=1}^{n}\lvert p_{i}-q_{i}\rvert \tag{1}\]  
where  
\(d(p,q)\): the Manhattan distance between trip \(p\) and \(q\),  
\(n\): the total dimensions included in the set, (trip purpose, mode, departure time and distance)  
\(p_{i}\): coordinate of trip \(p\) in dimension \(i\). \(q_{i}\): coordinate of trip \(q\) in dimension \(i\).