Short-term urban road congestion prediction considering temporal-spatial correlation

. In order to address the gaps in the study of short-term urban road congestion prediction based on Baidu map real-time road condition data, a short-term prediction model for urban road congestion based on Pearson Correlation Coefficient (PCC) and Weighted Markov Chains (WMC) is constructed by combining historical temporal correlation of urban road congestion data with spatial correlation between road sections. The model use the PCC method to filter out the spatially significantly related road sections from the upstream and downstream sections of the target road section and add them to the target road section data set as the data input of the WMC prediction model to achieve the short-term prediction of urban road congestion. The performances of the proposed models are validated by using manually collecting real-time road condition data from Baidu map. The research results show that the model integrate the spatial and temporal correlations in the urban road congestion data. Compared with other three prediction models, the prediction accuracy of the proposed model is improved by 3.096% on average, and the prediction error is reduced by 0.135 on average.


Introduction
Baidu Map Smart Traffic uses the City Road Congestion Index as an objective indicator of traffic congestion on urban roads, with a larger congestion index representing a higher level of congestion.According to the size of the congestion index, Baidu map classifies the congestion level of city roads into four states: smooth, slow, congested and severely congested.With Baidu map's real-time road conditions feature, we can understand the congestion status of each road section in real time so that we can plan our routes.However, when we need to plan our route some time in advance, Baidu map's real-time road condition function is useless, while its road condition prediction function can only predict the congestion status at one-hour intervals, which obviously does not meet our needs.
There is a gap in the current research on short-term prediction of urban road congestion based on Baidu maps.For the urban road congestion, which is a discrete time series in both state and time, this paper is inspired by Xie Kaibing use autocorrelation coefficients to calculate the weights of Markov chains of different orders to form weighted Markov chains for state prediction of traffic volume after division into different states [1] and Shao Chunfu et al use PCC algorithm to form a temporal-spatial combination model for traffic volume prediction [2], using PCC algorithm to explain the spatial correlation between the target road sections and the upstream and downstream road sections, and using autocorrelation coefficients to consider the correlation between different time steps, the PCC-WMC prediction model that considers both temporal and spatial correlation is proposed for urban road congestion prediction.
The Markov chain process is characterised by the fact that each transfer of states is only related to the previous state of the interconnection and is independent of the past states [3] .At present, Markov chains are more often used in the field of traffic flow prediction in the direction of transportation.Chen Shuyan et al proposed a prediction method combining wavelet analysis and Markov magic, which improved the anti-interference of the prediction model [4]; Jiang Lizhong et al proposed to combine Grey model and Markov chain model to form Grey Markov chain model for traffic flow prediction, and the experiment showed that the model has certain feasibility [5]; Li Junhuai et al proposed to combine exponential smoothing theory and Markov chain, and the experiment showed that the combined model is more accurate than the single model [6]; Xu Mengmeng et al improved the prediction accuracy of the model by correcting the residuals on the basis of the Grey Markov model [7]; Shen Qidong et al introduced traffic flow prediction influence factors from time and space to achieve traffic flow prediction of intersections [8].

A model for predicting urban road congestion based on temporal-spatial characteristics 2.1 Spatial feature mining
Spatial feature mining refers to considering the influence of congestion of upstream and downstream road sections on the target road section, using the inter-section correlation degree to characterize the mutual influence between the two road sections.In this paper, PCC is used to explain the correlation degree between the target road section and the upstream and downstream road sections, assuming that the time series of the target road section


, and the time series of the upstream and downstream road sections


, then the correlation coefficient between the two road sections is Where AB r is the correlation between two road sections A, B; T is the length of the time series.When AB r tends to 1, it means that the correlation between the target road section and the upstream and downstream road sections is greater; when AB r tends to 0, it means that the correlation between the target road section and the upstream and downstream road sections is smaller.In order to ensure the accuracy of prediction, 1 5 0   AB r . is taken as the range of spatial correlation coefficient in this paper.
It should be noted that the range of values for the spatial correlation coefficient is derived from a significance test for PCC, i.e. a range of PCC values that would indicate a significant correlation between the two road segments for a given sample size.The t-test [9] is used here, with the known statistic t , it indicates a significant spatial correlation between the two road segments.

Temporal feature mining
The congestion of urban roads in the target time period is not only directly related to the congestion of the previous time period, but also indirectly related to several previous time periods.In order to solve this problem, this paper adopts a weighted Markov chain to extract the temporal characteristics of the data, by constructing multiple Markov chains of different orders, using the autocorrelation coefficients of each order to obtain the weights of each Markov chain, and then using the weighted summation to calculate the prediction value of the congestion state with the highest probability.

Markov property test
Markov property means that past states and future states are conditionally independent if the current state is known.To apply Markov chain models to analyse and solve practical problems, it is necessary to first test whether the time series has Markov property.In fact, the test of Markov property is a test of whether the past and present states are conditionally independent, or a test of the correlation between the two.For discrete sequences, the 2    test [10] is a common method used for correlation tests.Thus, the 2  test can be used to test the Markov property of a time series.
Also assume that the target road section A time series is ] , , , [


, which includes four states: smooth, slow, congested and heavily congested, corresponding to state 1, state 2, state 3 and state 4 respectively.Now use  ij s to denote the frequency of the time series in time length T from state i to state j after one step, thus obtaining the frequency matrix  A S of the one-step state shift of the target road section A in time length T. The value obtained by dividing row i of the matrix  A S by the sum of rows i is the one-step state transfer probability, which is denoted as  ij p , and its matrix is denoted as  A P .The value obtained by dividing the sum of column j of the matrix  A S by the sum of all columns of the matrix is the marginal probability, which is denoted as When the amount of data is sufficient, 2 obey the 2  distribution with the degrees of freedom At a defined level of significance , if the statistic then the target road section A time series is considered to have Markov property.

Construction of a multi-step state transfer probability matrix
The construction of a multi-step state transfer probability matrix is an important prerequisite for the application of weighted Markov chains for prediction.After collecting some of the historical data, the overall state transfer probability matrix can be estimated from this sample data, as follows.
Firstly, assume that the time series of the target road


, which consists of four states: smooth, slow, congested and heavily congested, corresponding to state 1, state   (9) The final n-step transfer probability matrix for the


. It is important to note that the state transfer frequency matrix and the state transfer probability matrix here are not the same concept as the matrix used in Section 1.2.1.

Calculation of weights 1) autocorrelation coefficient of each order
Assume that the target road section A time series is ] , , , [


and it consists of four states: smooth, slow, congested and heavily congested, corresponding to state 1, state 2, state 3 and state 4 respectively.The nth order autocorrelation coefficient Where X is the urban road congestion at time t of target road section A; A X is the mean value of the time series A X of target road section A; T denotes the length of the time series.
2) standardisation Once the order autocorrelation coefficients have been calculated, they are standardized.The sum of the standardized autocorrelation coefficients is 1, which is then used as the weight of the Markov chain of the corresponding order.The standardisation formula for the autocorrelation coefficients of each order for the target section A is as follows.
is the weight of the nth-order Markov chain for the target section A; N is the number of different order Markov chains.

Prediction module
Assume that in a Markov chain of order n, the urban road congestion of the target road section A at time t By finding the state corresponding to the maximum probability in the weighted prediction probability vector, the predicted state value for the next moment can be obtained.
It is important to note that since this paper is to predict the urban road congestion for one continuous hour at five minute intervals after the current moment.Therefore, after predicting the next moment state value, it is necessary to continue to predict this predicted state value as if it were a known state.

Temporal-spatial feature prediction model
Assuming that there are m road sections in the target road network, the target road network time series matrix X can be defined as Where m X is the time series of road section m; m t X is the congestion state of urban roads at time t for road section m.
The congestion of urban roads at the next moment of the target road section is mainly related to the congestion of the previous moments and the significantly correlated upstream and downstream road sections.Therefore, in this paper, for the target road network time series matrix X, the PCC algorithm is used to find out the road sections with high correlation with the target road sections among the upstream and downstream road sections, and then reconstruct them into a new data set, and finally the reconstructed data set is used as the input data of the weighted Markov chain prediction model for prediction, and the specific operation of reconstructing the data here is to merge the target road section time series with the upstream and downstream significantly correlated road section time series.The model calculation process is divided into the following 9 steps.
Step 1 Build the spatial correlation coefficient matrix: use equation ( 1) to calculate the correlation coefficient between the two road segments and build the spatial correlation coefficient matrix according to the following equation.
Step 2 Spatial correlation coefficient ranking: the upstream and downstream sections of the target section are ranked according to their spatial correlation coefficients, from largest to smallest.
Step 3 Reconstruct the temporal-spatial feature matrix: filter out the road sections with correlation coefficients greater than 0.9, 0.8, 0.7, 0.6 and 0.5 respectively, and reconstruct them into a new data set.
Step 5 Construct the multi-step state transfer probability matrix: count the frequency matrix of state transfers for each step of the new data set and use equations ( 8) and ( 9) to obtain the multi-step state transfer probability matrix.
Step 6 Calculation of weights: each order of autocorrelation coefficient of the target road section is calculated using equation ( 10) and standardized using equation ( 11) to obtain each order of predicted probability vector weights.
Step 7 Urban road congestion prediction: a weighted Markov chain prediction model is constructed to predict the congestion of urban roads.
Step 8 Calculate the accuracy and the Root Mean Square Error (RMSE) of the model.
Step 9 Prediction results and error analysis.

Case design
In order to verify the feasibility of the PCC-WMC model, this paper manually collected 96 road sections (in both directions) from the second ring to the third ring in part of the Haidian District of Beijing through the realtime road condition function of Baidu map, and the congestion of urban roads from 16:00-19:00 with 5min interval for 22 working days, a total of 36×96×22 data, and the experimental road network is shown in Figure 1 and 2. The data of the first 21d were used as the training set and the data of the last day were used as the test set to predict the congestion of urban roads at 5min intervals from 17:05 to 18:05 on the last day.
where l is the number of predicted states that are the same as the actual states in the desired prediction period; L is the overall amount of predicted data required; i p is the predicted state value; i x is the actual state value.Accuracy is used to directly evaluate the correctness of the state prediction, the higher the value the better the prediction; RMSE is used to consider the size of the specific prediction error, the smaller the value the better the prediction.

Analysis of results
The model calculation process presented in Section 1.3 was followed to predict the congestion status of urban roads for each of the 96 road sections within the experimental road network.
Firstly, the data from the test set of section 1 is used as an example to verify whether it has Markov property.Using equations ( 4) and ( 5) in Section 1.2.1 to find the state transfer frequency matrix  1 S and the state transfer is that the actual states in the road section 1 time series contain only three states, state 1, state 2 and state 3.
The prediction of urban road congestion is then carried out.In order to study the influence of temporalspatial variables on the prediction results, the spatial correlation coefficient thresholds are set to 0.5, 0.6, 0.7, 0.8, 0.9 and 1 in this paper; the time steps, i.e. the number of Markov chains of different orders, are set to 1, 5, 6, 7, 8, 9 and 10.The prediction performance evaluation of the PCC-WMC prediction model under different values of temporal-spatial variables is shown in Tables 1 and 2.
In order to improve the prediction accuracy of the model, this paper uses the PCC algorithm for spatial feature mining.From the evaluation results, it can be seen that: when the time step is small (1,5,6), as the value of the spatial threshold value decreases, the accuracy continues to decrease and RMSE continues to increase, adding the PCC algorithm at this time instead reduces the prediction accuracy; when the time step increases to a certain number (7,8,9,10).As the value of the spatial threshold is taken to decrease, the accuracy first increases to reach a peak and then gradually decreases, and RMSE first decreases and then gradually increases.In other words, when the time information used for prediction is too small, adding spatial information will not have an optimising effect and may even have a negative effect; when there is enough time information, adding the right amount of spatial information can have an optimising effect to a certain extent, but too much spatial information will also interfere with the prediction results.
Further analysis of the effect of time step on the prediction accuracy shows that under the same spatial threshold value, the overall trend of the accuracy increases and then gradually decreases as the time step increases, while the overall trend of RMSE decreases and then increases.It can be seen that, within a certain range, the model prediction accuracy increases with increasing time step.When the prediction uses too little time information, the prediction is poor; while when the time step is too long, irrelevant time information will be added, resulting in poor prediction performance.This trend is not obvious in Table 1 and 2, and is visualised in Figure 3 and 4. As can be seen from the graphs, the highest accuracy and the smallest RMSE, i.e. the best overall prediction, is achieved when the time step is 9 and the spatial threshold is 0.9.In order to compare and investigate the prediction performance of the PCC-WMC prediction model for each time period in short-term prediction, the first-order Markov chain prediction model (MC_1), the first-order Markov chain prediction model considering temporalspatial correlation (PCC-MC_1 with the spatial threshold set to 0.9), and the weighted Markov chain prediction model (WMC with the time step set to 9) were used to predict the congestion of urban roads on each segment of the experimental road network.The prediction performance of the different models for each time period is shown in Figure 5 and 6.It can be seen that the PCC-WMC prediction model does not show superior prediction performance compared to the other three models in short time prediction, but when the prediction time increases and the prediction performance of the other three models decreases, the PCC-WMC prediction model maintains a more stable prediction performance, which makes it more advantageous in short-term prediction.Comparing the PCC-WMC and WMC prediction models, we can see that the addition of spatial information does not have a positive effect on short-term prediction, but as the prediction time increases, it gradually improves the prediction performance of the model.Overall, the PCC-WMC prediction model improved the accuracy by an average of 3.096% and reduced RMSE by an average of 0.135 compared to the other three models.1) This paper uses the PCC algorithm for spatial feature mining, which is simple to implement and the core idea is to characterize the degree of spatial correlation between road segments by dividing the covariance by the product of the standard deviation of the two time series.WMC is based on MC and uses a combination of the weights of each order obtained by using the autocorrelation coefficient for each order of Markov chain, effectively using more time information.
2) This paper investigates the effect of time step size on prediction accuracy, which increases with increasing time step size within a certain range.When the time step size is small and there is too little time information, the prediction effect is poor; while when the time step size used for prediction is too long, the added irrelevant time information will interfere with the prediction results.The effect of the spatial threshold on the prediction accuracy was also investigated.When the time step was small, the prediction accuracy continued to decrease as the spatial threshold decreased, i.e. when there was less temporal information, the added spatial information would interfere with the prediction results; when the time step was large enough, the prediction accuracy increased and then decreased as the spatial threshold decreased, i.e. when there was a lack of spatial information, the prediction results were poor, and the prediction is equally disturbed when too much irrelevant spatial information is added.Therefore, setting the values of temporal and spatial variables reasonably can improve the prediction accuracy.
3) In this paper, we studied the trend of prediction performance of different models in short-term prediction by time period.Overall, the prediction performance of all four models tends to decrease with increasing predict length, but the prediction performance of PCC-WMC prediction model is more stable, which makes it the best in short-term prediction.The superiority of the PCC-WMC model is not obvious for short time prediction, but when the predict length is long enough, its superiority gradually becomes obvious.
4) The PCC-WMC prediction model proposed in this paper can provide a new idea for the research and application of urban road congestion prediction based on Baidu map.In the subsequent research, the prediction performance can be improved by trying to use appropriate time steps and spatial thresholds for each road segment in the road network individually, so that the temporal-spatial information used in the prediction matches each road segment one by one.In addition, to address the problem that the prediction performance of the model is not good enough for short time prediction, a combination of models can be considered for separate prediction in different time periods to further improve the prediction performance.

Fig. 2 .
Fig. 2. Topological structure of road network In order to quantitatively analyze the prediction results of the model, the accuracy and Root Mean Square Error (RMSE) are used as the evaluation indicators of the prediction results in this paper, and each indicator is calculated by the following formula 100   L l accuracy (16) section 1 test set time series satisfies Markov property.The reason that the degrees of freedom are taken here as  

Fig. 5 .
Fig. 5. Trends in accuracy by time slot of different models

Fig. 6 .
Fig. 6.Trends in RMSE by time slot of different models

Table 1 .
Accuracy under different temporal-spatial variables

Table 2 .
RMSE under different temporal-spatial variables