A taxi passenger flow prediction method

By using spatial multi-headed attention algorithm and multi-layer perceptron extraction features in the traffic spatiotemporal data prediction model, the difficulties of the existing model in extracting distant spatial features are solved, and high-precision taxi passenger flow prediction is achieved.

CN114444792BActive Publication Date: 2025-04-18SUN YAT SEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210070034.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-21
Publication Date
2025-04-18
Estimated Expiration
2042-01-21

AI Technical Summary

Technical Problem

The existing traffic spatiotemporal data prediction model has difficulties in extracting distant spatial features, resulting in large prediction errors and low accuracy.

Method used

The spatial multi-head attention algorithm is used to extract the training data spatial features, and the time feature extraction is performed in combination with the multi-layer perceptron to form a traffic prediction model based on the multi-layer perceptron.

Benefits of technology

Effectively extract the spatial and temporal characteristics of taxi passenger flow, improve the prediction accuracy, and realize high-precision prediction of taxi passenger flow.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114444792B_ABST
    Figure CN114444792B_ABST
Patent Text Reader

Abstract

The present invention provides a method for predicting passenger flow of taxis. First, the passenger flow and the passenger flow are spliced ​​into the same dimension, and spatial nodes are serialized. The original data is obtained after the data is normalized, and the original data is divided into training data and test data; secondly, a spatial multi-head attention algorithm is used to extract spatial attention features of the training data to obtain global spatial features; then the global spatial features and the training data are flattened into the same dimension, and a first multi-layer perceptron is used to extract time features to obtain global time features; then the global time features and the training data are input into a second multi-layer perceptron for iterative training to obtain a trained flow prediction model, and then the test data is input into the prediction model to obtain a prediction result. The present invention can effectively extract global spatial features and global time features, and can achieve high-precision prediction of taxi passenger flow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of traffic spatiotemporal data prediction, and in particular to a taxi passenger flow prediction method. Background Art

[0002] Traffic spatiotemporal data prediction is an important issue in the field of intelligent transportation. Traffic spatiotemporal data is an important indicator of traffic status. Short-term traffic spatiotemporal data prediction is an important part of traffic management and guidance. By predicting the taxi passenger flow in various areas of the city in advance, traffic guidance can be effectively carried out, and taxis in areas with abundant resources can be deployed to areas with insufficient resources, reducing passenger waiting time and improving urban traffic operation efficiency.

[0003] Due to the complexity of traffic spatiotemporal data prediction, there are currently many prediction models, and graph neural networks are mostly used to extract spatial features. However, as a priori knowledge of spatial structure, graph neural networks can only extract adjacent spatial features, and it is difficult to extract distant spatial features. Increasing the number of graph neural network layers can easily lead to over-smoothing problems, resulting in large prediction errors in the prediction model and low prediction accuracy. Summary of the invention

[0004] The present invention provides a method for predicting taxi passenger flow, which aims to solve the problem of difficulty in effectively extracting data spatial feature correlation due to the fixed prior knowledge of graph neural networks in traffic spatiotemporal data prediction, so as to improve the prediction accuracy and obtain better prediction results.

[0005] The technical solution of the present invention is as follows:

[0006] A taxi passenger flow prediction method comprises the following steps:

[0007] S1: The passenger boarding and alighting flows are abstracted into spatial nodes and concatenated into the same dimension. Then all spatial nodes are serialized and normalized to obtain the original data. The original data is then divided into training data and test data.

[0008] S2: Use the spatial multi-head attention algorithm to extract spatial attention features from the training data and obtain global spatial features;

[0009] S3: Flatten the global spatial features and training data into the same dimension, use the first multi-layer perceptron to extract temporal features, and obtain global temporal features;

[0010] S4: inputting the global time features and the training data into the second multi-layer perceptron for iterative training to obtain a trained traffic prediction model based on the second multi-layer perceptron;

[0011] S5: Input the test data into the traffic prediction model for prediction, and obtain the traffic prediction results of taxi passengers getting on and off the taxi.

[0012] Furthermore, in step S1, the specific process of splicing the passenger boarding flow and the passenger alighting flow into the same dimension and abstracting them into spatial nodes is as follows:

[0013] The taxi pick-up and drop-off flow in a city is obtained and divided into several grids. The pick-up and drop-off flow of each grid are abstracted into spatial nodes and spliced ​​into the same dimension. That is, the number of spatial nodes is twice the number of divided grids.

[0014] Furthermore, in step S1, all spatial nodes obtain flow data once every 30 minutes, and use the deviation standardization method to normalize the data. The normalization formula is as follows:

[0015]

[0016] In the formula, x s is the processed data, x is the input data, X max is the maximum value of the data, X min is the minimum value of the data.

[0017] Furthermore, in step S1, after obtaining the original data, the first E time interval data in the data are used to predict the future F time interval data, so as to update the original data, and the updated original data is divided into training data and test data according to the proportion.

[0018] Furthermore, the first 60% of the updated original data is divided into training data, and the remaining 40% is divided into testing data.

[0019] Further, in step S2, the process of using the spatial multi-head attention algorithm to extract spatial features from the training data is as follows:

[0020] Using different weight matrices W q , W k , W v Perform h operations on the training data H to obtain spatial attention features of different subspace granularities, and finally merge them into global spatial features;

[0021] Among them, the formula of the spatial multi-head attention algorithm is as follows:

[0022]

[0023] head (i) =Attention(Q (i) ,K (i) ,V (i) )

[0024] MultiHead(H)=Concat(head (1) ,head (2) ,…,head (h) )W0

[0025] in, are the parameter matrices for mapping the i-th subspace data; Q (i) , K (i) 、V (i) Respectively represent the i-th subspace data after mapping; head (i) represents the attention of the i-th subspace; Attention represents the attention mechanism operation; Concat represents the concatenation operation; W0 is a learnable parameter; MultiHead (H) represents the global space feature.

[0026] Further, the specific process of step S3 is as follows:

[0027] The input formats of global spatial features and training data are both: B×N×M, where B is the amount of data input at one time, N is the number of nodes, and M is the number of input time intervals; the global spatial features and training data are flattened to the same dimension and converted into a data format of B×1×(N×M), and then the first multi-layer perceptron is used to extract time features from the last dimension to obtain global time features, and finally the global time features are converted into a data format of B×N×Z, where Z is the number of output time intervals.

[0028] Furthermore, the first multi-layer perceptron in step S3 uses a 6-layer perceptron to extract time features.

[0029] Furthermore, the second multi-layer perceptron in step S4 is iteratively trained using a 2-layer perceptron.

[0030] Further, the error calculation of the flow prediction result obtained in step S5 uses the mean absolute error, root mean square error and Pearson correlation coefficient;

[0031] Mean absolute error:

[0032]

[0033] Root Mean Square Error:

[0034]

[0035] Pearson correlation coefficient:

[0036]

[0037] Where MAE is the mean absolute error, RMSE is the root mean square error, PCC is the Pearson correlation coefficient, N is the number of nodes, and y i is the true value, is the predicted value, is the mean of the true values, is the mean of the predicted values.

[0038] The beneficial effects of the present invention are:

[0039] The method of the present invention first abstracts the passenger flow of taxis into nodes, and performs serialization and normalization processing, and divides them into training data and test data according to the proportion; then uses a spatial multi-head attention mechanism to extract the spatial features of the data to obtain global spatial features; then flattens the obtained data and the training data to the same dimension, and uses a multi-layer perceptron to extract temporal features; finally, uses a trained prediction model based on a multi-layer perceptron to make a final prediction. The present invention uses a spatial attention mechanism to extract global spatial features, and then uses a multi-layer perceptron to extract global temporal features, which can effectively extract the spatiotemporal global features of taxi passenger flow, achieve high-precision prediction, and effectively predict the passenger flow of taxi passengers. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION

[0041] The drawings are only for illustrative purposes and cannot be construed as limiting the present invention. To better illustrate the present embodiment, some parts of the drawings may be omitted, enlarged, or reduced, and do not represent the size of the actual product. For those skilled in the art, it is understandable that some well-known structures and their descriptions may be omitted in the drawings. The positional relationships described in the drawings are only for illustrative purposes and cannot be construed as limiting the present invention.

[0042] Embodiment 1:

[0043] like Figure 1 As shown, a taxi passenger flow prediction method comprises the following steps:

[0044] S1: The passenger boarding and alighting flows are abstracted into spatial nodes and concatenated into the same dimension. Then all spatial nodes are serialized and normalized to obtain the original data. The original data is then divided into training data and test data.

[0045] S2: Use the spatial multi-head attention algorithm to extract spatial attention features from the training data and obtain global spatial features;

[0046] S3: Flatten the global spatial features and training data into the same dimension, use the first multi-layer perceptron to extract temporal features, and obtain global temporal features;

[0047] S4: inputting the global time features and the training data into the second multi-layer perceptron for iterative training to obtain a trained traffic prediction model based on the second multi-layer perceptron;

[0048] S5: Input the test data into the traffic prediction model for prediction, and obtain the traffic prediction results of taxi passengers getting on and off the taxi.

[0049] In this embodiment, the specific process of splicing the passenger boarding flow and the passenger alighting flow into the same dimension and abstracting them into space nodes in step S1 is as follows:

[0050] The taxi pick-up and drop-off flow in a city is obtained and divided into several grids. The pick-up and drop-off flow of each grid are abstracted into spatial nodes and spliced ​​into the same dimension. That is, the number of spatial nodes is twice the number of divided grids.

[0051] In this embodiment, in step S1, all spatial nodes obtain flow data once every 30 minutes, and use the deviation standardization method to normalize the data. The normalization formula is as follows:

[0052]

[0053] In the formula, x s is the processed data, x is the input data, X max is the maximum value of the data, X min is the minimum value of the data.

[0054] In this embodiment, in step S1, after obtaining the original data, the first E time interval data in the data are used to predict the future F time interval data, so as to update the original data, and the updated original data is divided into training data and test data according to the proportion.

[0055] In this embodiment, the first 60% of the updated original data is divided into training data, and the last 40% is divided into testing data.

[0056] In this embodiment, in step S2, the process of using the spatial multi-head attention algorithm to extract spatial features from the training data is as follows:

[0057] Using different weight matrices W q , W k , W v Perform h operations on the training data H to obtain spatial attention features of different subspace granularities, and finally merge them into global spatial features;

[0058] Among them, the formula of the spatial multi-head attention algorithm is as follows:

[0059]

[0060] head (i) =Attention(Q (i) ,K (i) ,V (i) )

[0061] MultiHead(H)=Concat(head (1) ,head (2) ,…,head (h) )W0

[0062] in, are the parameter matrices for mapping the i-th subspace data; Q (i) , K (i) 、V (i) Respectively represent the i-th subspace data after mapping; head (i) represents the attention of the i-th subspace; Attention represents the attention mechanism operation; Concat represents the concatenation operation; W0 is a learnable parameter; MultiHead (H) represents the global space feature.

[0063] In this embodiment, the specific process of step S3 is as follows:

[0064] The input formats of global spatial features and training data are both: B×N×M, where B is the amount of data input at one time, N is the number of nodes, and M is the number of input time intervals; the global spatial features and training data are flattened to the same dimension and converted into a data format of B×1×(N×M), and then the first multi-layer perceptron is used to extract time features from the last dimension to obtain global time features, and finally the global time features are converted into a data format of B×N×Z, where Z is the number of output time intervals.

[0065] In this embodiment, the first multi-layer perceptron in step S3 uses a 6-layer perceptron to extract time features.

[0066] In this embodiment, the second multi-layer perceptron in step S4 is iteratively trained using a 2-layer perceptron.

[0067] In this embodiment, the error calculation of the flow prediction result obtained in step S5 uses mean absolute error, root mean square error and Pearson correlation coefficient;

[0068] Mean absolute error:

[0069]

[0070] Root Mean Square Error:

[0071]

[0072] Pearson correlation coefficient:

[0073]

[0074] Where MAE is the mean absolute error, RMSE is the root mean square error, PCC is the Pearson correlation coefficient, N is the number of nodes, and y i is the true value, is the predicted value, is the mean of the true values, is the mean of the predicted values.

[0075] Through the error calculation of the above formula, the output prediction results can be made closer to the true value, further reducing the prediction error of the prediction model and outputting more accurate prediction results.

[0076] The method of the present invention first abstracts the passenger flow of taxis into nodes, and performs serialization and normalization processing, and divides them into training data and test data according to the proportion; then uses a spatial multi-head attention mechanism to extract the spatial features of the data to obtain global spatial features; then flattens the obtained data and the training data to the same dimension, and uses a multi-layer perceptron to extract temporal features; finally, uses a trained prediction model based on a multi-layer perceptron to make a final prediction. The present invention uses a spatial attention mechanism to extract global spatial features, and then uses a multi-layer perceptron to extract global temporal features, which can effectively extract the spatiotemporal global features of taxi passenger flow, achieve high-precision prediction, and effectively predict the passenger flow of taxi passengers.

[0077] Embodiment 2:

[0078] In this embodiment, each step of the taxi passenger flow prediction method in the above-mentioned embodiment 1 can also be integrated into different modules and implemented through the system to design a taxi passenger flow prediction system.

[0079] The system comprises a data processing module, a spatial feature extraction module, a temporal feature extraction module, and an output module which are sequentially connected in communication;

[0080] The data processing module is used to abstract the passenger boarding and alighting flows into spatial nodes and splice them into the same dimension, then serialize all spatial nodes, perform data normalization to obtain the original data, and then divide the original data into training data and test data;

[0081] The spatial feature extraction module is used to extract spatial attention features from training data using a spatial multi-head attention algorithm to obtain global spatial features;

[0082] A temporal feature extraction module is used to flatten the global spatial features and the training data into the same dimension, and use the first multi-layer perceptron to extract the temporal features to obtain the global temporal features;

[0083] The output module is used to input the global time features and training data into the second multi-layer perceptron for iterative training to obtain a trained traffic prediction model based on the second multi-layer perceptron. Finally, the test data is input into the traffic prediction model for prediction, and the traffic prediction results of taxi passengers getting on and off are output.

[0084] In this embodiment, the above modules may be integrated on one processor for implementation.

[0085] Embodiment 3:

[0086] The platform for this example is: the processor is Intel i7-8700, the memory is 32.0GB; the graphics card is GTX3070; the system is Windows10 (64-bit); the program language version is Python3.6, and the deep learning algorithm is implemented in the Pytorch learning library. A taxi passenger flow prediction method includes the following steps:

[0087] Step S1, the data of this embodiment comes from the taxi pick-up and drop-off flow in a certain area of ​​New York City. The area is divided into 266 grids, and the pick-up nodes and drop-off nodes are abstracted and spliced ​​into the same dimension to form 532 spatial nodes. All spatial nodes are serialized, and the flow acquisition time interval of all nodes is 30 minutes. The deviation normalization method is used to normalize and obtain the original data;

[0088] The normalization method is as follows:

[0089]

[0090] Among them, x s is the processed data, x is the input data, X max is the maximum value of the data, X min is the minimum value of the data;

[0091] After obtaining the original data, the past E = 12 time interval data in the data set is used to predict the future F = 12 time interval data, that is, the past 6 hours of data are used to predict the future 6 hours of data, so as to update the original data, and the updated original data is divided according to the proportion, the first 60% is divided into training data, and the last 40% is divided into test data;

[0092] Step S2: Using the spatial multi-head attention algorithm to extract spatial features of the training data;

[0093] At this time, the amount of data fed at one time is 64, and the format of the fed data is B×N×M, that is, 64×532×12. The number of multi-heads used in this embodiment is 3, that is, the last dimension is divided into 3 parts, and the training data is operated 3 times. The format of each subspace is 64×532×4, and the time granularity of the subspace is 4, that is, 2 hours. The correlation of the spatial sequence nodes is calculated for each subspace on a time scale of 2 hours, and then spliced ​​into a global spatial feature in a 64×532×12 data format, and output through a layer of full connection;

[0094] Step S3, flattening the global spatial features and the training data into the same dimension, and using the first multi-layer perceptron to extract temporal features;

[0095] The input format of global spatial features and training data is 64×532×12. The global spatial features and training data are flattened to the same dimension and converted into a data format of 64×1×6384. Then, the first multilayer perceptron is used to extract the time features of the last dimension to obtain the global time features. The first multilayer perceptron adopts a 6-layer structure. The mapping of the first layer is 6384→532, the mapping of the second layer is 532→256, the mapping of the third layer is 256→256, the mapping of the fourth layer is 256→256, the mapping of the fifth layer is 256→532, and the mapping of the sixth layer is 532→6348. Finally, the global time features are converted into a data format of 64×532×12.

[0096] Step S4, inputting the global time features and the training data into the second multi-layer perceptron for iterative training to obtain a trained traffic prediction model based on the second multi-layer perceptron;

[0097] Among them, the second multi-layer perceptron uses a 2-layer perceptron for iterative training;

[0098] Step S5: input the test data into the traffic prediction model for prediction, and obtain the traffic prediction result of taxi passengers getting on and off the taxi;

[0099] The input format of the prediction data is 64×532×12. A prediction model based on a two-layer perceptron is used. The mapping of the first layer is 12→128, and the mapping of the second layer is 128→12. The error calculation of the prediction results uses the mean absolute error, root mean square error, and Pearson correlation coefficient.

[0100] Mean absolute error:

[0101]

[0102] Root Mean Square Error:

[0103]

[0104] Pearson correlation coefficient:

[0105]

[0106] Where MAE is the mean absolute error, RMSE is the root mean square error, PCC is the Pearson correlation coefficient, N is the number of nodes, y7 is the true value, is the predicted value, is the mean of the true values, is the mean of the predicted values.

[0107] After calculation, it can be obtained that MAE=5.97, RMSE=11.36, and PCC=0.95, which proves that the present invention can achieve high-precision prediction.

[0108] Obviously, the above embodiments of the present invention are only examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.

Claims

1. A taxi passenger flow prediction method, characterized in that: The following steps are involved: S1: The passenger boarding and alighting flows are abstracted into spatial nodes and concatenated into the same dimension. Then all spatial nodes are serialized and normalized to obtain the original data. The original data is then divided into training data and test data. S2: Use the spatial multi-head attention algorithm to extract spatial attention features from the training data and obtain global spatial features; S3: Flatten the global spatial features and training data into the same dimension, use the first multi-layer perceptron to extract time features, and obtain global time features; the first multi-layer perceptron uses a 6-layer perceptron to extract time features; S4: inputting the global time features and the training data into the second multi-layer perceptron for iterative training to obtain a trained traffic prediction model based on the second multi-layer perceptron; the second multi-layer perceptron is iteratively trained using a 2-layer perceptron; S5: Input the test data into the traffic prediction model for prediction, and obtain the traffic prediction results of taxi passengers getting on and off the taxi.

2. The taxi passenger flow prediction method according to claim 1, characterized in that: The specific process of splicing the passenger boarding flow and the passenger alighting flow into the same dimension and abstracting them into spatial nodes in step S1 is as follows: The taxi pick-up and drop-off flow in a city is obtained and divided into several grids. The pick-up and drop-off flow of each grid are abstracted into spatial nodes and spliced ​​into the same dimension. That is, the number of spatial nodes is twice the number of divided grids.

3. The taxi passenger flow prediction method according to claim 1, characterized in that: In step S1, all spatial nodes obtain flow data once every 30 minutes, and use the deviation standardization method to normalize the data. The normalization formula is as follows: In the formula, x s is the processed data, x is the input data, X max is the maximum value of the data, X min is the minimum value of the data.

4. The taxi passenger flow prediction method according to claim 1, characterized in that: In step S1, after the original data is obtained, the first E time interval data in the data are used to predict the future F time interval data, so as to update the original data, and the updated original data is divided into training data and test data according to the proportion.

5. The taxi passenger flow prediction method according to claim 4, characterized in that: The first 60% of the updated original data is divided into training data, and the remaining 40% is divided into test data.

6. The taxi passenger flow prediction method according to claim 1, characterized in that: In step S2, the process of using the spatial multi-head attention algorithm to extract spatial features from the training data is as follows: Using different weight matrices W q , W k , W v Perform h operations on the training data H to obtain spatial attention features of different subspace granularities, and finally merge them into global spatial features; Among them, the formula of the spatial multi-head attention algorithm is as follows: head (i) =Attention(Q (i) ,K (i) ,V (i) ) MultiHead(H)=Concat(head (1) ,head (2) ,…,head (h) )W0 Where i = 1, 2, …, h; are the parameter matrices for mapping the i-th subspace data; Q (i) , K (i) 、V (i) Respectively represent the i-th subspace data after mapping; head (i) represents the attention of the i-th subspace; Attention represents the attention mechanism operation; Concat represents the concatenation operation; W0 is a learnable parameter; MultiHead (H) represents the global space feature.

7. The taxi passenger flow prediction method according to claim 1, characterized in that: The specific process of step S3 is as follows: The input format of global spatial features and training data is: B×N×M, where B is the amount of data input at one time, N is the number of nodes, and M is the number of time intervals input; The global spatial features and training data are flattened into the same dimension and converted into a B×1×(N×M) data format. Then, the first multi-layer perceptron is used to extract the time features of the last dimension to obtain the global time features. Finally, the global time features are converted into a B×N×Z data format, where Z is the number of output time intervals.

8. The taxi passenger flow prediction method according to claim 1, characterized in that: The error calculation of the flow prediction result obtained in step S5 uses the mean absolute error, root mean square error and Pearson correlation coefficient; Mean absolute error: Root Mean Square Error: Pearson correlation coefficient: Where MAE is the mean absolute error, RMSE is the root mean square error, PCC is the Pearson correlation coefficient, N is the number of nodes, and y i is the true value, is the predicted value, is the mean of the true values, is the mean of the predicted values.

Citation Information

Patent Citations

  • Urban vehicle demand prediction method and device and storage medium

    CN112330215A

  • Urban traffic flow interpretable prediction method based on space-time potential energy field

    CN112382094A