## 3 Materials and Methods
### Analysis Methods
#### 3.2.3 Clustering Analysis (DBSCAN)  
A variant of the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm was employed to group trips according to waiting times and transport mode. Since the dataset, after applying the survey expansion factors, reached around 1,400,000 trips, using the standard DBSCAN algorithm presented computational limitations. To overcome this challenge, an adapted version was developed using a KD-Tree, a data structure that organizes points in a multidimensional space to optimize neighbor searches within a specified radius (eps_value). Rather than merely counting the number of neighbors, the dataset's expansion factors were used as weights to identify core points. This adaptation maintained the density-based focus of the original DBSCAN [39] and enabled a more efficient identification of user groups with prolonged waiting times. The expansion factors (weights) state how many real trips each survey record stands for. Weighting the neighbor count within radius \(\varepsilon\) makes the min_samples threshold operate on the estimated number of population trips, preventing over-sampled strata from distorting core formation. Consequently, the resulting clusters mirror the true population distribution and preserve the study's external validity. The use of KD-Tree in this context is common in research dealing with large volumes of data, as it accelerates neighbor searches and optimizes the algorithm's execution time [40]. During the initial exploration phase, the K-means algorithm was used. K-means partitions the data into a predefined number of clusters, assigning each point to the nearest cluster based on the mean of the points within that cluster. However, the clusters obtained with K-means proved too similar to one another because the algorithm tends to produce clusters of relatively uniform size, which did not adequately capture the variability in waiting times observed in the data. Given that the goal was to identify clusters with high waiting times, DBSCAN was chosen instead, as it is more suitable for data with varying densities and the presence of noise [41]. DBSCAN proved more effective in identifying trip clusters with prolonged waiting times, aligning more closely with the study objectives. After forming the clusters using DBSCAN (Scikit-learn version 1.6.1), a detailed characterization was performed. These clusters were analyzed to determine which user groups face the longest waiting times, focusing on variables such as origin commune, origin macrozone, and sex. Characterizing these clusters made it possible to identify sociodemographic and spatial patterns that explain which population segments suffer the most negative effects of extended waiting periods. To further evaluate the clustering quality, the silhouette coefficient was applied, measuring internal cluster consistency and separation between clusters. The formula for the silhouette coefficient is:  
\[S=b-max(a,b)\]  
where:  
* \(a\) is the average distance between a point and all other points in its own cluster;
* \(b\) is the average distance between that point and the points in the nearest cluster;
* \(max(a,b)\) is the maximum between \(a\) and \(b\). * The silhouette coefficient \(S\) ranges from \(-1\) to \(1\):
* \(S\) close to \(1\) indicates that the point is well-matched to its own cluster. * \(S\) close to \(0\) indicates that the point lies on or near the boundary between two clusters. * A negative \(S\) suggests that the point may have been assigned to the wrong cluster. This coefficient helped validate the robustness of the clusters formed based on the variables Mode of Travel and Waiting Time, ensuring that the identified clusters reflected the patterns observed in the data.