Traffic flow prediction method and device, storage medium and electronic device
By adopting the target graph neural network prediction model in traffic flow prediction, and using graph attention mechanism and channel attention optimization, the problem that existing technology is difficult to capture the spatial characteristics of the traffic system is solved, and more efficient and accurate traffic flow prediction is achieved, helping to improve traffic management and commuting efficiency.
Patent Information
- Application Number
- CN202411906512.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-04
AI Technical Summary
When predicting the start and end flow of the urban transportation system, it is difficult for the prior art to fully capture the close spatial connection of the transportation system, resulting in poor prediction results, which in turn aggravates the commuting pressure in the city.
The target graph neural network prediction model is adopted, and by obtaining historical traffic flow data and building an adjacency matrix based on the topology of the traffic network, the graph neural network model is trained to predict the traffic flow of the current date. This model utilizes graph attention mechanism and channel attention optimization to capture the correlation and importance of nodes in the traffic network more accurately.
It significantly improves the accuracy and real-time nature of traffic flow prediction, can more accurately capture the correlation and importance of nodes in the traffic network, effectively improves the prediction performance of the model, provides timely and accurate prediction data, and helps optimize traffic flow management and reduce traffic congestion.
Smart Images

Figure CN119761583A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of civil aviation information technology, and in particular to a traffic flow prediction method, device, storage medium and electronic device. Background Art
[0002] With the acceleration of urbanization and the continuous growth of urban population, the transportation systems of major cities in China are facing increasing commuting pressure. Various modes of transportation, including road transportation, public transportation and air transportation, play a vital role in daily life. As the demand for transportation increases, an effective solution is urgently needed to optimize the operation of the transportation system.
[0003] In the field of transportation, the origin-destination flow (OD flow), that is, the travel flow in a certain period of time, is usually used to describe the congestion of the transportation system. If the OD flow in a certain period of time can be accurately predicted, corresponding measures can be taken according to the predicted data, such as optimizing traffic signals, adjusting public transportation schedules, planning new traffic routes, etc., thereby effectively alleviating the pressure on the transportation system. Therefore, how to accurately predict OD flow has become an important issue that needs to be solved at present.
[0004] At present, most of the research on OD flow prediction mainly stays at the level of data statistics or machine learning in the time dimension. For a system that is closely connected in space, such as an urban transportation system, the effect of these methods is often unsatisfactory. Especially when there are multiple transportation hubs around some core areas, the traffic flow in the area will inevitably be affected by the surrounding hubs, and simple data statistics or machine learning methods in the time dimension cannot fully capture these spatial characteristics.
[0005] Therefore, there is an urgent need for an intelligent traffic flow prediction method that can display the current traffic flow changes in real time, provide traffic flow prediction data, and provide strong data support for the formulation of traffic operation strategies. Summary of the invention
[0006] The main purpose of the present application is to provide a traffic flow prediction method, device, storage medium and electronic device to solve the problem that most of the research on start-end traffic prediction in related technologies mainly stays at the data statistics level or the machine learning level of the time dimension, resulting in the inability to fully capture the spatial characteristics of transportation systems that are closely connected in space, which in turn may lead to the city's transportation system facing increasing commuting pressure.
[0007] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a traffic flow prediction method is provided. The method comprises: obtaining a target data set, wherein the target data set is used to represent the traffic flow data of a preset traffic route within a preset historical time period, and the preset historical time period includes the date of the day before the current date, and any date of the week before the current date; using a target graph neural network prediction model to predict the traffic flow of the target data set to obtain a prediction result, wherein the target graph neural network prediction model is obtained based on adjacency matrix training, and the prediction result is used to predict the traffic flow of the current date, and the adjacency matrix is constructed based on the topological structure of the traffic network, and any element in the adjacency matrix represents the degree of interaction between two locations.
[0008] Furthermore, the traffic flow prediction method also includes: obtaining first data, wherein the first data is used to represent the traffic flow data of a preset traffic route within a preset time period, and the time of the preset time period is earlier than the current date; performing data slicing processing on the first data based on a preset slicing strategy to obtain second data, wherein the preset slicing strategy is used to perform data slicing on the first data according to the slicing time interval; performing data splicing processing on the second data to obtain third data; training an initial graph neural network prediction model based on the third data and the adjacency matrix to obtain a target graph neural network prediction model.
[0009] Furthermore, obtaining the first data includes: obtaining fourth data; filtering the fourth data based on a preset filtering strategy to obtain filtered data; and performing data elimination processing on the filtered data to obtain the first data.
[0010] Furthermore, the first data is subjected to data sharding processing based on a preset sharding strategy to obtain the second data, including: filtering the first data based on the starting place information to obtain the fifth data; grouping the fifth data based on the location number to obtain the sixth data, wherein the data with the same location number in the sixth data are in the same group; and sharding the sixth data based on the sharding time interval to obtain the second data.
[0011] Furthermore, the second data is spliced to obtain the third data, including: extracting the starting flow data in the second data to obtain a flow sequence; constructing a flow matrix based on the flow sequence; and splicing the flow matrix based on the location number to obtain the third data.
[0012] Furthermore, the initial graph neural network prediction model is trained based on the third data and the adjacency matrix to obtain a target graph neural network prediction model, including: extracting features of the third data based on the graph attention network layer of the initial graph neural network prediction model to obtain a first eigenvector; forward propagating the first eigenvector to obtain a prediction result; and adjusting the model parameters of the initial graph neural network prediction model based on a preset loss function, the adjacency matrix and the prediction result to obtain a target graph neural network prediction model.
[0013] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a traffic flow prediction device is provided. The device includes: an acquisition module, which is used to acquire a target data set, wherein the target data set is used to represent the traffic flow data of a preset traffic route within a preset historical time period, and the preset historical time period includes the date of the day before the current date, and any date of the week before the current date; a prediction module, which is used to use a target graph neural network prediction model to predict the traffic flow of the target data set to obtain a prediction result, wherein the target graph neural network prediction model is obtained based on adjacency matrix training, and the prediction result is used to predict the traffic flow of the current date, and the adjacency matrix is constructed based on the topological structure of the traffic network, and any element in the adjacency matrix represents the degree of interaction between two locations.
[0014] Furthermore, the acquisition module is also used to acquire first data, wherein the first data is used to represent traffic flow data of a preset traffic route within a preset time period, and the time of the preset time period is earlier than the current date; the first data is subjected to data slicing processing based on a preset slicing strategy to obtain second data, wherein the preset slicing strategy is used to perform data slicing on the first data according to the slicing time interval; the second data is subjected to data splicing processing to obtain third data; the initial graph neural network prediction model is trained based on the third data and the adjacency matrix to obtain a target graph neural network prediction model.
[0015] Furthermore, the acquisition module is also used to acquire fourth data; perform screening processing on the fourth data based on a preset screening strategy to obtain screened data; and perform data elimination processing on the screened data to obtain first data.
[0016] Furthermore, the acquisition module is also used to filter the first data based on the starting place information to obtain the fifth data; group the fifth data based on the location number to obtain the sixth data, wherein the data with the same location number in the sixth data is in the same group; and slice the sixth data based on the slice time interval to obtain the second data.
[0017] Furthermore, the acquisition module is also used to extract the starting flow data in the second data to obtain a flow sequence; construct a flow matrix based on the flow sequence; and splice the flow matrix based on the location number to obtain the third data.
[0018] Furthermore, the acquisition module is also used to extract features of the third data based on the graph attention network layer of the initial graph neural network prediction model to obtain a first feature vector; forward propagate the first feature vector to obtain a prediction result; adjust the model parameters of the initial graph neural network prediction model based on a preset loss function, adjacency matrix and prediction result to obtain a target graph neural network prediction model.
[0019] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a computer-readable storage medium is provided, wherein the storage medium stores a program, wherein the program executes any one of the above-mentioned traffic flow prediction methods.
[0020] In order to achieve the above-mentioned purpose, according to another aspect of the present application, an electronic device is provided, which includes one or more processors and a memory, and the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the above-mentioned traffic flow prediction methods.
[0021] Through this application, the following steps are adopted: obtaining a target data set, wherein the target data set is used to represent the traffic flow data of a preset traffic route within a preset historical time period, and the preset historical time period includes the date of the day before the current date, and any date of the week before the current date; using a target graph neural network prediction model to predict the traffic flow of the target data set, and obtaining a prediction result, wherein the target graph neural network prediction model is obtained based on adjacency matrix training, and the prediction result is used to predict the traffic flow of the current date, and the adjacency matrix is constructed based on the topological structure of the traffic network. Any element in the adjacency matrix represents the degree of interaction between two locations, which solves the problem that most of the research on the prediction of the start-end flow in the related technology mainly stays at the data statistics level or the machine learning level of the time dimension, resulting in the inability to fully capture the spatial characteristics of the transportation system that is closely connected in space, and then the urban transportation system may face increasing commuting pressure. The traffic flow prediction method of this application significantly improves the accuracy and real-time performance of the prediction. Through the graph attention mechanism and channel attention optimization, it can more accurately capture the correlation and importance between nodes in the traffic network, and effectively improve the prediction performance of the model. In practical applications, the traffic flow prediction method of this application can provide timely and accurate prediction data, which helps to optimize traffic flow management, reduce traffic congestion, and improve road traffic efficiency, and is of great value to urban traffic planning and emergency response. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0023] Figure 1 is a flow chart of a traffic flow prediction method provided according to an embodiment of the present application;
[0024] Figure 2 It is a schematic diagram of the model structure in this embodiment;
[0025] Figure 3 is a schematic diagram of a traffic flow prediction system provided according to an embodiment of the present application;
[0026] Figure 4 is a schematic diagram of a traffic flow prediction device provided according to an embodiment of the present application;
[0027] Figure 5 is a schematic diagram of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0028] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0029] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set between this system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0032] The present invention is described below in conjunction with preferred implementation steps. Figure 1 is a flow chart of a traffic flow prediction method provided according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0033] Step S10, obtaining a target data set, wherein the target data set is used to represent traffic flow data of a preset traffic route within a preset historical time period, and the preset historical time period includes the date of the day before the current date, and any date of the week before the current date;
[0034] In the embodiment of the present invention, the preset historical time period can be understood as a specific date range for training and predicting models. Exemplarily, the preset historical time period mainly includes the day before the current date and any date within a week before the current date, which is not limited here.
[0035] The preset traffic route can be understood as a specific traffic route of interest. For example, the data set used in this application is 70 million traffic flow data of 3 lines and 81 locations in the subway line, which is not limited here.
[0036] The date one day before the current date can be understood as the day before.
[0037] Any date one week before the current date can be understood as any date last week.
[0038] Obtaining the target data set can be understood as first determining the preset historical time period as the day before the current date and any date within a week before the current date, and then obtaining the traffic flow data of the traffic routes within the corresponding time period, thereby ensuring that the selected data can reflect the changing pattern of traffic flow to the greatest extent and provide high-quality training data for the model.
[0039] In the embodiment of the present invention, obtaining the target data set is a key step in building a prediction model, which not only requires the accuracy and timeliness of the data, but also ensures that the model is trained on the most relevant historical data, thereby improving the accuracy and reliability of the prediction.
[0040] Step S12, using the target graph neural network prediction model to predict the traffic flow of the target data set to obtain a prediction result, wherein the target graph neural network prediction model is trained based on the adjacency matrix, and the prediction result is used to predict the traffic flow on the current date. The adjacency matrix is constructed based on the topological structure of the traffic network, and any element in the adjacency matrix represents the degree of interaction between two locations.
[0041] In the embodiment of the present invention, the target graph neural network prediction model can be understood as a deep learning model that is specifically used to predict the traffic flow of a preset traffic route on the current date after a specific training process. The core of this model is the Graph Neural Network (GNN), especially the GNN variant that uses the Graph Attention Mechanism (GAT). GNN is a neural network that can process graph structured data, learn the feature representation of nodes, and consider the connectivity between nodes, that is, the topological structure of the traffic network.
[0042] The prediction result can be understood as the specific value output by the target graph neural network prediction model on the traffic flow prediction of the current date. The prediction result represents the predicted traffic flow data, which can be the expected passenger flow or vehicle flow of each station in different time windows (such as 15-minute intervals). The accuracy of the prediction result is crucial for decision-making such as traffic scheduling, route planning, and signal light control. The prediction result provides an expectation of future traffic demand, allowing relevant departments to prepare in advance and optimize resource allocation to cope with possible traffic peaks or congestion.
[0043] The target graph neural network prediction model is used to predict the traffic flow of the target data set. The prediction result can be understood as using the trained GNN model to input the collected traffic flow data (target data set) within the preset historical time period into the model. The model will predict the traffic flow value of each location of interest on the current date based on the patterns and rules it has learned before.
[0044] The target graph neural network prediction model is trained based on the adjacency matrix, which can be understood as using the adjacency matrix to dynamically adjust the weights between different locations, thereby capturing more detailed traffic changes and dependencies.
[0045] Any element in the adjacency matrix represents the degree of interaction between two locations. It can be understood that each element (i.e., each value) in the adjacency matrix corresponds to the connection relationship between two locations in the transportation network. If there is a direct access or route between the two locations, the corresponding element value may be higher, indicating that the degree of interaction or connection between the two locations is high. If there is no direct access between the two locations, or the importance of the access is low, for example, there are few passengers or vehicles going directly from A to B, then the corresponding element value will be low or even zero. Through the adjacency matrix, the model can identify key locations and routes that have a direct impact on traffic flow, thereby improving the accuracy and effectiveness of traffic prediction, which is not limited here.
[0046] For example, in traffic flow prediction, locations and routes can be naturally represented as graph structures, where nodes represent locations and edges represent connections or routes between sites. The use of graph convolutional network (GCN) technology can make full use of the topological structure of the traffic network, and by aggregating the information of adjacent sites, capture the spatial dependence of traffic flow, thereby improving the accuracy of prediction. Through GCN, we can better understand how the passenger flow of a subway station is affected by its adjacent sites and the changing trend of the overall network traffic. Therefore, we use graph convolution technology to perform convolution operations directly on graph data to capture the dependencies and graph structure information between nodes. GCN generates a high-level feature representation of each node by aggregating the neighbor information of the node layer by layer. The core formula of graph convolution technology is shown in formula (1), H represents the feature, σ represents the activation function, D represents the degree matrix, A represents the adjacency matrix with the unit matrix added, W is the model training parameter matrix, l is the current number of layers, and the feature vector of the next layer is obtained by transforming and activating the feature vector of the previous layer through formula (1).
[0047]
[0048] In traffic flow prediction, the relationship and influence between different stations are not equal. The graph neural network GAT based on graph attention technology is based on GCN research. It abandons the Laplace matrix and uses the adjacency matrix to dynamically adjust the weights between different stations to capture more detailed traffic changes and dependencies. This flexibility enables GAT to more accurately model the influence between stations when processing complex subway network data and improve the accuracy of prediction. The core of the GAT model lies in the graph attention matrix, and its core calculation formula is shown in Formula (2) and Formula (3).
[0049]
[0050] Among them, e represents the attention matrix, a represents the model training parameters, W is also a model training parameter, h represents the node feature, the || symbol represents simple vector concatenation, and softmax and LeakyRelu are activation functions.
[0051] In an embodiment of the present invention, the target graph neural network prediction model can make accurate predictions about future traffic flows by fully understanding the connection structure between locations and historical traffic data. Its training and prediction process is closely dependent on deep learning of the connection relationships between locations, that is, capturing and learning these relationships through the adjacency matrix, thereby improving the accuracy of the prediction.
[0052] In the embodiment of the present invention, obtaining the target data set is a key step in building a prediction model, which not only requires the accuracy and timeliness of the data, but also ensures that the model is trained on the most relevant historical data, thereby improving the accuracy and reliability of the prediction. The target graph neural network prediction model can make accurate predictions of future traffic flow by fully understanding the connection structure between locations and historical traffic data. Its training and prediction process closely relies on deep learning of the connection relationship between locations, that is, capturing and learning these relationships through the adjacency matrix, thereby improving the accuracy of the prediction.
[0053] Optionally, the traffic flow prediction method further includes:
[0054] Step S101, obtaining first data, wherein the first data is used to represent traffic flow data of a preset traffic route within a preset time period, and the time of the preset time period is earlier than the current date;
[0055] Step S102, performing data sharding processing on the first data based on a preset sharding strategy to obtain second data, wherein the preset sharding strategy is used to perform data sharding on the first data according to sharding time intervals;
[0056] Step S103, performing data splicing processing on the second data to obtain third data;
[0057] Step S104: train the initial graph neural network prediction model based on the third data and the adjacency matrix to obtain a target graph neural network prediction model.
[0058] In the embodiment of the present invention, the first data may be understood as originally collected and unprocessed traffic flow data, including detailed traffic information of a preset traffic route within a preset time period.
[0059] The second data can be understood as data that has been processed by data sharding. The second data converts the first data into a format that is convenient for model training according to a preset sharding strategy and time interval.
[0060] The third data can be understood as being obtained after data splicing processing. The third data is obtained by splicing the data of multiple sites in the same time slice to form a matrix or tensor, which is convenient for input into the graph neural network model.
[0061] The preset time period can be understood to refer to a time range for collecting the first data. For example, the preset time period can be 25 days, which is not limited here.
[0062] The preset sharding strategy can be understood as a method of dividing the first data by time, and its purpose is to convert continuous time series data into a series of time segments or windows that are easy to process.
[0063] The slicing time interval can be understood as the length of each defined time segment. For example, the slicing time interval can be segmented according to 15 minutes, which is not limited here.
[0064] Obtain first data, wherein the first data is used to represent traffic flow data of a preset traffic route within a preset time period. The preset time period being earlier than the current date can be understood as collecting and preparing historical traffic flow data, which covers a specific time range earlier than the current date and focuses on the preset traffic route.
[0065] The first data is processed by data slicing based on the preset slicing strategy to obtain the second data, wherein the preset slicing strategy is used to slice the first data according to the slicing time interval, which can be understood as cutting the first data (original historical traffic flow data) according to the pre-set slicing strategy and time interval, and converting it into a series of smaller data segments that are evenly divided in time, that is, obtaining the second data. The second data will make it easier for the model to understand and learn short-term and periodic patterns in time series.
[0066] The data splicing process of the second data to obtain the third data can be understood as reorganizing or splicing the data segments (i.e., the second data) that have been processed by sharding according to a certain logic to form a unified data set (i.e., the third data). This step usually involves vertically splicing data from the same site in different time segments, or horizontally splicing data from different sites in the same time segments to create a multidimensional data structure that can simultaneously reflect the characteristics of location and time, which is convenient for the input and processing of the graph neural network model.
[0067] The initial graph neural network prediction model is trained based on the third data and the adjacency matrix to obtain the target graph neural network prediction model. It can be understood that the initial graph neural network model is trained using the third data (processed traffic flow data set) and the adjacency matrix (a mathematical structure that describes the spatial dependencies between locations) as training data. The model gradually adjusts its internal parameters by learning the time series characteristics and spatial dependencies in the data to improve the accuracy of predicting traffic flow on the current date. After training, the initial graph neural network model is transformed into a target graph neural network prediction model, which has the ability to predict traffic flow and can provide a scientific basis and decision support for traffic management.
[0068] In the embodiment of the present invention, through the entire process of collecting historical traffic data and building and training the prediction model, it is ensured that the model can fully understand the spatial structure and time series characteristics of the traffic network, thereby improving its accuracy and reliability in predicting the traffic flow on the current date.
[0069] Optionally, in step S101, obtaining the first data includes the following execution steps:
[0070] Step S1011, obtaining fourth data;
[0071] Step S1012, filtering the fourth data based on a preset filtering strategy to obtain filtered data;
[0072] Step S1013, performing data elimination processing on the screened data to obtain first data.
[0073] In the embodiment of the present invention, the fourth data can be understood as a preliminary collected original traffic flow data set containing all details. For example, the fourth data can be the 12 sample data shown in Table 1, which is not limited here.
[0074] Table 1
[0075]
[0076] The preset screening strategy can be understood as a data processing method for screening out data that is highly relevant to the prediction target from the fourth data. Exemplarily, the preset screening strategy can be to delete useless fields and only consider the user's starting location information, route information, and direction information, which is not limited here. The preset screening strategy is used to perform data preprocessing operations on the data in Table 1 according to the processing flow, delete useless fields, and only consider the user's starting location information, route information, and direction information. Delete erroneous data, including data with null values that cannot be analyzed. The data shown in Table 2 is obtained in the format after processing.
[0077] Table 2
[0078]
[0079]
[0080] Data removal can be understood as the process of further removing data points that do not meet quality standards or are irrelevant to prediction from the screened data after pre-screening. This may include removing duplicate data, abnormal values (such as extreme values or null values), data from non-target sites, etc., to ensure that the first data used for model training is high-quality, noise-free, and contains only information that actually contributes to the prediction.
[0081] Acquiring the fourth data can be understood as the initial step of collecting or extracting raw traffic flow data from a data source (such as a traffic monitoring system, a sensor network, a historical database, etc.). This step usually involves operations such as data capture, data interface calls, or data file imports, which are not limited here.
[0082] The fourth data is screened based on the preset screening strategy to obtain the screened data, which can be understood as selecting data points that are closely related to the prediction task or meet specific conditions from the fourth data containing all the original information according to pre-defined rules or standards (i.e., the preset screening strategy), to form a more refined data set, i.e., the screened data.
[0083] Performing data elimination processing on the filtered data to obtain the first data can be understood as further removing those data points that do not meet the quality requirements or are irrelevant to the prediction target on the basis of the filtered data, such as removing records with missing values, outliers, duplicate records or fields irrelevant to the prediction task, and finally obtaining a purer, structured data set suitable for model training, namely the first data.
[0084] In the embodiment of the present invention, data preprocessing is a key step in the model training process. Through this step, the original data is converted into high-quality training data that can be directly used by the model, thereby ensuring that the data set in the model training stage is free of noise and redundancy, thereby improving the learning efficiency and prediction accuracy of the model, and laying a solid foundation for subsequent model training and traffic prediction.
[0085] Optionally, in step S102, performing data sharding processing on the first data based on a preset sharding strategy to obtain the second data includes the following execution steps:
[0086] Step S1021, filtering the first data based on the origin information to obtain fifth data;
[0087] Step S1022, grouping the fifth data based on the location number to obtain sixth data, wherein data with the same location number in the sixth data are in the same group;
[0088] Step S1023: fragment the sixth data based on the fragmentation time interval to obtain second data.
[0089] In the embodiment of the present invention, the fifth data can be understood as a data set obtained by filtering the first data based on the origin information. That is, the fifth data will only include traffic flow data associated with the selected origin, thereby reducing the complexity of the data set and making subsequent data processing and analysis more centralized and efficient.
[0090] The sixth data can be understood as a data set obtained by grouping the fifth data based on the location number. That is, all records in the fifth data are classified according to the location number to ensure that data with the same location number are in the same group. Through this grouping method, the sixth data will be organized into multiple sub-data sets, each of which corresponds to the traffic flow data of a station or location.
[0091] Filtering the first data based on the starting point information to obtain the fifth data can be understood as filtering from the original first data set according to specific starting point information (i.e., the starting point of the traffic flow), extracting all records related to these starting points, and forming a new data set, i.e., the fifth data.
[0092] The fifth data is grouped based on the location number to obtain the sixth data, wherein the data with the same location number in the sixth data are in the same group, which can be understood as further classifying and grouping the fifth data (the filtered starting point related data) according to the location number, ensuring that all data under the same location number are classified into the same sub-data set, i.e., the sixth data.
[0093] Slicing the sixth data based on the slicing time interval to obtain the second data can be understood as cutting the sixth data (data grouped by location number) according to a pre-set time slicing strategy (such as 15 minutes as a time window) to obtain a series of time segment data that are continuous in time and have a fixed length, namely the second data.
[0094] For example, all data are counted, the starting place sequence is screened, grouped by number, and the time is sliced according to 15 minutes, from 5:00 to 24:00, a total of 19 hours, 76 slices. The starting time sequence of each location in each time period is extracted. The horizontal axis of the sequence is the number of locations, and the vertical axis is the time slice. Therefore, the starting time sequence of a day is 81*76. All data are processed as above and spliced to obtain 81*1824 (76*24) data. The final data division is shown in Table 3.
[0095] Table 3
[0096] serial number 5:00-5:15 5:15-5:30 5:30-5:45 ...... 23:45-24:00 1 15 24 72 ...... 15 2 24 32 61 ...... 24 ...... ...... ...... ...... ...... ...... 81 19 28 47 ...... 33
[0097] In the embodiment of the present invention, the processing flow from the first data to the second data includes screening and grouping based on the starting place information and the location number, as well as time-based slicing, the purpose of which is to convert the original and complex traffic flow data into a format that is more orderly, more relevant, and more suitable for model training, thereby improving the accuracy of traffic flow prediction.
[0098] Optionally, in step S103, performing data concatenation processing on the second data to obtain third data includes the following execution steps:
[0099] Step S1031, extracting the starting flow data in the second data to obtain a flow sequence;
[0100] Step S1032, constructing a traffic matrix based on the traffic sequence;
[0101] Step S1033, concatenating the traffic matrix based on the location number to obtain third data.
[0102] In the embodiment of the present invention, extracting the starting flow data from the second data to obtain the flow sequence can be understood as extracting the flow information of the starting place in each time slice from the second data after time slicing, arranging the flow information in chronological order, and forming a series of flow sequences. The flow sequence reflects the flow changes of a specific place in different time windows, and is the basis for the subsequent construction of the flow matrix and prediction analysis.
[0103] Exemplarily, extract the starting time series of each location in each time period, for example, extract the starting flow data in each time slice for the grouped data of each location number. This means that for the subway station with location number 27, we will calculate the number of passengers departing from the station in each time slice of 05:00-05:15, 05:15-05:30, ..., 23:45-24:00. Ultimately, each location will form a flow sequence consisting of 76 data points, which is not limited here.
[0104] Constructing a traffic matrix based on traffic sequences can be understood as organizing the extracted traffic sequences into a matrix form, namely the traffic matrix. Typically, the rows of the traffic matrix may represent different locations, and the columns represent time windows arranged in chronological order. In this way, each matrix element represents the traffic value of a specific location within a specific time window. The construction of the traffic matrix is to provide a structured data representation that facilitates the model to understand and learn the complex relationship between location and time, as well as the pattern of traffic changes over time.
[0105] For example, the horizontal axis of the sequence is the number of locations, the vertical axis is the time slice, and the start time sequence of a day is 81*76. For example, a flow matrix is constructed with the horizontal axis being the number of locations (81 locations) and the vertical axis being the time slice (76 time slices). This means that the start time sequence of a day will be a two-dimensional matrix of 81×76, where each element represents the start flow of a specific location in a specific time slice, which is not limited here.
[0106] The flow matrix is spliced based on the location number to obtain the third data, which can be understood as horizontally splicing or stacking multiple flow matrices (which may correspond to different locations or stations) according to the location number to obtain a comprehensive data set, namely the third data. This step is to ensure that the flow information of all locations is included in the same data structure, which is convenient for the unified processing and analysis of the subsequent model, and is not limited here.
[0107] For example, all data are processed in the above steps and spliced to obtain 81*1824 (76*24) data. For example, the flow data of 24 consecutive days (76×24=1824) are spliced according to the location. Since the flow data of each location for one day is 76 time slices, the data of 24 consecutive days will form an 81×1824 matrix, which is not limited here.
[0108] In the embodiment of the present invention, the conversion process from raw traffic data to structured prediction input ensures that the model can learn the patterns and laws of traffic changes from a comprehensive data set that contains both location information and time series information, thereby improving the accuracy of the prediction. The extraction of traffic sequences, the construction of traffic matrices, and the splicing of traffic matrices are all aimed at optimizing the data format to make it more consistent with the model requirements of graph neural networks and graph attention mechanisms, thereby providing data support for accurate prediction of traffic flow.
[0109] Optionally, training the initial graph neural network prediction model based on the third data and the adjacency matrix to obtain the target graph neural network prediction model includes the following execution steps:
[0110] Perform feature extraction on the third data based on the graph attention network layer of the initial graph neural network prediction model to obtain a first feature vector;
[0111] Perform forward propagation on the first eigenvector to obtain the prediction result;
[0112] Based on the preset loss function, adjacency matrix and prediction results, the model parameters of the initial graph neural network prediction model are adjusted to obtain the target graph neural network prediction model.
[0113] In the embodiment of the present invention, the graph attention network layer (GAT layer) can be understood as a component of the graph neural network (GNN), which uses the nodes in the graph structure and their relationships to extract features.
[0114] The first eigenvector can be understood as the vector representation obtained by the graph attention network layer (GAT layer) after feature extraction and aggregation of the input data (the third data, i.e., the processed traffic matrix).
[0115] The preset loss function can be understood as a function used to quantify the difference between the model prediction result and the actual observation value. For example, the preset loss function can be the mean square error (MSE), which is expressed as
[0116] The first feature vector can be understood as extracting features from the third data based on the graph attention network layer of the initial graph neural network prediction model, dividing the third data into a training set, a validation set, and a test set in chronological order or randomly for model training, hyperparameter adjustment, and final performance evaluation. The data in the training set is divided into weekly data and daily data, and features are extracted from the weekly data and daily data respectively based on the graph attention network layer, and the feature vectors obtained are row-joined to obtain the first feature vector.
[0117] Forward propagation of the first eigenvector to obtain the prediction result can be understood as extracting features from the first eigenvector through a two-dimensional convolutional layer and obtaining the final prediction result through a fully connected layer.
[0118] Based on the preset loss function, adjacency matrix and prediction results, the model parameters of the initial graph neural network prediction model are adjusted to obtain the target graph neural network prediction model. It can be understood as adjusting the parameters of the initial graph neural network prediction model based on the preset loss function (such as mean square error MSE, etc.), adjacency matrix (a matrix reflecting the spatial relationship between locations), and the prediction results of the model through optimization algorithms such as back propagation and gradient descent to achieve the purpose of improving the prediction accuracy.
[0119] In the embodiment of the present invention, the graph attention network layer is a key component for extracting features from data with a graph structure, and the node information is better aggregated by calculating the attention weight. The first feature vector is obtained through the graph attention network layer, which reflects the comprehensive characteristics of the location in the traffic network. The preset loss function is a quantitative standard for guiding the adjustment of model parameters to optimize the prediction effect. The above steps together constitute the training process of the traffic flow prediction model based on the graph neural network, ensuring that the model can accurately predict future traffic flow.
[0120] Figure 2 It is a schematic diagram of the model structure in this embodiment, such as Figure 2 As shown in the figure, two types of data are used as input, namely weekly data and daily data. The time step is set to 5. The model predicts the data of the next day by inputting the data of the previous few days. Weekly data refers to the data of the first 5 time slices at the same time point last week, and daily data refers to the data of the first 5 time slices at the same time point the previous day. Weekly data and daily data are 64*81*5 data respectively, 64 is the batch size, 81 is the number of sites, and 5 is the number of time slices. After the two sets of data are processed by the GAT layer to extract the features of the surrounding nodes, 64*81*5 data is output. Then, the daily data and weekly data are simply concatenated in rows, and the output format is 64*81*10. Then, the data is processed by a two-dimensional convolution layer to convert the data from 1 channel to 8 channels, and 64*8*81*10 data is output. Further feature extraction is performed on the data to explore the potential relationship between the data. Then the channel dimension is flattened to obtain 64*6480 data. Next, the data is converted into 64*1024, 64*528, and 64*1 data respectively through three fully connected layers.
[0121] The calculation part of the GAT model trains a weight matrix W (size is [in_feature, out_feature]) and an attention coefficient a (size is [2*out_feature, 1]) to train the weights between neighbors. The attention weight matrix attention is calculated by formula (2) and formula (3), and then attention is calculated with the input feature h to obtain the final node feature representation.
[0122] The specific training process of the model is as follows:
[0123] 1: Initialize the model parameters, randomly initialize the parameters or read the pth file;
[0124] 2: Load data and divide it into training set and test set;
[0125] 3: for epoch=1to max_epochs do:
[0126] a: Calculate the weekly data and daily data of the training set through the GAT model, result 1 and result 2;
[0127] b: horizontally splice result1 and result2 to get result3;
[0128] c: Extract features from result3 through a two-dimensional convolutional layer, and obtain the final prediction result through a fully connected layer;
[0129] d: Calculate the loss function, see formula (4):
[0130]
[0131] e: Back propagation and update parameters: see formula (5):
[0132]
[0133] f: Perform the test and input the test set data into the model;
[0134] g: Calculate the loss function, see formula (4);
[0135] h: record and save the training loss function results and the test loss function results;
[0136] i: Determine whether the loss function result is reduced. If it does not decrease for five consecutive times, exit the training and save the model in the form of a pth file;
[0137] 4: Visualize the results based on the results saved in step 3.h.
[0138] The training data uses the data from the first 21 days, and the test data uses the data from the last 7 days. The number of attention heads is set to 1, and the number of epochs during training is set to 1000. The optimizer uses the stochastic gradient descent method and the early stopping strategy to monitor the change of the loss function. When the error of the model on the validation set is worse than the last training result, the training is stopped to avoid overfitting. In order to avoid multiple training, the model will save the current optimal model.
[0139] In the model prediction stage, the input is 81*1520 ((10+10)*76) time slices, 76 is the number of time slices in a day, that is, the time slices of the previous day and the previous week, and the output is 81*76. The system deploys the algorithm in a separate server and calls the algorithm module regularly at 1 am every day to obtain the forecast data for the day.
[0140] Figure 3 is a schematic diagram of a traffic flow prediction system provided according to an embodiment of the present application, such as Figure 3As shown in the figure, the components involved in the system include data preprocessing component, data partitioning component, model training component, and model prediction component. Among them, the data preprocessing component is used to delete useless fields and erroneous data in the data set. The data set of the data partitioning component includes 70 million traffic flow data of 3 routes and 81 locations within 25 days. All data are counted, the starting place sequence is filtered, grouped by number, and the time is sliced according to 15 minutes to extract the starting time sequence of each location in each time period. The model training component uses the GAT layer to extract the features of the surrounding nodes, and then processes it through the two-dimensional convolution layer. Then the channel dimension is flattened and predicted through three layers of fully connected layers. The model stops training when the error on the validation set is worse than the last training result to avoid overfitting. In order to avoid multiple training, the model will save the current optimal model. In the model prediction component, the input uses 81*1520 time slices and the output is 81*76. The system deploys the algorithm on a separate server and calls the algorithm module regularly at 1 am every day to obtain the forecast data for the day.
[0141] Specifically, first preprocess the data set, delete useless fields, and only consider the user's starting location information, route information, and direction information. Delete erroneous data, including data with null values that cannot be analyzed. Then count all the data, filter the starting location sequence, group by number, and slice the time according to 15 minutes, from 5 to 24 hours, a total of 19 hours, 76 slices. Extract the starting time sequence of each location in each time period. The horizontal axis of the sequence is the number of locations, and the vertical axis is the time slice. Therefore, the starting time sequence of a day is 81*76. All data are processed as above and spliced to obtain 81*1824 (76*24) data. Then train the model on the data set and save the current optimal model. Finally, call the model prediction component, input the time slices of the previous day and last week, and output the predicted data for all time slices of the day.
[0142] The traffic flow prediction method proposed in this application combines the graph neural network (GNN) and the graph attention mechanism (GAT) to dynamically adjust the weights between different nodes, thereby capturing the traffic changes and the spatial dependencies between traffic nodes in a more detailed manner, thereby improving the accuracy of traffic prediction. This application can also display the current traffic flow changes in real time and provide traffic flow prediction data. The model uses efficient calculation methods and optimization strategies to ensure that large-scale traffic data processing and prediction are completed in a short time. In addition, this application can be applied to various traffic scenarios and provide effective prediction and optimization solutions for different types of traffic systems. This flexibility makes the model more robust and stable when processing complex traffic network data.
[0143] The embodiment of the present application also provides a traffic flow prediction device. It should be noted that the traffic flow prediction device of the embodiment of the present application can be used to execute the traffic flow prediction method provided in the embodiment of the present application. The traffic flow prediction device provided in the embodiment of the present application is introduced below.
[0144] Figure 4 is a schematic diagram of a traffic flow prediction device 400 provided according to an embodiment of the present application. Figure 4 As shown, the device includes: an acquisition module 401 and a prediction module 402.
[0145] Specifically, the acquisition module 401 is used to acquire a target data set, wherein the target data set is used to represent the traffic flow data of a preset traffic route within a preset historical time period, and the preset historical time period includes the date of the day before the current date, and any date of the week before the current date;
[0146] The prediction module 402 is used to use the target graph neural network prediction model to predict the traffic flow of the target data set to obtain a prediction result, wherein the target graph neural network prediction model is trained based on the adjacency matrix, and the prediction result is used to predict the traffic flow on the current date. The adjacency matrix is constructed based on the topological structure of the traffic network, and any element in the adjacency matrix represents the degree of interaction between two locations.
[0147] In summary, the traffic flow prediction device 400 provided in the embodiment of the present application obtains a target data set through an acquisition module 401, wherein the target data set is used to represent the traffic flow data of a preset traffic route within a preset historical time period, and the preset historical time period includes the date of the day before the current date, and any date of the week before the current date. Through the prediction module 402, the target graph neural network prediction model is used to predict the traffic flow of the target data set to obtain a prediction result, wherein the target graph neural network prediction model is obtained based on adjacency matrix training, and the prediction result is used to predict the traffic flow of the current date. The adjacency matrix is constructed based on the topological structure of the traffic network. Any element in the adjacency matrix represents the degree of interaction between two locations, which solves the problem that most of the research on the prediction of the start and end traffic in the related technology mainly stays at the data statistics level or the machine learning level of the time dimension, resulting in the inability to fully capture the spatial characteristics of the traffic system that is closely connected in space, and then the city's traffic system may face increasing commuting pressure. The traffic flow prediction method of the present application significantly improves the accuracy and real-time performance of the prediction. Through the graph attention mechanism and channel attention optimization, it can more accurately capture the correlation and importance between nodes in the traffic network, and effectively improve the prediction performance of the model. In practical applications, the traffic flow prediction method of this application can provide timely and accurate prediction data, which helps to optimize traffic flow management, reduce traffic congestion, and improve road traffic efficiency, and is of great value to urban traffic planning and emergency response.
[0148] Furthermore, the acquisition module 401 is also used to acquire first data, wherein the first data is used to represent traffic flow data of a preset traffic route within a preset time period, and the time of the preset time period is earlier than the current date; the first data is subjected to data slicing processing based on a preset slicing strategy to obtain second data, wherein the preset slicing strategy is used to perform data slicing on the first data according to the slicing time interval; the second data is subjected to data splicing processing to obtain third data; the initial graph neural network prediction model is trained based on the third data and the adjacency matrix to obtain a target graph neural network prediction model.
[0149] Furthermore, the acquisition module 401 is also used to acquire fourth data; perform screening processing on the fourth data based on a preset screening strategy to obtain screened data; and perform data elimination processing on the screened data to obtain first data.
[0150] Furthermore, the acquisition module 401 is also used to filter the first data based on the starting place information to obtain the fifth data; group the fifth data based on the location number to obtain the sixth data, wherein the data with the same location number in the sixth data are in the same group; and slice the sixth data based on the slicing time interval to obtain the second data.
[0151] Furthermore, the acquisition module 401 is also used to extract the starting flow data in the second data to obtain a flow sequence; construct a flow matrix based on the flow sequence; and splice the flow matrix based on the location number to obtain the third data.
[0152] Furthermore, the acquisition module 401 is also used to perform feature extraction on the third data based on the graph attention network layer of the initial graph neural network prediction model to obtain a first feature vector; forward propagate the first feature vector to obtain a prediction result; adjust the model parameters of the initial graph neural network prediction model based on a preset loss function, adjacency matrix and prediction result to obtain a target graph neural network prediction model.
[0153] The traffic flow prediction device includes a processor and a memory. The acquisition module 401, prediction module 402, etc. are stored in the memory as program units. The processor executes the program units stored in the memory to implement corresponding functions.
[0154] The processor includes a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set to accurately predict the OD flow by adjusting the kernel parameters to provide more accurate traffic flow prediction.
[0155] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0156] An embodiment of the present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the traffic flow prediction method is implemented.
[0157] An embodiment of the present invention provides a processor, which is used to run a program, wherein the traffic flow prediction method is executed when the program is running.
[0158] like Figure 5As shown, an embodiment of the present invention provides an electronic device, the device includes a processor, a memory and a program stored in the memory and executable on the processor, and the processor implements the following steps when executing the program: obtaining a target data set, wherein the target data set is used to represent the traffic flow data of a preset traffic route within a preset historical time period, and the preset historical time period includes the date of the day before the current date, and any date of the week before the current date; using a target graph neural network prediction model to predict the traffic flow of the target data set to obtain a prediction result, wherein the target graph neural network prediction model is obtained based on adjacency matrix training, and the prediction result is used to predict the traffic flow of the current date, and the adjacency matrix is constructed based on the topological structure of the traffic network, and any element in the adjacency matrix represents the degree of interaction between two locations.
[0159] When the processor executes the program, the following steps are also implemented: obtaining first data, wherein the first data is used to represent traffic flow data of a preset traffic route within a preset time period, and the time of the preset time period is earlier than the current date; performing data slicing processing on the first data based on a preset slicing strategy to obtain second data, wherein the preset slicing strategy is used to perform data slicing on the first data according to the slicing time interval; performing data splicing processing on the second data to obtain third data; training an initial graph neural network prediction model based on the third data and the adjacency matrix to obtain a target graph neural network prediction model.
[0160] When the processor executes the program, the following steps are also implemented: acquiring fourth data; performing screening processing on the fourth data based on a preset screening strategy to obtain screened data; performing data elimination processing on the screened data to obtain first data.
[0161] When the processor executes the program, the following steps are also implemented: the first data is filtered based on the starting place information to obtain the fifth data; the fifth data is grouped based on the location number to obtain the sixth data, wherein the data with the same location number in the sixth data are in the same group; the sixth data is segmented based on the segmentation time interval to obtain the second data.
[0162] When the processor executes the program, the following steps are also implemented: extracting the starting flow data in the second data to obtain a flow sequence; constructing a flow matrix based on the flow sequence; and splicing the flow matrix based on the location number to obtain third data.
[0163] When the processor executes the program, the following steps are also implemented: the initial graph neural network prediction model is trained based on the third data and the adjacency matrix to obtain the target graph neural network prediction model, including: extracting features of the third data based on the graph attention network layer of the initial graph neural network prediction model to obtain a first feature vector; forward propagating the first feature vector to obtain a prediction result; adjusting the model parameters of the initial graph neural network prediction model based on a preset loss function, the adjacency matrix and the prediction result to obtain a target graph neural network prediction model.
[0164] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0165] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: obtaining a target data set, wherein the target data set is used to represent the traffic flow data of a preset traffic route within a preset historical time period, and the preset historical time period includes the date of the day before the current date, and any date of the week before the current date; using a target graph neural network prediction model to predict the traffic flow of the target data set to obtain a prediction result, wherein the target graph neural network prediction model is obtained based on adjacency matrix training, and the prediction result is used to predict the traffic flow of the current date, and the adjacency matrix is constructed based on the topological structure of the traffic network, and any element in the adjacency matrix represents the degree of interaction between two locations.
[0166] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: obtaining first data, wherein the first data is used to represent traffic flow data of a preset traffic route within a preset time period, and the time of the preset time period is earlier than the current date; performing data slicing processing on the first data based on a preset slicing strategy to obtain second data, wherein the preset slicing strategy is used to perform data slicing on the first data according to the slicing time interval; performing data splicing processing on the second data to obtain third data; training an initial graph neural network prediction model based on the third data and the adjacency matrix to obtain a target graph neural network prediction model.
[0167] When executed on a data processing device, it is also suitable for executing a program that initializes the following method steps: obtaining fourth data; filtering the fourth data based on a preset filtering strategy to obtain filtered data; and performing data elimination processing on the filtered data to obtain first data.
[0168] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: filtering the first data based on the starting place information to obtain the fifth data; grouping the fifth data based on the location number to obtain the sixth data, wherein the data with the same location number in the sixth data are in the same group; and slicing the sixth data based on the slicing time interval to obtain the second data.
[0169] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: extracting the starting flow data in the second data to obtain a flow sequence; constructing a flow matrix based on the flow sequence; and splicing the flow matrix based on the location number to obtain the third data.
[0170] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: training an initial graph neural network prediction model based on third data and an adjacency matrix to obtain a target graph neural network prediction model, including: extracting features of the third data based on the graph attention network layer of the initial graph neural network prediction model to obtain a first eigenvector; forward propagating the first eigenvector to obtain a prediction result; adjusting the model parameters of the initial graph neural network prediction model based on a preset loss function, an adjacency matrix and a prediction result to obtain a target graph neural network prediction model.
[0171] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0172] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0173] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0174] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0175] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0176] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0177] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0178] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0179] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0180] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A traffic flow prediction method, characterized in that: The method comprises: Acquire a target data set, wherein the target data set is used to represent traffic flow data of a preset traffic route within a preset historical time period, and the preset historical time period includes a date one day before a current date and any date one week before the current date; A target graph neural network prediction model is used to predict traffic flow on the target data set to obtain a prediction result, wherein the target graph neural network prediction model is trained based on an adjacency matrix, and the prediction result is used to predict the traffic flow on the current date. The adjacency matrix is constructed based on the topological structure of the traffic network, and any element in the adjacency matrix represents the degree of interaction between two locations.
2. The method according to claim 1, characterized in that The method further comprises: Acquire first data, wherein the first data is used to represent traffic flow data of the preset traffic route within a preset time period, and the time of the preset time period is earlier than the current date; Performing data sharding processing on the first data based on a preset sharding strategy to obtain second data, wherein the preset sharding strategy is used to perform data sharding on the first data according to sharding time intervals; Performing data splicing processing on the second data to obtain third data; The initial graph neural network prediction model is trained based on the third data and the adjacency matrix to obtain the target graph neural network prediction model.
3. The method according to claim 2, characterized in that The obtaining of the first data comprises: Acquiring fourth data; Performing screening processing on the fourth data based on a preset screening strategy to obtain screening data; The screened data is subjected to data elimination processing to obtain the first data.
4. The method according to claim 2, characterized in that: The performing data slicing processing on the first data based on the preset slicing strategy to obtain the second data includes: Filter the first data based on the starting place information to obtain fifth data; Grouping the fifth data based on the location number to obtain sixth data, wherein data with the same location number in the sixth data are in the same group; The sixth data is sliced based on the slice time interval to obtain the second data.
5. The method according to claim 4, characterized in that The performing data splicing processing on the second data to obtain the third data comprises: Extracting the starting flow data in the second data to obtain a flow sequence; constructing a traffic matrix based on the traffic sequence; The traffic matrix is spliced based on the location number to obtain the third data.
6. The method according to any one of claims 2 to 5, characterized in that The training of the initial graph neural network prediction model based on the third data and the adjacency matrix to obtain the target graph neural network prediction model includes: Performing feature extraction on the third data based on the graph attention network layer of the initial graph neural network prediction model to obtain a first feature vector; Performing forward propagation on the first feature vector to obtain a prediction result; Based on the preset loss function, the adjacency matrix and the prediction result, the model parameters of the initial graph neural network prediction model are adjusted to obtain the target graph neural network prediction model.
7. A traffic flow prediction device, characterized in that: The device comprises: An acquisition module, used for acquiring a target data set, wherein the target data set is used for representing traffic flow data of a preset traffic route within a preset historical time period, wherein the preset historical time period includes the date of the day before the current date, and any date of the week before the current date; A prediction module is used to use a target graph neural network prediction model to predict the traffic flow of the target data set to obtain a prediction result, wherein the target graph neural network prediction model is trained based on an adjacency matrix, and the prediction result is used to predict the traffic flow on the current date. The adjacency matrix is constructed based on the topological structure of the traffic network, and any element in the adjacency matrix represents the degree of interaction between two locations.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the traffic flow prediction method described in any one of claims 1 to 6 when running on a computer or a processor.
9. A computer program product, characterized in that The invention comprises a computer program, which implements the traffic flow prediction method described in any one of claims 1 to 6 when being executed by a processor.
10. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to run the computer program to execute the traffic flow prediction method described in any one of claims 1 to 6.