## 4 Material and Method
### Learning Transformer Network  
The temporal order data of GPS locations are based on tracing mobility. As in the previous studies, RNN outperforms different architectures such as MLPs for mobility tracing with sequential data. These networks are not tailored to work with sequential data and temporal data. However, the limitation of RNN is that the training data cannot be parallelized. The transformer network takes place with parallelization to process the sequential data and temporal data. Furthermore, the previous research mainly focuses on the fine-grained single trajectories to predict the next taxi destination. In other words, these methods are based on all GPS location points of each ride [9]. The previous research has some important limitations; for instance, a vast volume of data of all GPS points of a trip are stored and almost all trajectory points are needed to predict the ending point. To avoid the problem mentioned above, we model the trajectory according to the definitions in the Preliminaries Section. The GPS point sequences of pick-up and drop-off are composed of pairs for several taxi rides. This is the best way to not keep all pick-up and drop-off points of the whole trajectory. In this way, the prediction takes place instantaneously; only the trip starts and pick-up location information is available. Therefore, most mobility models are set as the classification problem to predict the next location--the mobility model's goal is to classify the location we predict. We find the main drawback of this approach is during the model training, where most of the locations are unseen. The model never produces several locations. To overcome this drawback, we propose making the coordinates two different functions, longitude and latitude, to predict the destination. The spatial part has the location clusters. In the prediction part, as mentioned above, we define the set of clusters of locations as m=|C|. We calculate the clusters with the K-means clustering algorithm. The algorithm trains the destination of all the trajectories. We keep each point of the trajectory during the training process as consequently assigned to the nearest centroid \(C_{i}\). According to the Preliminaries Section, trajectory \(T_{\beta}\) is translated into the new mapped cluster. The new clusters are traced as \(CT_{\beta}=C_{1},C_{2},\ldots,C_{n}\). In the traced clusters, \(C_{i}\) is the hash of the cluster; this cluster is closest to the point. Since longitude and latitude are the points, we work with longitude and latitude values. We use the Haversine distance between the two points \(P_{1}\) and \(P_{2}\). The Haversine distance formula is helpful to compute the next taxi destination prediction. The formula is defined as follows:  
\[D_{haversine}(P_{1},P_{2})=2R\sqrt{\frac{a(dP_{1},dP_{2})-1}{a(dP_{1},dP_{2})-1}} \tag{11}\]  
\[a(P_{1},P_{2})=sin^{2}(\frac{(\phi_{2}-\phi_{1})}{2})+cos(\phi_{1})cos(\phi_{ 2})sin^{2}(\frac{\lambda_{2}-\lambda_{1}}{2}) \tag{12}\]  
In the above equation, R is the radius of the Earth, \((\lambda_{i},\phi_{i})\). \(i=1,2,3...\), are the values of longitude and latitude coordinates with probability \(P_{i}\). Our model, the spatial transformer, is an embedded layer that captures all information, for instance, time, day, mobility, influence by human mobility, and semantic classification of each place. Furthermore, each location represents a single feature; we apply it to the spatial transformer cluster embedding layer as input feature sequences. In this way, the origin and destination co-occurrence is based on dense representation and then based on the other transformer module. These modules help us gather all sequential information visited in the last locations. We apply our transformer network as a basic model, encoder, and decoder to make effective human mobility for this task. Inside the transformer, the attention layer consists of multi-head attention, which passes the information as an input sequence to the feed-forward neural layer.