{'fraction_non_alphanumeric': 0.030867163103531107, 'fraction_numerical': 0.008671631035311074, 'mean_word_length': 5.023003472222222, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
How do you go where? Improving next location prediction by learning travel mode information using transformers

Predicting the next visited location of an individual is a key problem in human mobility analysis, as it is required for the personalization and optimization of sustainable transport options. Here, we propose a transformer decoder-based neural network to predict the next location an individual will visit based on historical locations, time, and travel modes, which are behaviour dimensions often overlooked in previous work. In particular, the prediction of the next travel mode is designed as an auxiliary task to help guide the network's learning. For evaluation, we apply this approach to two large-scale and long-term GPS tracking datasets involving more than 600 individuals. Our experiments show that the proposed method significantly outperforms other state-of-the-art next location prediction methods by a large margin (8.05% and 5.60% relative increase in F1-score for the two datasets, respectively). We conduct an extensive ablation study that quantifies the influence of considering temporal features, travel mode information, and the auxiliary task on the prediction results. Moreover, we experimentally determine the performance upper bound when including the next mode prediction in our model. Finally, our analysis indicates that the performance of location prediction varies significantly with the chosen next travel mode by the individual. These results show potential for a more systematic consideration of additional dimensions of travel behaviour in human mobility prediction tasks. The source code of our model and experiments is available at https://github.com/mie-lab/location-mode-prediction.


INTRODUCTION
The rapid urbanization process in the last decades has caused a constant increase in individual travel, imposing significant challenges in achieving sustainable cities. To meet the sustainable development goals of the United Nations [12], mobility behaviour change and new mobility concepts to promote these changes will play indispensable roles [26]. These mobility concepts, such as mobility as a service (MaaS) [30], smart charging [43] and ride-sharing [16], all rely on the capability to proactively provide personalized services that are tailored to the travel context and individuals' characteristics [23]. Individual mobility prediction to know when and where travel will occur is a crucial technique driving the development and application of these new concepts and, therefore, a key technology for sustainable transportation.
The prediction of where an individual will go given her historical mobility information is central to individual mobility prediction. The problem is also known as the next location prediction and has attracted much attention over the last decade. Researchers are increasingly interested in tackling this problem using learning-based methods thanks to the booming of deep learning (DL) models [22]. As it can be formulated as a sequence prediction problem, similar to the tasks encountered in natural language processing and audio processing, models that have shown success in these two fields are often directly applied. In particular, the transformer model [39] that utilizes a multi-head self-attention mechanism has revolutionized various sequence modelling tasks due to its powerful and efficient network structure. Transformer models are also starting to gain attention in predicting individual mobility, as they tackle some challenges in mobility prediction by design: (1) Multiple periodicities co-exist in the location visitation patterns of individuals [9] (e.g., daily, weekly). These periodicities vary considerably across individuals. The multi-head self-attention module allows the network to focus on multiple steps in the input sequence, effectively capturing these periodicities. (2) The long-term dependency of mobility behaviour. Studies have shown that the current mobility depends on behaviours conducted days or weeks before [4,37], which requires the prediction model to capture long-term dependencies. The design of the transformer model enables efficient learning of these dependencies. However, human mobility also exhibits unique characteristics, such as complex spatio-temporal dependencies [9,20] and the inherent stochasticity of location visits [36], which hinder the performance when applying sequence learning models on raw location visit sequences. Therefore, learning to predict the next location directly from historical location visits is challenging. An accurate prediction model should consider context information that influences individuals' choice of locations.
Results from travel behaviour studies that aim to understand individuals' activity location choices could guide the consideration of context information. Empirical evidence suggests that the selection of activity locations is highly correlated to other aspects of individual travel behaviour, such as the availability of travel modes [27] and the day of the week [7]. However, the comprehensive information regarding individuals' travel behaviour is not fully utilized in location prediction problems. To date, it is still unclear (1) how strong the influence of these long-term factors is on choosing the immediate next location and (2) whether the DL network can benefit from this knowledge and learn the complex dependency patterns directly from data.
To close this research gap and answer the above questions, we propose a transformer-based model that utilizes historical travel behaviour to predict individuals' next location. More precisely, the model aims to learn mobility transition patterns from historical location, temporal and travel mode sequence information. Inspired by travel behaviour studies, we encourage the model to also predict the next travel mode the individual will choose. We anticipate that this ancillary task will help the prediction of the next location. Through experiments on two real-world GPS datasets, we demonstrate the effectiveness of our model design and quantify the dependency of location prediction performance on travel mode. Our results show that careful consideration of individual travel behaviour significantly benefits human mobility prediction. In short, our contributions are summarized as follows: • We propose a transformer decoder-based neural network that utilizes location, travel mode and time-related information for the next location prediction task. The proposed model achieves state-of-the-art performance. • We show that jointly learning the next location and next mode improves the prediction performance for both tasks. • We conduct extensive experiments on two real-world GPS tracking datasets and conclude that considering additional aspects of travel behaviour significantly increases the performance of next location prediction.
The rest of this paper is organized as follows. We first systematically review related work in Section 2. In Section 3, we formulate the next location prediction problem. Next, we introduce details of the network architecture in Section 4. We apply our model to two real-world GPS datasets and analyze its performance in Section 5. Finally, we summarize the main findings and conclude the paper in Section 6.

RELATED WORK 2.1 Next location prediction
The next location prediction problem has found application in many different fields, such as recommendation systems [44], sensor networks [28], and mobility behaviour analysis [41,42]. The exact definition of the problem varies across studies due to different objectives and employed datasets. For example, location-based social network (LBSN) applications focus on predicting the next checkin point-of-interest (POI) [40,44]. In contrast, mobility behaviour studies aim to understand the next location for a user to conduct an activity [34]. Here we focus on the methods proposed for mobility applications.
The last decade has witnessed the expansion of studies focusing on next location prediction. Markov Chain and its variants are probably the most often employed methods for the task [22]. These models regard locations as states and construct a transition matrix that encodes the transition probability between states for each individual. Ashbrook and Starner [1] and Gambs et al. [11] both proposed identifying significant locations from GPS data and building a Markov model to predict location transitions. Later Markov model variants that consider collective movements [3] and incorporate location importance [17] further increased the prediction performance. However, Markov-based models struggle to represent the complex sequential patterns in human mobility because of their inherent assumption that the current state only depends on the states of previously limited time steps [20].
Recent advances in DL have also promoted their application in location prediction. As a widely adopted sequence modelling method, recurrent neural network (RNN)-based models, such as Long Short-Term Memory (LSTM) [34] and spatial-temporal (ST)-RNN [21], were reported to outperform Markov models by a large margin in the task. Still, vanilla RNN models tend to underweight long-term dependencies when the input sequence length increases. Therefore, studies employed the attention module to capture both short-term and long-term dependencies dynamically [9,20]. Moreover, the transformer model that builds on top of the multi-head selfattention mechanism [39] have started to gain interest in the field. In particular, Xue et al. [44] proposed MobTcast for considering various contexts with a transformer-based structure and achieved state-of-the-art POI prediction results for LBSN data. Although having great potential in learning the complex spatio-temporal dependencies, limited studies have applied transformer for the location prediction problem.

Factors affecting activity location choice
Understanding the factors affecting activity location choice is beneficial for predicting individuals' mobility, as they can be regarded as prior knowledge and potentially guide the learning of DL models. In the travel behaviour field, the choice of locations is regarded as an integral part of individuals' activity-travel behaviour and has been studied within the activity-based framework [32]. Studies that focus on analysing travel behaviour over time suggest that both stability and variability are found in individuals' activity location choices. For example, Dharmowijoyo et al. [6] showed that the variability of location visits is much larger between weekend-weekday pairs than between weekday-weekday and weekend-weekend pairs. Empirical studies also demonstrate the correlation of different aspects of individual travel behaviour. For example, Susilo and Axhausen [38] reported high repetition in location-mode combinations, suggesting that individuals use the same travel mode to reach their locations. Similar conclusions were reported by Hong et al. [14], where they found that only a subset of all location-mode combinations is essential for describing the mobility behaviour. From this perspective, aspects of travel behaviour can be considered constraints for individuals' choice of activity locations.
A similar problem as the next location prediction is the formulation of an individual's location choice set, which is a crucial component in microscopic traffic simulation models [19]. Instead of predicting the exact next location, the problem aims at generating a set containing all possible locations. Based on time geography theory, potential path areas analysis has been applied to tackle the problem, suggesting that the choice set is constrained by the travel time [33], time of day [45] and the available travel mode [27]. However, this empirical knowledge is not fully utilized in models for location predictions.
Building on the previous studies, we utilize a transformer-based model for learning spatio-temporal dependencies in individual location visits. In addition, we consider other aspects of travel behaviour that constrain an individual's activity location choices in the learning process.

PROBLEM FORMULATION
We formulate the next location prediction problem with the following definitions: Definition 1 (Trajectory). Let ( ) be a user in a set of users U = (1) , (2) , ..., ( | U |) , a trajectory ( ) = [ 1 , 2 , ..., ( ) ] is a time-ordered sequence composed of ( ) track points visited by ( ) . A track point can be represented as a tuple of = ⟨ , ⟩, where records the time when the user visits, and = ⟨ , ⟩ represents spatial coordinates in a given reference system, e.g., latitude and longitude.
Definition 2 (Location seqence). Location is defined when a user remains within a certain geographical radius for a defined time, and is a sub-sequence of the user's trajectory. A location sequence ( ) = [ 1 , 2 , ..., ( ) ] is a time-ordered sequence composed of ( ) locations visited by ( ) . Each location = ⟨ , , ⟩ is described by the arrival time , the (main) travel mode used to reach that location, and the identifier ∈ O, where O is the set containing all known locations.

Problem 1 (Next location prediction). Consider the historical location sequence
where is the current time step and is the number of considered previous locations, the goal is to predict the location identifier the same user ( ) will visit in the next time step, i.e., +1 ∈ O.
In this study, we construct the historical location sequence using locations visited in the previous 7 days. Thus, the number of considered previous locations depends on the user ( ) and the current time step , making the next location prediction a sequence prediction problem with variable sequence length. Figure 1 presents the overview of the proposed model. Specifically, the model considers historical location, time and travel mode patterns as input and learns from the auxiliary task of predicting the next travel mode to improve the prediction of the next location. The model consists of three major components: (1) feature embedding (Section 4.1); (2) transformer decoder and fully connected (FC) layers (Section 4.2); and (3) loss design and prediction (Section 4.3). The detailed description of each component is presented in the following subsections.

Embedding learning
The representation and modelling of historical information is a vital step for accurately predicting the next location. Most existing prediction models utilize the location visitation sequence to understand the complex spatial-temporal dependencies. We additionally consider temporal and travel mode information that can provide context for visitation patterns. Moreover, user information is beneficial for the network to identify location sequences travelled by different users and learn user-specific movement patterns. Therefore, we regard the location , the start time , and the travel mode at any time step as well as the user ( ) (represented as a unique identifier) of the current sequence as the input features (see Figure 2). Specifically, we extract the time of the day ℎ (grouped into 15-minute bins) and the day of the week from the start time , aiming to separate different levels of periodicity in location visits.
We now introduce the embedding method to transform each feature from the categorical type to a finite-dimensional real-valued vector. This is a more efficient and effective way to represent the correlation between different categorical values compared to the commonly used one-hot encoding method [10,20]. The embedding layers are parameter matrices that provide mappings between the original variable and the real-valued vector, whose parameters are jointly optimized with the entire network. The feature construction process can be formulated as follows: are the respective embedding vectors, and , ℎ , , and ( ) are the respective one-hot encoded original categorical features. W terms stand for weight matrices that are optimized during training. See Figure 2 for an illustration of the embedding process. Finally, the total embedding vector for each time step is obtained by adding all sequence features together with a position encoding : We use the original positional encoding proposed by Vaswani et al. [39] that utilizes sine and cosine functions to encode sequence information in the embedding. Positional encoding is essential for the training as the self-attention module does not implicitly assume sequential order [39]. Note that we use addition instead of a concatenation operation to combine embedding vectors [46]. This process allows the model to flexibly balance the importance of each feature, as compared to manually assigning and tuning the sizes for different embedding vectors. After the embedding process, we obtain a single user embedding ( ) and a sequence of embedding vectors representing features at each time step , which can be further processed with the transformer-based network.

Transformer and fully connected layers
An accurate next location prediction model should be able to extract regularities and capture the multilevel periodicity from the complex  The network's output is concatenated with user embedding and processed through a fully connected residual block for predicting the next location. We introduce the next mode prediction as an auxiliary task to guide the learning process. spatio-temporal historical sequences [9]. We utilize a transformerbased network to learn location transition patterns from historical location, temporal and travel mode information encoded in the final embedding vector . We adopt an architecture similar to the Generative Pre-trained Transformer (GPT) model, originally designed for language modelling [29], where only the transformer decoder part is used. The decoder consists of a stack of identical blocks (see Figure 3), each with two layers. The first is the masked multi-head attention, and the second is the fully-connected feedforward network with two linear layers and a ReLU activation function. Residual connections and layer normalization components are added to each layer to facilitate learning [13]. The input and output dimension of each block is designed to be the same as the embedding vector, i.e., = . The core of the transformer structure is the multi-head selfattention mechanism. The attention function can be understood as obtaining an output value based on a query and a set of key-value pairs, all of which are vectors of size . As described by Vaswani et al. [39], transformer uses the scaled dot-product attention and implements the calculation efficiently by packing the set of query, key and value values into matrices Q, K and V. This process can be formulated as follows: Then, multi-head attention is constructed by concatenating the results of attention functions (see Figure 3): where ⊕ represents the concatenation operation and terms are parameter matrices learned by the network. In each masked multihead attention, key, value and query matrices are identical, all corresponding to the output of the previous block. In the first block, they are set as the embedding matrix , obtained through stacking all embedding vectors according to their sequence. Note that we additionally include the forward-masking operation to prevent the attention function from accessing information from "future" time steps (see Figure 3); that is, the entry at time step can only focus on the information preceding (and including) . The selfattention mechanism enables the model to access information from every step in the historical sequence and evaluate its importance by learning parameter matrices. This ensures that long-term dependencies in the historical pattern can be extracted. Additionally, thanks to the multi-head design, the model retains multiple sets of parameter matrices that focus on various places in the historical sequence, efficiently capturing the multi-level periodic nature of human mobility.
Then, the output vector of the transformer-decoder model is concatenated with the user embedding ( ) , and fed into a fully-connected residual block: where (·) represents the operation by the fully-connected residual block, whose structure is shown in Figure 4. It consists of a single linear feedforward layer and a ReLU activation function, followed by a dropout layer, residual connection and a batch normalization layer. This block learns the dependencies of the transformer decoder output and the user embedding, helping the model extract user-specific movement patterns. Finally, the aggregated vector representation encapsulates location, temporal, travel mode and user information of the entire historical sequence, and can be further used to predict the next location.

Linear
ReLU FC Dropout Batchnorm Add Figure 4: Structure of the fully-connected residual block.

Loss and training
The aggregated vector representation is then fed into two branches: the next location prediction branch and the next mode prediction branch. For the first task, we calculate the probability of each location through a linear projection and a softmax function: where (+ 1 ) of size |O| contains the probability of all locations to be visited at the next time step. Therefore, the most likely visited location+ 1 at time step + 1 is the location with the highest probability in (+ 1 ). Given the ground truth next location +1 from the training dataset, the task can be regarded as a multi-class classification problem. We obtain our location prediction loss L 1 using the multiclass cross entropy: where (+ 1 ) ( ) represents the predicted probability of visiting the -th location and ( +1 ) ( ) is the one-hot represented ground truth, i.e., ( +1 ) ( ) = 1 if the actual visited next location is the -th location, and ( +1 ) ( ) = 0 otherwise. In addition to predicting the next location, we enforce the network to predict the next travel mode and optimize the network's parameters based on the joint prediction loss. This design is motivated by the assumption that learning to correctly predict the next travel mode can improve the prediction of the next location. Analogous to the next location probability, the probability of choosing each travel mode (ˆ+ 1 ) can be obtained as follows: Therefore, we introduce the mode prediction loss L 2 using the multi-class cross entropy: where |M| is the total number of travel mode categories, (ˆ+ 1 ) ( ) represents the probability of using the -th mode at time step + 1 and ( +1 ) ( ) is the one-hot represented true next mode. The final loss is the combination of the two losses. Given training samples in mini-batches of size , the network's parameters are optimized by minimizing the following loss: where L 1 ( ) and L 2 ( ) correspond to the location prediction loss and the mode prediction loss of the -th training sample in the mini-batch, respectively, and balances the relative weights of the two losses.

EXPERIMENTS 5.1 Datasets
We test the proposed method using longitudinal tracking datasets from two tracking studies performed in Switzerland. The Green Class (GC) study [24]. The study contains 139 participants based in Switzerland who got access to a comprehensive mobility package consisting of a general public transport pass valid in Switzerland, as well as access to several car-and bike-sharing programs and a battery electric vehicle for their personal use. All participants were asked to record their movements using a tracking app on their phones between November 2016 and January 2018. The app pre-processed the movement of participants into staypoints (stationary behaviour) and triplegs (continuous movement without changing travel mode). The study participants provided high-level activity labels for staypoints (home, work, errand, leisure, wait, and unknown) and mode labels for triplegs (car, e-car, train, bus, tram, bicycle, e-bike, walk, airplane, boat, coach).
The yumuv study [30]. The study involves 498 participants based in and around the city of Zürich, Switzerland. Participants were tracked over three months between July and September 2020, when COVID-19 case numbers, non-medical interventions and impact on people's daily lives were low in Switzerland. Participants got access to a mobility-as-a-service app called yumuv that provided simplified access to several micro-mobility modes. All participants were tracked via an app on their phones. Similar to the GC study, the app pre-processed movements into staypoints and triplegs that participants labelled with activity labels and travel modes.
We pre-process the raw movement data from the GPS tracking studies into corresponding analysis units for the next location prediction task using Python and the open-source Trackintel framework [25]. We only consider users tracked for more than 300 days in GC and more than 30 days in Yumuv to ensure high temporal tracking coverage. 93 users in GC and 422 users in Yumuv remain. Based on the activity label, we regard a stay point as an activity if its duration is longer than 25 minutes or if it was labelled with a non-trivial purpose (any available purpose except for wait or unknown). Then, the activity stay points are spatially aggregated into locations to account for visits to the same place at different times. We utilized the function provided in Trackintel with parameters = 20 and _ = 2 to generate dataset locations [15]. Locations are also attached with the arrival travel mode. Since travel to a location may involve multiple stages with various travel modes, we determine the main travel mode as the mode with the longest distance [2]. We further group the main travel mode into seven groups: walk, bicycle, train, tram, bus, car and other (including ski, airplane and coach). Table 1 shows the number of locations in both datasets, categorized based on the main travel mode. We split the location visitation sequence of each user into train, validation and test sets with the ratio of 6:2:2 based on time, such that location records that occurred in the first 60% of days are considered as train and the last 20% of days as test. The hyperparameters are tuned on the validation set, and the test set is only used for reporting the prediction performance. We train a single population-level model using records from the training set of all users. We do not pre-filter the locations visited less often, which is a pre-processing step usually found in the location prediction models using GPS traces (e.g., [34]). Although preserving the original location transition patterns, this setting makes the problem a more challenging task, as a large proportion of mobility consists of exploring new locations that are difficult to predict [5].

Setup
The hyper-parameters for the network are reported in Table 2. We chose the best performing set of hyper-parameters using grid search: the number of layers from {2, 4, 6}, the number of heads from {4, 8}, the size of the embedding from {32, 64, 128, 256} and the dropout of the FC layer from {0.1, 0.2, 0.5}. The in the final loss (Eq. (15)) is set to 1. Adam optimizer with an initial learning rate of 1 −3 and L2 penalty of 1 −6 is used to optimize the model's parameters. We implement learning rate warm-up and decay as reported by Vaswani et al. [39]. To alleviate the model over-fit on the training dataset, we use an early stopping strategy to pause the learning if the validation loss stops decreasing for 3 epochs. We then drop the learning rate by 0.1 and continue the training from the model with the lowest validation loss. This process is repeated 3 times. We implement several popular methods as baselines to compare with our proposed model. The approaches we choose are as follows: (1) Markov models. The de facto standard method for this task [11,17,18]. We implement the 1 st order Mobility Markov Chain (1-MMC) [11], as our pre-experiment shows that higher-order methods can not improve the prediction performance. (2) LSTM network, a widely adopted recurrent neural network (RNN) model for sequence data, has been successfully applied to predict the next location [34,42]. We implement the model proposed by Solomon et al. [34]. (3) Deepmove [9]. It incorporates a historical attention module to extract historical movement patterns with RNN-based networks. We consider the most recent two days as the current sequence and the remaining five days as the historical sequence for the input to the model. (4) MobTcast [44]. It considers temporal, semantic, social, and geographical contexts with a transformer encoder-based structure to forecast the next POI. Also, the model includes two losses to encourage predicted and ground truth locations to be close in space. We incorporate all components except for the social context since the overlap between location visits for our users is low due to the high-resolution GPS tracking. (5) LSTM with selfattention (LSTM attn). Inspired by Li et al. [20], we implement an LSTM-based network with self-attentions between the current and previous hidden states.
We use the following metrics to evaluate the next location prediction performance of various methods: (1) Accuracy. It indicates the number of correctly predicted locations by the network. We rank the predicted probability from (+ 1 ) in descending order and count the number of times that the ground truth location appears in the top-k predicted locations (Acc@k). Acc@1, Acc@5, and Acc@10 are reported. (2) F1 score. Since certain locations are visited more often than others [35], we employ the F1 score weighted by location visitation frequency. We argue that the F1 score is a better metric than Acc@1 as it considers the unbalanced location visits. (3) Mean Reciprocal Rank (MRR). The metric is commonly applied to measure performance in information retrieval and re-identification tasks. MRR is the harmonic mean of the ground truth label's rank in the prediction. Table 3 shows the performance of next place prediction methods on the two considered datasets. We train each DL model 5 times with different random seeds and report the mean and the standard deviation of the respective performance indicators. The 1-MMC method provides a strong baseline for the task. However, its performance is worse than any DL model, indicating that the Markov property cannot fully capture mobility patterns. On the contrary, the naïve LSTM model outperforms the 1-MMC method by a relatively large margin, demonstrating the effectiveness of DL-based models in predicting mobility. The worse performance compared to other DL methods can be attributed to the insufficient consideration of long-term dependencies in location visit sequences, an inherent shortcoming of the LSTM model [39]. This deficiency is partly tackled by introducing the historical attention module in the Deepmove model that explicitly focuses on extracting historical information, which consistently outperforms the naïve LSTM on all indicators for both datasets. MobTcast obtains comparable performance in Yumuv and slightly better F1 and Acc@1 scores in GC compared to Deepmove, suggesting the additional consideration of context and the introduction of two losses have limited effect on predicting an individual's next location.

Overall performance.
However, we observe a significant performance increase by adding a self-attention mechanism to the naïve LSTM model. The self-attention's ability to focus on specific steps during prediction indicates that successfully mining historical patterns can greatly benefit location prediction. By incorporating the multi-head selfattention and introducing the next mode prediction loss, the proposed model outperforms all other models by a relatively large margin. The relative increase of the F1 score is 8.05% and 5.60% for two datasets, respectively, which is calculated using the formula ( 1 1 − 1 2 )/ 1 2 , where 1 1 is the F1 score of our model and 1 2 represents the F1 score of the second-best performing model. The consistent pattern for both considered datasets demonstrates the effectiveness of our network architecture and loss design. Additionally, we report that the performance difference between LSTM with self-attention and our transformer decoder-based model is relatively small in Acc@5 and Acc@10 compared to the other indicators. We assume that the single head self-attention can already extract multiple likely visited next locations but lacks the ability to distinguish the importance within this set successfully.

Ablation study.
We perform an extensive ablation study to understand the importance of each component in our proposed model. In Table 4, we show the performance of different variants of our model, considering whether or not to include temporal features ℎ and , the travel mode feature , and the next travel mode prediction loss L 2 . The performance results are consistent across both datasets. We first report that the model performs significantly better with temporal features. This increase is intuitive as the time encodes different levels of periodicity in location visits compared to merely having the sequence information. While considering the travel mode feature and the mode prediction loss are both beneficial for the model's performance, the latter is more important for the task. Moreover, we observe a further performance gain when simultaneously including the travel mode feature and the mode prediction loss, as indicated by the highest performance achieved by the complete model for both datasets. These experiments show that temporal features are indispensable for accurate next location prediction. They also confirm that both historical travel mode patterns and the ability to predict the next travel mode are essential for the task, justifying the effectiveness of our model design.
Since our proposed model outputs both the probability of the next location and the next travel mode, we can utilize the same Table 4: Performance of the ablation study for next location prediction. We consider the model with (✓) and without (-) adding temporal features (T), the travel mode feature (F), and the mode prediction loss (L 2 ). model structure to evaluate the performance of predicting the next travel mode. From this viewpoint, time and location can be regarded as additional features, and predicting the next location can be seen as the auxiliary task. We evaluate the usefulness of these components in the next mode prediction task using an ablation study. The performance result are shown in Table 5. We again observe a large performance increase after including temporal features. Furthermore, historical location visits and the additional location prediction loss benefit the prediction. The top performance is achieved by the complete model that utilizes all three components in the network. These results indicate that the next travel mode prediction performance can be improved by considering location visit information. Combined with the location prediction ablation study, we conclude that the next location and the next travel mode prediction tasks are inherently dependent and should be tackled together to achieve optimal performance.

Importance of travel mode information.
We further investigate the influence of travel mode on the next location prediction task. To understand to what extent the next location prediction result depends on the prediction of travel mode, we input the ground truth next travel mode into the model. This is achieved by feeding the travel mode at the next time step into the mode embedding layer to generate the embedding vector +1 . Then, the vector is added to the user embedding and further processed with the fully connected layer, i.e., Eq. (10) becomes = (( + Linear( +1 )) ⊕ ( ) ). We can regard this new problem as predicting the next location conditioned on the next travel mode, where the scenario is to predict the location when knowing which travel mode the user will take. Figure 5 compares the performance of the original model with the model that includes the next travel mode. When knowing the next travel mode, we observe a notable increase in all indicators for the two datasets. In line with the conclusion from the ablation study, this result illustrates that the choice of the next location depends strongly on the travel mode. The performances shown in Figure 5 can also be interpreted as the upper bound of performance gain that can be achieved by including the prediction of travel mode in our model. This result suggests that working on a better mode prediction still holds great potential to increase the prediction accuracy of the next location. This mode-location dependency is evident by checking differences in predicting various categories of locations. In particular, we group the location prediction result based on the ground truth next travel mode and plot the F1 score in Figure 6. Each "box" in the figure is generated by the F1 score of every user and represents the model's performance in a single travel mode. We also labelled each box with the median F1 score across users. The differences in the F1 scores suggest that location prediction depends on the travel mode: locations with specific travel modes are more challenging to predict than others. For example, the locations reached by tram and bus obtained relatively lower performance than other modes in GC (Figure 6a). For Yumuv, the mode tram achieves a relatively low median F1-Score, and the mode bus has a high variance across users (Figure 6b). This observation could be attributed to the more variate choice of locations when users travel with these modes. The failure to predict the mode other (including airplane, ski and coach) is related to the exploration nature of human mobility: users often travel with these modes to new locations that are difficult for the model to predict. Moreover, the distinct pattern for the GC and Yumuv datasets can be explained by the mobility patterns of the two groups of participants. GC participants are more active in their mobility and often travel a longer distance by car and train [14], whereas Yumuv users mostly commute within the city [30] and have a more balanced use of travel modes (Table 1).

DISCUSSION AND CONCLUSION
Travel behaviour researchers have long realized that individuals' choice of locations is highly influenced by other travel behaviour dimensions, such as the day of the week and the availability of travel modes. While this dependency is evident in an increasing number of empirical studies, limited attention has been placed on integrating this information into the next location prediction task. In this study, we present a transformer-based model to predict the next location visit of an individual. In particular, the model is designed to accurately predict the next location and the next travel mode at the same time. We test our model on two large-scale real-world GPS tracking datasets and compare its performance with most recent methods for the task. Our experiments show that the proposed model learns the dynamics of human mobility from historical time, travel mode and location sequences and obtained state-of-the-art next location prediction performance. Our extensive ablation study demonstrates that temporal and travel mode features and the ability to predict the next travel mode are essential components in an accurate location prediction model. Moreover, our analysis indicates strong mode-location dependency, which suggests the next location and the next travel mode prediction tasks should be tackled together to achieve optimal performance. We conclude that considering historical travel mode patterns increases the accuracy of the next location prediction. This result connects travel mode detection models with next location prediction models. Mode detection models aim to classify a movement's travel mode given its spatio-temporal characteristics [31], which can enrich general tracking datasets that lack accurate user-provided travel mode labels. Therefore, mobility prediction can be tackled using a two-step approach: (1) identify the travel mode with detection models based on spatio-temporal movement characteristics; and (2) predict the next location with prediction models based on temporal, travel mode and location information. This approach indicates that an optimal system for mobility prediction should develop accurate models for both tasks.
Next location prediction is an essential backbone of many sustainable transport solutions; however, it is a challenging problem that is not yet fully tackled. Although we improve the state-ofthe-art considerably compared to the other methods, the field still needs more research to achieve a more accurate prediction performance. We propose several future directions based on the results of this work. This study demonstrates the importance of travel mode for predicting an individual's immediate next location visit. Since the mode-location dependency is more evident on a longer time scale [14,38], future research should consider integrating travel mode information into mobility simulation models for generating more realistic mobility sequences. Furthermore, besides the interdependent travel behaviour dimensions, studies have shown that external contexts, such as the built environment, play an indispensable role in shaping individuals' mobility [8]. This knowledge can be effectively extracted and combined with individual mobility in DL models based on land-use maps and POI data. Whether or not the additional information will improve the performance of next location prediction or mobility generation tasks is a direction worth exploring.