# A Vehicle Velocity Prediction Method with Kinematic Segment Recognition
## 3 Methodology
### Prediction Model Based on K-Means-QPSO-LSTM  
In recent years, a LSTM neural network prediction model based on QPSO has been widely used in various disciplines. In terms of the PM2.5 concentration prediction, the prediction model of QPSO combined with LSTM can accurately predict the PM2.5 concentration after training [37]. In terms of the usage prediction of shared bicycles, the prediction model of QPSO combined with LSTM could predict the number of bicycles needed per hour in the future day [38]. The forecast model of QPSO combined with LSTM could predict the freight volume in the future time (hour, day, or month), [39] and each of the above models showed good predictive power when verified. Therefore, the prediction accuracy can be significantly improved after the optimization of LSTM hyperparameters. When a LSTM neural network is used for model training, the number of hyperparameter hidden layer neurons \(L_{\text{a}}\) and \(L_{\text{b}}\), iterations \(K\), and learning  
Figure 4: LSTM cell diagram. rate \(I_{\text{r}}\) need to be evaluated. The selection of hyperparameter values has a great impact on the performance and training effect of the LSTM neural network, and the appropriate selection can improve the accuracy of the results. In order to avoid determining appropriate hyperparameters through a large number of experiments, this paper used the QPSO algorithm to optimize the \(L\), \(K\), and \(I_{\text{r}}\) of the LSTM neural network and constructed a QPSO-LSTM prediction model. The process is shown in Figure 5, where \(L_{\text{a1}}\), \(L_{\text{b1}}\) represent the number of hyperparameter hidden layer neurons of the first sub-LSTM model, \(K_{\text{1}}\) represents the number of iterations of the first sub-LSTM model, and \(I_{\text{r1}}\) represents the number of iterations of the first sub-LSTM model; \(L_{\text{a2}}\), \(L_{\text{b2}}\) represent the number of hyperparameter hidden layer neurons of the second sub-LSTM model, \(K_{\text{2}}\) represents the number of iterations of the second sub-LSTM model, and \(I_{\text{r2}}\) represents the number of iterations of the second sub-LSTM model; \(L_{\text{a3}}\), \(L_{\text{b3}}\) represent the number of hyperparameter hidden layer neurons of the third sub-LSTM model, \(K_{\text{3}}\) represents the number of iterations of the third sub-LSTM model, and \(I_{\text{r3}}\) represents the number of iterations of the third sub-LSTM model. The overall procedure for the algorithm design and optimization is as follows:  
Figure 5: Structure of the vehicle velocity prediction model. Data processing. The data processing steps have been detailed in Section 2 and will not be elaborated in this section. Three types of driving condition datasets were obtained through data processing. For the first type of dataset, because there was a lot of data, the first 90% of the dataset was used as the training set, and the last 10% was used as the test set. For the second and third types of datasets, the first 70% of the driving condition data was used as the training set, and the last 30% was used as the test set. The training set was used to train the sub-LSTM model and optimize its parameters, while the test set was used to evaluate the model's performance. 2. Initialize the particle swarm parameters including the particle swarm size, particle dimension, number of iterations, particle position (hidden layer neuron number (\(L_{\text{ai}}\), \(L_{\text{bi}}\)), training number (\(K_{i}\)), and learning rate (\(I_{\text{ri}}\)) (\(i=1,\,2,\,3\)). 3. The velocity and position of each particle are updated, and the fitness value of each particle is calculated. The fitness value of each particle is a function of the mean square error (MSE) of the training set. 4. Update the individual and population history optimal fitness value and location of each particle as well as the other parameters. 5. The end condition is satisfied by calculating the maximum number of iterations or the minimum difference value of the fitness value between two iterations.