# A Spatio-Temporal Schedule-Based Neural Network for Urban Taxi Waiting Time Prediction
## 3 Materials and Methods
### Spatio-Temporal Rules Neural Network Model  
#### 3.5.1 Neural Network Model Design  
The waiting time of a taxi passenger can be approximated according to Equation (1). \[t_{wait}=\frac{t-loc_{first}-t_{current}}{num}*\sigma \tag{1}\]  
In the equation, \(t-loc_{first}\) denotes the time for a passenger to encounter the first empty taxi at a given location \(loc\). \(t_{current}\) denotes the time point at which the current passenger is waiting for a taxi. \(num\) denotes how many times an empty taxi appears at the current location and current time in historical taxi trail. \(\sigma\) is an empirical value, describing the relevance between \(t-loc_{first}\) and \(t_{current}\). The value of \(\sigma\) ranges from 0 to 1. Without the loss of generality, \(\sigma\) is set to 1 based on practical experience. In order to better adjust the number of hidden layers of the neural network, this study adjusted the settings for predicting positive examples. Normally, passengers can put up with the longest waiting time at about 2 min, and 30 s of waiting time enable passengers to have best experience. This paper assumes that if the difference between the predicted value and the actual value does not exceed 30 s, a positive example will be identified. The neural network training model is optimized by the characteristics of waiting time, trajectory historical and POI data, behavioral and spatial data. The result will be taxi  
Figure 4: Multi-source data fusion method. waiting times distributed along the grid spatial and temporal representation of the city. The time-space feature optimization neural network model is shown in Figure 5.  
As demonstrated in related work, as long as there is a three-layer BP neural network with a hidden layer, any mapping function can be approximated [36]. We compare our neural network model results constrained by time and space features with up to four different hidden layers. It can be seen from Table 6 that the model with 2 hidden layers gave the highest accuracy. Therefore, the model uses a BP neural network with a five-layer structure of fully connected, as shown in Figure 6 below. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Hidden Layer** & **1** & **2** & **3** & **4** \\ \hline Accuracy & 92.5\% & 94.1\% & 93.3\% & 90\% \\ Error & 9.94 \(\times\) 10\({}^{-5}\) & 9.27 \(\times\) 10\({}^{-5}\) & 9.98 \(\times\) 10\({}^{-5}\) & 9.72 \(\times\) 10\({}^{-5}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 6: Error table for different hidden layers. Figure 5: Time–space feature optimization neural network model principles. The characteristic input values of the neural network model are represented by the main factors that influence the waiting time of taxi passengers in the grid as follows:  
* X1 is the time slice corresponding to the urban residents' daily schedule;
* X2 is based on POI data according to different urban functional area categories;
* X3 marks whether the day is a holiday;
* X4 determines whether the grid is in a particular location, such as a large business district, a large stadium and a general hospital. The output layer is the output Y of the neuron, which reveals the time it takes for a passenger to wait at the grid for the first empty taxi. We use the ReLu function as the neural network activation function. Because of the linear characteristics of the ReLu function, the negative value of the function is 0, while the positive value does not change, i.e., one-sided suppression. The neurons in the neural network are also sparsely activated, making it easier to learn and optimize. For nonlinear functions, the ReLu function overcomes the vanishing gradient problem because the gradient of the non-negative interval is constant, so that the convergence speed of the model is maintained in a stable state. The ReLu function formula is shown in Equation (2).