Truck Traffic Flow Prediction Based on LSTM and GRU Methods With Sampled GPS Data

Given the enormous traffic issues, such as congestion and crashes, resulting from the conflicts between trucks and passenger cars, an accurate and reliable prediction of truck traffic flow is needed to enhance the traffic flow efficiency and safety in the mixed traffic condition. Enabled by emerging sensing technologies, the GPS data become available and will reveal some insights to improve the understanding of truck traffic flow prediction. In the paper, a novel method of truck traffic flow prediction is proposed by using sampled GPS data in the roadway network. The proposed method consists of two phases, which are expansion and prediction. In the data expansion phase, a piece-wise constant coefficient method is designed to minimize errors between the sampled truck flow and the actual truck flow, where the coefficients are determined according to road grades and traffic flow size. In the prediction phase, Long Short Term Memory (LSTM) and Gated Recursive Unit (GRU) neural network methods are first time employed to improve the prediction accuracy. Considering that the sequence of the expansion and prediction could have different prediction performance, approaches using both ‘previous-prediction’, ‘post-expansion’ and ‘previous-expansion’, ‘post-prediction’ were used and the results compared with the survey data from traffic flows. The results demonstrate that LSTM and GRU have a superior performance compared to existing approaches using SRV and ARIMA for truck traffic flow prediction. For the whole prediction period, LSTM has better prediction results than GRU overall with an accuracy which is 4.10% better than that of GRU. Furthermore, the accuracy of the ‘previous-prediction’, ‘post-expansion’ is 8.26% greater than that of the ‘previous-expansion’, ‘post-prediction’.


I. INTRODUCTION
It is generally acknowledged that the efficient operation of modern supply chains, supporting sustained economic development, relies heavily on trucks for freight transportation. According to statistics, at the end of 2019, truck freight traffic in China had grown by a staggering 40.32% over the past decade (NBSC, 2020). On the positive side, this rise in truck traffic is a reflection of increasing economic activity, but it has also resulted in more road accidents, which in The associate editor coordinating the review of this manuscript and approving it for publication was Zhe Xiao . turn has led to increasing levels of non-recurrent congestion [30]. Therefore, in order to help address the blight of congestion caused by trucks, it is essential to understand current truck traffic processes and how to predict future traffic flow to within a reasonable horizon. Seeking to gain such an understanding, in previous approaches, detailed searches were made through data that were mainly obtained from the coil and video detection, which often have the problems of inaccurate vehicle type identification and missing traffic counts. However, an emerging alternative is the use of data collected by satellite positioning devices through the global positioning system (GPS). GPS data provide effective traffic information services for trucks and although in the past, such data have been used in various studies including the stopped truck purpose [10], truck travel time reliability [18] and truck traffic speed prediction [30], few studies have carried out in-depth analyses of truck traffic flow, especially using GPS data. One of the main reasons for this is because of problems arising from inaccuracies in the sampled GPS data where not all truck trajectories are captured in their entirety, largely due to errors in data transmissions from trucks to data centers leading to problems associated with incomplete and, therefore, inaccurate data sets. Moreover, the large amounts of data that are involved are generally difficult to analyze, thus representing an additional problem. To address these problems, this paper applies a data expansion technique and a deep learning method to illustrate how the sampled truck GPS data can be used to describe the current truck traffic flow in a roadway and to predict future traffic flow within a horizon of 1 hour.. Furthermore, in practical engineering projects, a dilemma that is often encountered relates to the order in which processes are done; in this study the processes are data expansion and prediction. Whether to expand the truck traffic flow data first followed by predicting, or predicting the truck traffic flow first and then expanding the data; which processing order will produce more accurate results? To address this dilemma, this paper applies the sampled truck GPS data to compare the prediction accuracy of previous-prediction, post-expansion and previous-expansion, post-prediction with traffic survey data representing the actuality of truck traffic flow on the road. To our knowledge, this is the first study to apply the sampled truck GPS data in an attempt to describe the actual truck traffic flow operating on the road, to predict future truck traffic flow, and discuss the forecasting accuracy of the order of expansion and prediction. It is anticipated that this study can be used to inform future road traffic management developments regarding the minimization of congestion and consequential road accidents associated with truck traffic.
The remainder of the paper is organized as follows: Section 2 is a comprehensive literature review. In Section 3, methodologies provide details on truck traffic flow prediction based on LSTM and GRU methods with sampled GPS data. Section 4 introduces the application data. Section 5 presents the modeling results. In order to verify the performances of the proposed models, the prediction results were compared with the traffic survey data. Finally, Section 6 summarizes the conclusions and highlights the perspectives from the viewpoints of research.

II. LITERATURE REVIEW
Since the late 1990s, GPS recorders have been used by freight carriers to track the current positions of their trucks. However, it is only recently, that analyses post collection of GPS truck data have become more commonplace. This is essentially in recognition of the enormous potential that GPS data can provide for both current and future truck flow analysis. Recent applications of GPS truck data include analyses of vehicle congestion, reliability on road segments, time intervals between cargo deliveries and truck tours [2], [10], [12], [15], [18], [22], and [32] measured the travel time reliability using different methodologies based on freight data collection using GPS. Reference [10] applied the concept of entropy to mine large volumes of GPS data in order to determine the purpose of stopped truck events. GPS data has the potential to produce high prediction accuracy [8]. However, the prediction accuracy will vary based on the spatial coverage, sample size, and data quality [13]. Although GPS data come from a large sample of trucks, the data do not necessarily represent all trucks from any region [16]. While GPS devices provide a convenient method of data collection, there are still some problems when applying them as input for truck traffic flow prediction. Due to the abnormal noise signals, the sampled GPS data does not generally include all truck trajectories, which means that truck traffic flow processed by sampled GPS data is less than the actual truck traffic flow in a roadway. At present, few researches verify and expand the sampled data quality, which is obtained by the equipment directly, in order to reduce inaccuracies. Before applying GPS data to predict the future truck traffic flow on road segments, it is crucial to understand the extent to which the data accurately represents the actual truck traffic flow. Moreover, the truck traffic data obtained by sampled GPS data should be corrected. Since the truck traffic data obtained by sampled GPS data is less than the actual truck traffic flow, sample expansion should be emphasized to improve the quality of the data to represent the actual truck traffic flow as closely as possible.
At present, although there are ample researches on traffic flow forecasting, most of the existing efforts have focused on passenger car traffic on freeways. In comparison, little has been done to model traffic flows of trucks. Typically, truck traffic flow characteristics are different from those of passenger cars. The passenger car traffic flow has obvious characteristics of morning and evening peaks, and the volume during the peak hour is greater than night flow. In China, trucks are prohibited from passing internal area during the daytime in most cities. For example, the Beijing Municipal Transportation Bureau stipulates that trucks cannot enter the roads within the Fifth Ring Road between 6 am and 11 pm. As a result, in most urban areas, truck traffic flow at night is often significantly larger than during the daytime.. In this paper, the peak and stable periods of truck traffic flows are studied with the aim of predicting such flows.
In the prediction of truck traffic flow, this paper will refer to the passenger car traffic flow prediction method, that has achieved productive research results in the past 50 years, of which there are two types: model-driven and data-driven [30]. The model-driven method relies on prior knowledge for system modeling, so it is challenging to obtain a precise traffic flow model. New data-driven research methods are emerging, mainly including parametric and non-parametric models. The general parametric model includes ARIMA and subset ARIMA [14], [24], [26], and [29]. Other studies [4], [9], [20], [23], and [38] have used the Kalman filtering model to predict traffic flow. The prediction effect of the parametric model on nonlinear traffic flow data with strong randomness is not good. However, non-parametric models can learn historical information rules to obtain high prediction accuracies. The general non-parametric models include K-Nearest Neighbor (KNN), Support Vector Regression, Back Propagation Neural Network, and Fuzzy Neural Networks [5], [11], [17], [25], [27], and [28]. Moreover, the field of artificial intelligence and deep learning has developed rapidly with the improvement of computer performance in recent years. Deep neural networks can capture the dynamic characteristics of traffic flow data and have achieved excellent results. Conventional deep learning methods include Deep Belief Network, Recurrent Neural Network (RNN), and Convolutional Neural Networks [6], [17], and [31]. With ongoing research and development, the traditional deep learning model has improved. As a variant of RNN, LSTM and GRU can effectively use the self cycling mechanism to learn the time dependence well [21]. The method mentioned above has a good effect on the prediction of passenger car traffic flow, but it has not been applied to the prediction of truck traffic flow. Especially the latest research found that the LSTM has a high prediction effect in the prediction of passenger car traffic flow [30] and [33]. In addition, it is worth noting that a reasonable prediction effect of LSTM depends on a large amount of training data and parameters, and the model's computing ability is limited by computer memory and bandwidth. GRU was proposed to solve the deficiencies of LSTM, and its parameters are relatively small and is easier to obtain a converged solution. Reference [7] applied the GRU method to predict passenger car traffic flow for the first time, which performed better than the ARIMA model. Reference [36] then applied GRU to predict urban traffic flow considering weather conditions. Scholars have demonstrated that LSTM and GRU have advantages in the accuracy and stability of the passenger car traffic flow prediction algorithm. GRU has the advantages of fewer parameters and easier convergence, whilst LSTM has better performance when the data set is large. GRU and LSTM are indistinguishable in many tasks. In this paper, both LSTM and GRU methods were applied in the prediction of truck traffic flow, the prediction effects of which were subsequently evaluated. To the author's knowledge, this is the first time that LSTM and GRU methods have been used in the prediction of truck traffic flow.
Currently, the main challenge for prediction accuracy is a lack of sufficient data and a suitable model for truck traffic flow. In this paper, the method proposed has several merits. Firstly, the truck traffic flow obtained by sampled GPS data has the advantages of high reliability, and high data sampling rate, which can ensure the prediction effect. Secondly, the expansion method of sampled GPS traffic flow is studied to make it represent the actual traffic flow as accurately as possible. This is because the LSTM and GRU neural networks are adopted to predict the truck traffic flow based on the expanded GPS data. Thirdly, the impact of the processing order regarding expansion first then prediction or vice-versa on prediction performance are investigated by comparing the prediction results to the survey data. These methods can, therefore, serve as a reference for the transportation engineers who are seeking for a method to predict traffic flow, especially partial traffic flow, such as truck traffic flow, using sampled GPS data.

III. METHODOLOGIES
The proposed method comprises two main phases, one is the data expansion of sampled GPS truck traffic flow, and the other is the prediction of the expanded traffic flow data. The flow chart of the prediction process of the proposed method is shown in Fig. 1.

A. DATA EXPANSION
The sampled GPS data are periodically sent back to the data center via GPS-enabled devices onboard trucks. For each truck, the dataset includes the truck ID, longitude, latitude, timestamp, current driving speed, direction, and operation status. However, before the truck traffic flow prediction is carried out, it is necessary to convert the sampled GPS data into a sampled truck traffic flow. Firstly, the city roadway network is divided into numbered segments according to the road grade and length. Then, the map-matching sampled GPS data is realized on the road segments. Finally, the sampled GPS data is counted on each road segment at hourly intervals to form a sampled truck traffic flow.
However, there are limitations to the accuracy of a resultant truck traffic flow for the following reasons. Firstly, the sampled GPS data usually contains abnormal noisy signals, caused by random errors or systematic errors, such as software bugs, upgrades, transmission errors, and malfunctioning devices. Secondly,, there is no guarantee that all trucks are equipped with GPS devices. Thirdly, there are GPS data location and map matching problems. Therefore, a sampled truck traffic flow obtained from the sampled GPS data is essentially an underestimate of the corresponding actual truck traffic flow. For further analysis and application, it is, therefore, necessary to preprocess the truck traffic flow obtained by sampled GPS data. First of all, abnormalities in the truck traffic flow can be identified and corrected by applying traffic thresholds which can be set according to the mixture ratio of trucks and passenger cars. Trucks and passenger cars are routinely driven on the same road segment at the same time, therefore, at any moment there is a certain mixture ratio of trucks and passenger cars. If the value obtained by dividing the sampled truck flow by the mixed ratio is greater than the road segment capacity, the sampled truck traffic flow is implied to be an abnormal value and should be regulated by a threshold. The sampled truck flow threshold can be determined by multiplying the road segment capacity by the mixture ratio. Then, for road segments with incomplete data, the missing truck traffic flow data can be estimated and applied using the average value of the sampled truck traffic flow from upstream and downstream segments. Likewise, for any one period, missing truck traffic data can be estimated and applied using the average value of the truck traffic flow in the previous period and the next period. Finally, in order to resemble more closely to the actual traffic flow, data expansion of the sample truck traffic flow is required, which is done according to the truck traffic flow size and roadway grade, where a piece-wise constant coefficient method is proposed, which includes the following steps: Step 1: collating the sampled truck traffic flows, (S 0 , S 1 , . . . , S h , . . . , S 23 ), for all segments comprising the road grade for each hour in one day and finding the maximum S h .
Step 2: sorting the sampled truck traffic flows of all segments in descending order based on the ''hour_h'' sequence. The h of ''hour_h'' is determined by the h of the period of maximum S h .
Step 3: estimating the distribution function for the sorted sampled truck traffic flows. This function is of the form of an exponential distribution, as shown in Eq. (1) where, y represents the sampled truck traffic flow, v represents the sort number of the road segment after descending order, and k, a, l represent the model parameters. According to the China Technical Standard of Highway Engineering (JTG B01-2014), expressways are classified into five grades: Highway, First-class Highway, Second-class Highway, Third-class Highway, and Forth-class Highway. The distribution function of the sorting sampled truck traffic flow under each expressway grade is shown in Fig. 2. From Fig. 2, it can be seen that the forming function of the exponential distribution fit the sorted sampled truck traffic flow well. The goodness of fit (R 2 ) is used to evaluate the fitting performance of the exponential distribution function. The closer the goodness of fit is to 1, the better the fitting performance of the exponential function. The R 2 of the fitting exponential function of the five road grades is 0.9715, 0.9797, 0.9800, 0.8956, 0.9081, respectively, which means that the exponential distribution performs well to in fitting the sorted sampled truck traffic flow.
Step 4: dividing the sorted sampled truck traffic flow into five intervals, defined as [i, j], where i, j are the upper and lower bounds of the interval, and i, j refers to the sort numbers Step 5: dividing the sampled truck traffic flow data by the expansion coefficient m i,j .
After the data expansion, the errors of sampled truck traffic flow are essentially minimized and the resultant flow is much closer to the actual truck traffic flow.

B. PREDICTION
In this phase the future truck traffic flow is predicted using the expanded data and a deep neural network approach based on the LSTM and GRU methods. As highlighted in the literature review, LSTM and GRU are variants of RNN which is specialized for processing time series problems, such as language modeling and speech recognition, and exhibits a super capability in the modeling of nonlinear time sequences. However, with time tags increasing, gradients might disappear when RNN unfolds into a deep feedforward neural network. The disappearance of the gradient means that RNN is unable to capture long-term dependencies of the input sequence which represents a disadvantage in modelling truck traffic flows but LSTM and GRU, with their specific structural improvements to RNN, were essentially formed to overcome this disadvantage and for this reason were adopted in the truck traffic flow predictions in this paper.

1) TRUCK TRAFFIC FLOW PREDICTION WITH LSTM
As already mentioned, the LSTM model effectively solves the gradient disappearance problem encountered during training thus avoiding the long-term dependency problem essentially through improvements to the hidden layer. The existence of the hidden layer ensures that the LSTM can deal with the long-term time series dependence problems that are a feature in truck traffic flows. The LSTM model can well remember the long-term historical distribution characteristics of truck traffic flows and leads to a better prediction effect overall. Specifically, LSTM adds the memory block (including the forget gate, the input gate, and the output  gate), which can provide further controls in the truck traffic flow prediction process, by deciding which historical truck traffic flow should be retained and which should be deleted. The memory block of LSTM is recorded and self-connected recurrently, as shown in Fig. 3.
The input truck traffic flow time series is denoted by X = (x 1 , x 2 , . . . , x t ), the output truck traffic flow time series by Y = (y 1 , y 2 , . . . , y t ), and the hidden state of memory cells are denoted by H = (h 1 , h 2 , . . . , h t ), and T is the prediction period. For prediction purposes, X can be considered as the historical truck traffic flow data, and Y is the predicted truck traffic flow. The goal of using LSTM, therefore, is to predict truck traffic flow in the next time step based on prior sequence information. The input gate i t , the forget gate f t , and the output gate o t of the hidden memory cell can be calculated using Eqs. (3a), (3b), and (3c), respectively.
In these equations, weight matrices are denoted by W and bias vectors are donated by b. Specifically, W and b are utilized to establish a connection between the input layer, memory block, and the output layer. σ () denotes the standard logistics sigmoid function. h() is the extends of stand sigmoid function with range changing to and [−1, 1]. c is the state of the memory block. Training errors are minimized and local minimal points are avoided through application of the Adam optimizer, which is an improvement to the stochastic gradient descent optimizer with an adaptive rate. LSTM memory blocks can capture the sophisticated time distribution features within long term truck traffic flows, representing a significant improvement compared with the traditional RNN.

2) TRUCK TRAFFIC FLOW PREDICTION WITH GRU
A gated recurrent unit can adaptively capture truck traffic flow dependencies on different time sequences. Similar to LSTM units, the gating units in GRU are used to capture time dependency features of truck traffic flows. A detailed formulation of GRU can be found in [3] but for the purposes of this study, the salient features of GRU are such, that unlike LSTM, GRU does not have separate memory cells, rather a typical GRU cell contains the reset gate and the update gate, therefore comprising fewer parameters which implies a more straightforward calculation. The structure of the GRU unit is shown in Fig. 4.
Firstly, the reset gate r j and the update gate z j are computed using Eqs. (4a) and (4b), respectively: where, the definition of σ , x, h are the same as in LSTM, and U is the weight matrix, and j stands for the j-th element of a vector. The actual activation of the hidden unit h j is calculated using Eq. (5).
These units that capture shorter-term time series will tend to have the reset gate. The update gate can determine how many time series are transferred from the previous hidden state to the current. The cells that capture longer-term dependencies will have the update gate in the activated state. These cells are similar to the memory block in the LSTM. To verify the accuracy of truck traffic flow prediction, the results are compared with the actual truck traffic flow in the traffic survey, and then the parameters can continue to be adjusted to achieve better accuracy. Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), Explained Variance Score (EVS), and Accuracy are used to evaluate the difference between the sampled truck traffic flow y o and predicted truck traffic flow y p . The accuracy is obtained by subtracting the Absolute Percentage Error from 1. EVS is used to explain the variance of the model. The larger the EVS value, the better the model effect. The value of EVS ranges from 0 to 1. EVS is calculated in Eq. (6). Var calculates the correlation coefficient.
It is worth noting that the sequence of expansion and prediction might affect prediction accuracy. Based on previousexpansion, post-prediction, the expanding and forecasting sequence of the model is reversed to obtain the truck traffic flow result of previous-prediction, post-expansion. Comparing the results of the two sequences with the traffic survey data, the order sequence of expansion and prediction with high accuracy can be obtained.

IV. DATA
The sampled truck GPS data used in this paper were collected on the 28 th November and the 1 st December 2018 from a roadway network associated with Zhengzhou city in China. Each piece of GPS data contains the following information: Date, Time, license plate number, Longitude, Latitude, Speed, Azimuth, and Receive Time. Trucks equipped with GPS devices account for 80% of all vehicles in operation, according to Transport Commission. Also, the gis file of the road network was provided by the local Traffic Commission of Authority. According to the standard of JTG B01-2014, roadways are divided into ten levels, namely, Highway, First-class Highway, Second-class Highway, Third-class Highway, and Forth-class Highway; Urban Expressway, Arterial road, Secondary Arterial road, Local Road, and Other. The roadway network is divided into 82,970 segments and each given a unique numbered ID. Each road segment is set directional attributes for upstream, downstream, and cross-section. The grade of Urban Expressway, Arterial road, Secondary Arterial road, and their segment ID numbers are selected to show their distribution in the roadway network, as shown in Figure 5.
The sample GPS trajectory data of a truck is matched to the road segment using the Arcgis software, and the truck direction is set to be the same as the road segment. The sampled GPS trajectory data of each segment were then aggregated to form the sampled truck traffic flow. Compared to passenger car traffic flow, the sampled truck traffic flow is less in a short interval, especially where the road grade is of the category Local Road. The statistics show that the proportion of zero traffic volume in a 5-minute interval is more than 50%. And it is difficult to expand the zero sampled truck traffic flow by the proposed piece-wise constant coefficient method. While the sampled truck traffic flow at one-hour interval can basically ensure that each road segment has non-zero truck flow. It is helpful to expand the sampled truck traffic flow. Therefore, the time interval of sampled truck flow prediction is considered as one hour. At the same time, in order to compare the differences between the sampled truck traffic flow and the actual truck traffic flow, and then to provide a reference for the quality repair of the sampled data, traffic surveys were carried out on 46 roadway segments to obtain the actual truck traffic flow. These traffic surveys were carried out manually and involved counting and recording relevant information as trucks pass through each road segment. The traffic survey data include Survey Date (2018-12-01), Time slot (1 h), Survey station number (S233L125410185), Survey mileage (km), Direction of travel (Upstream, Downstream, Crosssection), and Actual truck traffic flow. Because the traffic survey data is the closest to the actual situation, we assume that the truck traffic flow determined from the traffic surveys is the actual truck traffic flow.
For different road grades, A piece-wise constant coefficient method is used to expand the sampled truck traffic flow. Compared with the real truck traffic flow, it is found that the proportion of non-sampled trucks on the roadway with greater truck traffic flow is lower, while the proportion of non-sampled trucks on the roadway with less truck traffic flow is higher. In other words, the proportion of non-sampled trucks on the high-grade highway, expressway, and the urban road categories are lower, while the proportion of non-sampled trucks on the low-grade expressway and urban road categories is higher. The truck traffic flow is sorted according to the size, and all roadway segments are divided into five sections based on the sorted number. For the Highway road grade, on the 28 nd November 2018, the coefficients k, a, l of the distribution function are estimated to be 222.92, 0.002, and 0, respectively. For each sorted number section, the expansion coefficient is calculated as 0.553, 0.249, 0.112, 0.050, and 0.035, respectively. Since installed GPS recorders in trucks account for 80% of the total operation, each parameter was divided by 0.8 to obtain adjusted expansion parameters. The detailed expansion coefficients of sampled truck traffic flow for the Highway road grade are shown in Table 1.
For the training, as a deep learning algorithm, there are several important parameters that affect the performance of the proposed model, including Batch size, Hidden layer number, Hidden unit size, Epochs, and Time steps. In the study, the learning rate is set to 0.001, the early stopping is set to avoid overfitting, the batch size is set to 20, and the epoch is 50 as determined from multiple iterations of training to find the optimal parameters.
(1) Training Environment. Tensorflow and Keras were used as the deep learning packages and Python 3.6 provided a general-purpose programming language. These were hosted on a desktop computer comprising an Intel Xeon (R) E5-2640 2.5 GHz CPU and 32 GB memory. (2) Hidden units. Different hidden units can affect prediction accuracy, and in order to choose the best value, it was necessary to search and compare the different units. Firstly, we tested the hidden units from [5,10,15,30,50, 100] with LSTM and GRU. The findings indicate that the best results occur for a unit of 5, no matter whether LSTM or GRU is used. We then continued testing the hidden units from [1,2,3,4,5] and found the respective EVS obtained by LSTM or GRU to be 0.798, 0.795, 0.799, 0.809, 0.799, suggesting that  [4,8,12,16,20,24] is shown in Fig. 6. The units of these time steps are hours Based on the results of EVS, MAPE, MAE, and RMSE, it can be seen that the performances of LSTM and GRU as well as the prediction results are better when the time step is 4. As the time step becomes higher, the prediction effect will gradually deteriorate. When the time step is 4, the EVS of LSTM and GRU are both 0.8. When the time step is 8, the EVS of LSTM remains unchanged, and the GRU starts to decrease. Subsequently, the prediction effect of LSTM decreased faster, while GRU's decline was more gradual. When the time step is 4, 8, 20, 24, the associated MAPE, MAE, and RMSE values indicate that LSTM performs better than GRU. However, when the time step is 16, the MAPE, MAE and RMSE values indicate that the performance of LSTM is the same as that of GRU. Moreover, when the time step is 12, the MAPE, MAE and RMSE values indicate that LSTM does not perform as well as GRU. In summary, when the time step is set to 4 for both LSTM and GRU, the prediction results are the best.

V. MODELING RESULTS
For the whole roadway network, with the above parameters, both LSTM and GRU were trained to predict the truck traffic flow and their performance results were compared with SVR and ARIMA to verify effectiveness. For clarity, the prediction evaluation results that are listed in Table 2 were obtained using a testing data set rather than the training data set.
As can be seen in Table 2, the evaluation of EVS, MAE, MAPE, RMSE was 0.941, 1.459, 19.2%, and 3.823, respectively, using LSTM. Compared with the SVR model, To analyze the prediction effects in more detail, four different road segments (IDs 3810369, 3423864, 3615501, and 13523705) with relatively large traffic volumes were selected at random, and after data expansion in each case, LSTM and GRU were applied on a one-hour time interval and a comparison of their prediction results are shown in Fig. 7.
In Fig. 7, it can be seen that the time distribution of expanded truck traffic flow presents a single peak pattern, which is different from the traditional double-peak pattern associated with passenger cars. The peak period is between hour_17 and hour_19. The stable period ranges from hour_6 and hour_8. The detailed prediction results, obtained using a testing data set rather than the training data set, for the four selected road segments by LSTM and GRU are listed in Table 3. Note that the prediction results are after data expansion. Table 3 shows that during the peak period, the average prediction accuracy for the four selected road segments obtained by LSTM and GRU is 89.70% and 88.58%, respectively. The peak period prediction accuracy of GRU is 1.51% higher than that of LSTM, which is different from the result for the total period of the day. During the stable period, the average prediction accuracy for the four road segments obtained by LSTM is 1.12% higher than that of GRU, which is different from the peak period performance. The respective average prediction accuracy during the peak period are 2.71% and 5.34% lower than in the stable period for LSTM and GRU. In the case of LSTM, the ''hour'' with the highest prediction accuracy associated with each of the four road segments is hour_13, hour_13, hour_13, and hour_21, with the accuracies of 99.69%, 99.26%, 99.40%, and 99.75%, respectively. Whereas with GRU, the highest prediction accuracy ''hours'' are hour_7, hour_23, hour_21, and hour_21, with accuracies of 99.49%, 99.27%, 98.64%, and 99.78%, respectively. Furthermore, it can be seen from Table 3 that the prediction results for each road segment is different. The prediction accuracy for the road segment, ID 3810369, is the highest, and the consequence of LSTM is 95.08%, which is higher than the 94.08% obtained with GRU. Besides, the respective average MAPE and accuracy values for LSTM are 0.078 and 92.24%, which is better than that for GRU at 0.086 and 91.36%. In summary, both LSTM and GRU have advantages in performance during peak and stable periods. However, for the average prediction accuracy of the total period, LSTM is better than GRU.
The prediction results are compared with the traffic survey data to verify the prediction effect. In order to analyze whether the order of expansion and prediction effects the final results, processing and comparisons were carried out in two parts, namely, previous-expansion, post-prediction and previous-prediction, post-expansion. The sampled GPS truck traffic flow data, traffic survey data, expanded truck traffic flow data, and prediction data are compared. For road segment ID 3803632, the results of the order processing for previous-prediction, post-expansion, and previousexpansion, post-prediction in both LSTM and GRU are shown in Fig. 8.
In Fig. 8, sampled GPS truck traffic flow data are referred to as S_GPS; Traffic survey data are referred as TSD; Prediction data are referred to as PD; Expanded data after prediction are referred to as PD+ED; Whilst Expanded data are referred ED. It can be seen that the results of the previousprediction, post-expansion processing order is better than that of previous-expansion, post-prediction using LSTM and GRU. At the hour_23, the value of ED+PD is higher than the traffic survey data compared with PD+ED. At hour_10, PD+ED is closer to the traffic survey data than ED+PD. However, at hour_7, ED+PD is closer to the traffic survey data than PD+ED. In general, therefore, it is better to perform predicting before expanding. The accuracies of ED+PD and PD+ED are shown in Fig. 9. Furthermore, the accuracy of PD + ED is 8.26% higher than that of ED+PD using LSTM, and the accuracy of PD+ED is 4.27% higher than that of ED+PD using GRU. In summary, both LSTM and GRU show that the prediction effect of the previous-prediction, post-expansion is better than previous-expansion, post-prediction processing order.
It is worth noting that Table 3 shows that the average accuracy of LSTM and GRU for the four road segment IDs is 92.24% and 91.36%, respectively. While Fig. 9 shows that the average accuracy of ED+PD and PD+ED predicted by LSTM and GRU is only 82.32% and 80.97%, respectively. Table 3 shows that under the assumption that the sampled 208166 VOLUME 8, 2020 GPS truck traffic flow data is the actual truck traffic flow, the LSTM and GRU have high accuracy in predicting the truck traffic flow. However, there is a large gap between sampled GPS truck traffic flow data and traffic survey data (shown in Fig. 9). Compared with traffic survey data, the MAPE of the sampled GPS truck traffic flow data is 0.78, and the sampled GPS truck traffic flow accuracy is only 21.61%. Compared with the traffic survey data, the low quality of the sampled GPS truck traffic flow data leads to a low prediction effect. The proposed methods of PD+ED and ED+PD by LSTM can improve the sampled GPS truck traffic flow accuracy by 64.84% and 56.58%, respectively. In general, therefore, it can be seen that the proposed method can effectively improve the prediction accuracy of sampled GPS truck traffic flow data.

VI. CONCLUSION
In this paper, a novel method is proposed for the prediction of truck traffic flow using the sampled GPS data from trucks. The method combines two phases, namely a data expansion phase and the actual prediction phase. Errors and omissions in the sampled GPS data necessitate the data expansion phase, in which a piece-wise constant coefficient method is used to expand the sampled truck traffic flow based on roadway levels and truck traffic flow. The LSTM and GRU neural networks were developed to predict truck traffic flow in the prediction phase. In order to analyze whether the order of expansion and prediction affects the final results, two strategies were investigated -previous-expansion, post-prediction and previous-prediction, post-expansion have been investigated.
The finding shows that both LSTM and GRU in general have excellent performance in predicting truck traffic flows. In particular, during peak periods, the average prediction accuracy of GRU is higher than LSTM. Whilst during off-peak stable periods, the prediction performance of LSTM is better than GRU. The reason for this result is that, during peak periods, the truck traffic flow fluctuates greatly with less regular trends compared with stable periods, making it more difficult to capture any patterns. However, for the average prediction accuracy throughout both peak and off-peak periods, LSTM is better than GRU with an improved accuracy of 4.1%.
Furthermore, the final results of the previous-expansion, post-prediction and previous-prediction, post-expansion processing order were compared actual truck flow from the survey data and the accuracy calculated. The results showed that the prediction accuracy of the previous-prediction, post-expansion processing order is 8.26% greater than that of previous-expansion, post-prediction using LSTM. The accuracy of the results indicates that for the sampled GPS truck traffic flow data, the prediction performance can be enhanced by using LSTM to predict firstly, then using the piece-wise constant coefficient method to expand. The proposed method can, therefore, provide significant insight into predicting truck traffic flows using sampled GPS data even if the data in is both incomplete and contains errors. To improve the prediction accuracy, in the future, a spatial correlation on truck traffic flow should be further investigated and studied. Moreover, to improve the quality of data, more accurate GPS data map matching problems need to be addressed. In the meantime, it is anticipated that this study can be used to inform future road traffic management developments regarding the minimization of congestion and consequential road accidents associated with truck traffic.

DATA AVAILABILITY
Some data and code used during the study are available in a repository in accordance with funder data retention policies. (https://github.com/uubest/-LSTM-and-GRU.git)