## 3 Methodology
### Trajectory Pre-Processing  
In mobility data recordings, motion is represented as a mapping function between space and time [28]. Trajectories are modeled as a series of chronologically ordered coordinate pairs enriched with a time stamp: \(T=\{p_{i}|i=1,2,3,\ldots,N\}\), where \(p_{i}=(lon_{i},lat_{i},t_{i})\). However, in order to feed the model properly, a pre-processing step is essential. The continuity of space and time needs to be subjected to a discretization process, by which the original traces are transformed into discrete location sequences \((LOC_{1},LOC_{2},\)\(\ldots,LOC_{N})\): continuous longitude and latitude variables are aggregated into discrete locations and time information is encoded in the position along the sequence. Each motion trace is therefore converted into a sequence of locations that unfolds in fixed time steps, and if more than one event refer to the same time step, the one with the most occurrences is chosen to represent the location of the user. The length of the time step depends on both the prediction problem and the data source (different ways of collecting motion data may define different time resolutions), to balance location accuracy with the completeness of the sequences: a long unit affects the accuracy of the actual trajectory representation, a short unit increases fragmentation in cases of discontinuous traces. Moreover, when the traces are very sparse over the territory and there are many locations with a very low number of occurrences, the poor results and the high computational cost could suggest grouping together adjacent locations, where multiple longitude/latitude pairs of individual track points can be mapped to the same discrete location. Raster-based partitioning, clustering, and stop point detection are typical approaches used to convert trajectories into discrete cells, clusters, and stay points [29]. Since human mobility is not usually uniformly distributed over the territory, we recommend methods which avoid cell partitioning when numerous cells contain very few location occurrences, leading to processing a large number of potentially inaccessible and irrelevant places, decreasing computational efficiency and prediction results. We suggest dealing only with locations that are visited by a sufficient number of users, areas with enough tracking of the historical motion behavior of visitors, avoiding bias samples in the dataset. A valuable option may be to choose a number of fixed meaningful reference points over the territory and project the other locations to the nearest reference point. The minimum distance between reference points can vary according to the precision required by different applications (e.g., predicting travel patterns over a country or exploring city-level mobility). The result consists of a number of fixed points, each of them representing a particular area or location.  
In conclusion, the pre-processed trajectory is represented by a discrete location sequence \((LOC_{1},LOC_{2},\,\ldots,LOC_{N})\), where, given a time step unit \(t\), locations in the sequence refer to time \((t,\,2t,\,\ldots,\,Nt)\). In the next subsection, we describe how to use these pre-processed trajectories for learning location embedding representations.