# Interpretability Study of Gradient Information in Individual Travel Prediction
## 4 Experiment
### Model Training  
The model training process is based on subway card swipe data from a large city, involving a subway system composed of 91 subway stations. The data samples obtained contain travel records from approximately 200,000 passengers. According to the travel records of these passengers, a data set is constructed, and four characteristics of departure station number o, destination station number d, departure week w, and travel arrival time t are selected to construct a spatiotemporal travel record:  
\[e=(o,d,w,t) \tag{15}\]In the feature processing stage, embedding techniques are employed to enrich the feature representation of individual travel records. For spatial attributes, such as subway station numbers, an embedding layer is used to map these discrete identifiers into a low-dimensional, dense vector space. Since the continuity of time does not directly reflect the numerical impact on travel predictions, the time attribute is first discretized into time points with categorical significance. For instance, a day is divided into several time intervals, and each interval is assigned an embedding vector. The core function of the embedding layer is to convert the discrete features in the travel records into continuous, high-dimensional vector representations. These vectors can capture the complex patterns and trends of individual travel behavior. After the embedding layer, a time-series processing layer was introduced to model the periodicity and temporal dependencies of travel records. This layer receives the sequence of travel record embedding vectors generated by the embedding layer and outputs a series of hidden states to capture the temporal information in the sequence. Specifically, the input to the time-series processing layer is a series of embedding vectors, and this layer processes these vectors through a recurrent neural network or its variants (LSTM or GRU), outputting a series of hidden states \([h_{1},h_{2},\dots,h_{N}]\). Among these hidden states, \([h_{1},h_{2},\dots,h_{N-1}]\) is referred to as the candidate vector, representing the cumulative information of each time step in the sequence; q serves as the query vector for the calculation of attention weights in the next stage. The attention layer constructs the context vector by meticulously capturing the similarity between the candidate vectors and the query vector. Specifically, a feedforward neural network (FNN) is utilized to transform each hidden state \(h_{t}\), yielding the corresponding nonlinear representations \(z_{t}\) as follows:  
\[z_{t}=\tanh(Wh_{t}+b) \tag{16}\]  
Here, \(t\in[1,n-1]\) and \(n\) is the sequence length. \(W\) denotes the weight matrix, \(b\) represents the bias term, and \(\tanh\) is the activation function, which introduces nonlinearity. After obtaining the nonlinear representations, the similarity between each \(z_{t}\) and the query vector \(h_{t}\) is calculated, serving as the basis for assigning attention weights. The calculation of attention weights \(\alpha_{t}\) can be expressed as follows:  
\[\alpha_{t}=\frac{\exp(z_{t}^{T}h_{t})}{\sum\limits_{t=1}^{n-1}\exp(z_{t}^{T}h_ {t})} \tag{17}\]  
Based on the calculated attention weights \(\alpha_{t}\), the candidate vectors \(z_{t}\) are weighted and summed to obtain the final context vector \(c_{t}\):  
\[c_{t}=\sum\limits_{t=1}^{n-1}\alpha_{t}z_{t} \tag{18}\]  
The context vector \(c_{t}\) integrates the information of all candidate vectors in the sequence, and this design enables the model to flexibly focus on the information that is most critical for prediction. The complete model training and interpretation process is shown in Figure 4.  
To explore the differences in gradient information interpretation of travel prediction models under different sequence lengths, three different travel sequence lengths were chosen, namely 20, 40, and 60. Then, all travel samples were divided into training and testing sets in an 8:2 ratio.