Traffic Flow Prediction Method, Device, Equipment and Medium Based on Spatiotemporal Data
The method of adjusting model parameters through space-time embedding networks and optimizers solves the problem that the existing technology cannot effectively capture the dynamic characteristics of the current time period, and improves the reliability and accuracy of traffic flow prediction.
Patent Information
- Application Number
- CN202510228756.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2045-02-28
AI Technical Summary
The prior art cannot effectively capture the dynamic characteristics of the current time period, resulting in the traffic flow prediction being unreliable enough.
By obtaining and dividing the traffic flow data set into training set, verification set and test set, the preset input information is processed using the spatiotemporal embedding network to generate predicted traffic flow, and adjusting the model parameters through the optimizer to reduce the loss value, and finally generating the predicted traffic flow for the next time of the current time period when the preset evaluation index conditions are met.
Improves the reliability of traffic flow forecasts, captures dynamic characteristics of the current time period, and reduces the impact of manual intervention.
Smart Images

Figure CN119723895B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of traffic prediction and information technology, and particularly to a traffic flow prediction method, device, equipment and medium based on spatio-temporal data. Background Art
[0002] In the process of urbanization development, the urban road network bears increasingly severe load pressure, resulting in a significant reduction in its carrying capacity and traffic efficiency, seriously restricting the development of the city. In order to improve the traffic efficiency of the city, it is necessary to obtain predicted traffic flow. By predicting the traffic flow, potential traffic bottlenecks and congestion points can be identified, so that timely and effective measures can be taken to maximize the traffic capacity of the road.
[0003] However, the dynamic characteristics of the current time period change with time, and the prediction models of the prior art cannot capture the dynamic characteristics of the current time period. Therefore, the predicted traffic flow generated by the prediction models of the prior art is not reliable enough. Therefore, how to predict traffic flow based on spatio-temporal data is an urgent problem to be solved. Summary of the Invention
[0004] The present invention provides a traffic flow prediction method, device, computer equipment and storage medium based on spatio-temporal data to solve the technical problem of how to predict traffic flow based on spatio-temporal data.
[0005] In a first aspect, a traffic flow prediction method based on spatio-temporal data is provided, including:
[0006] Obtain a traffic flow data set, and divide the traffic flow data set into a training set, a validation set and a test set;
[0007] In the training set, determine preset input information based on preset traffic flow, preset spatio-temporal data, and a preset road network topology map for a preset time period;
[0008] Process the preset input information through a preset spatio-temporal embedding network to generate predicted traffic flow for the next time period of the preset time period;
[0009] Obtain a loss value between the predicted traffic flow and the actual traffic flow for the next time period of the preset time period;
[0010] Control an optimizer to adjust the model parameters of the spatio-temporal embedding network, and select, according to the loss value and a predefined method, the spatio-temporal embedding network using the adjusted model parameters as a traffic flow prediction model;
[0011] Obtain the evaluation metric values of the traffic flow prediction model on the validation set and the test set. When the evaluation metric values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology map in the current time period, determine the current input information, and process the current input information through the traffic flow prediction model to generate the predicted traffic flow for the next time period in the current time period.
[0012] Further, in the training set, determining the preset input information based on the preset traffic flow, preset spatio-temporal data, and preset road network topology map in the preset time period includes:
[0013] In the training set, obtain the preset traffic flow, preset spatio-temporal data, and preset road network topology map in the preset time period. Combine the weather information, week information, time point information, holiday information, and number of time slices per day in the preset spatio-temporal data to form the preset time information data. Combine the index information of sensor nodes in space and the index information of urban hotspots in space in the preset spatio-temporal data to form the preset space information data;
[0014] Extract features from the preset traffic flow to obtain the first feature, extract features from the preset time information data to obtain the second feature, extract features from the preset space information data to obtain the third feature, extract features from the preset road network topology map to obtain the fourth feature, splice the first feature, the second feature, the third feature, and the fourth feature to obtain the fifth feature, and select the fifth feature as the preset input information.
[0015] Further, processing the preset input information through a preset spatio-temporal embedding network to generate the predicted traffic flow for the next time period in the preset time period includes:
[0016] Load the preset spatio-temporal embedding network and input the preset input information into the spatio-temporal embedding network;
[0017] Process the preset input information through the spatio-temporal embedding network to generate the predicted traffic flow for the next time period in the preset time period.
[0018] Further, obtaining the loss value between the predicted traffic flow and the actual traffic flow for the next time period in the preset time period includes:
[0019] Obtain the actual traffic flow for the next time period in the preset time period;
[0020] Obtain the difference between the predicted traffic flow and the actual traffic flow for the next time period in the preset time period, and select the absolute value of the difference as the loss value.
[0021] Further, the control optimizer adjusts the model parameters of the spatio-temporal embedding network, and selects the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model according to the loss value and a predefined manner, including:
[0022] The control optimizer adjusts the model parameters of the spatio-temporal embedding network;
[0023] When the loss value is the minimum value, stop adjusting the model parameters, save the adjusted model parameters, and select the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model.
[0024] Further, obtain the evaluation index values of the traffic flow prediction model on the validation set and the test set. When the evaluation index values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology map in the current time period, determine the current input information, and process the current input information through the traffic flow prediction model to generate the predicted traffic flow in the next time period of the current time period, including:
[0025] Obtain the evaluation index values of the traffic flow prediction model on the validation set and the test set, where the evaluation index values include the values of the mean absolute error, the mean absolute percentage error, and the root mean square error;
[0026] When the values of the mean absolute error, the mean absolute percentage error, and the root mean square error are all less than the preset threshold, obtain the current traffic flow, current spatio-temporal data, and current road network topology map in the current time period. Combine the weather information, week information, time point information, holiday information, and number of time slices per day in the current spatio-temporal data to form the current time information data. Combine the index information of the sensor nodes in space and the index information of the urban hotspots in space in the current spatio-temporal data to form the current space information data;
[0027] Extract features from the current traffic flow to obtain the sixth feature, extract features from the current time information data to obtain the seventh feature, extract features from the current space information data to obtain the eighth feature, extract features from the current road network topology map to obtain the ninth feature, splice the sixth feature, the seventh feature, the eighth feature, and the ninth feature to obtain the tenth feature, select the tenth feature as the current input information, input the current input information into the traffic flow prediction model, and process the current input information through the traffic flow prediction model to generate the predicted traffic flow in the next time period of the current time period.
[0028] Further, after obtaining the evaluation metric values of the traffic flow prediction model on the validation set and the test set, when the evaluation metric values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology of the current time period, determining the current input information, and processing the current input information through the traffic flow prediction model to generate the predicted traffic flow for the next time period of the current time period, the traffic flow prediction method includes:
[0029] Obtain a display page, create a display window for the display page, and display the predicted traffic flow for the next time period of the current time period through the display window.
[0030] In a second aspect, a traffic flow prediction device based on spatio-temporal data is provided, including:
[0031] A first acquisition module for acquiring a traffic flow data set and dividing the traffic flow data set into a training set, a validation set, and a test set;
[0032] A second acquisition module for determining preset input information based on the preset traffic flow, preset spatio-temporal data, and preset road network topology of a preset time period in the training set;
[0033] A first generation module for processing the preset input information through a preset spatio-temporal embedding network to generate the predicted traffic flow for the next time period of the preset time period;
[0034] A third acquisition module for obtaining the loss value between the predicted traffic flow and the actual traffic flow for the next time period of the preset time period;
[0035] An adjustment module for controlling an optimizer to adjust the model parameters of the spatio-temporal embedding network, and selecting the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model according to the loss value and a predefined manner;
[0036] A second generation module for obtaining the evaluation metric values of the traffic flow prediction model on the validation set and the test set, and when the evaluation metric values meet the preset conditions, determining the current input information based on the current traffic flow, current spatio-temporal data, and current road network topology of the current time period, and processing the current input information through the traffic flow prediction model to generate the predicted traffic flow for the next time period of the current time period.
[0037] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the steps of the above traffic flow prediction method are implemented.
[0038] Fourthly, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above traffic flow prediction method are implemented.
[0039] This application provides a traffic flow prediction method, device, computer device, and storage medium based on spatio-temporal data. The beneficial effects are in two aspects. On the one hand, the evaluation index values of the traffic flow prediction model on the validation set and the test set are obtained. When the evaluation index values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology map in the current time period, the current input information is determined, and the current input information is processed through the traffic flow prediction model to generate the predicted traffic flow in the next time period of the current time period. Since the current traffic flow, current spatio-temporal data, and current road network topology map are all dynamic characteristics of the current time period, the traffic flow prediction model can capture the dynamic characteristics of the current time period, so it is beneficial to improve the reliability of the predicted traffic flow in the next time period of the current time period. On the other hand, since the traffic flow prediction model is not affected by manual intervention, it is beneficial to improve the reliability of the predicted traffic flow in the next time period of the current time period. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments of the present invention. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0041] Figure 1 It is a schematic diagram of an application environment of the traffic flow prediction method in an embodiment of the present invention;
[0042] Figure 2 It is a schematic flowchart of a traffic flow prediction method provided by an embodiment of the present invention;
[0043] Figure 3 is Figure 2 a schematic flowchart of a specific implementation manner of step S23 in;
[0044] Figure 4 is Figure 2 a schematic flowchart of a specific implementation manner of step S25 in;
[0045] Figure 5 is Figure 2 a schematic flowchart of a specific implementation manner of step S26 in;
[0046] Figure 6It is a schematic structural diagram of a traffic flow prediction device in an embodiment of the present invention;
[0047] Figure 7 It is a schematic structural diagram of a computer device in an embodiment of the present invention. Detailed implementation manners
[0048] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0049] Please refer to Figure 1 , Figure 1 It is a schematic application environment diagram of a traffic flow prediction method in an embodiment of the present invention. The traffic flow prediction method provided by the embodiments of the present invention can be applied in an application environment such as Figure 1 , where the client communicates with the server through a network.
[0050] The server obtains a traffic flow data set through the client, and divides the traffic flow data set into a training set, a validation set, and a test set;
[0051] In the training set, based on the preset traffic flow, preset spatio-temporal data, and preset road network topology map in a preset time period, determine the preset input information;
[0052] Process the preset input information through a preset spatio-temporal embedding network to generate the predicted traffic flow for the next time period of the preset time period;
[0053] Obtain the loss value between the predicted traffic flow and the actual traffic flow for the next time period of the preset time period;
[0054] Control the optimizer to adjust the model parameters of the spatio-temporal embedding network, and select the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model according to the loss value and a predefined method;
[0055] Obtain the evaluation index values of the traffic flow prediction model on the validation set and the test set. When the evaluation index values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology map in the current time period, determine the current input information, and process the current input information through the traffic flow prediction model to generate the predicted traffic flow for the next time period of the current time period.
[0056] In the solutions implemented by the above traffic flow prediction method, device, equipment, and medium, the beneficial effects are in two aspects. On the one hand, obtain the evaluation index values of the traffic flow prediction model on the validation set and the test set. When the evaluation index values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology in the current time period, determine the current input information, and through the traffic flow prediction model, process the current input information to generate the predicted traffic flow for the next time period in the current time period. Since the current traffic flow, current spatio-temporal data, and current road network topology are all dynamic features of the current time period, the traffic flow prediction model can capture the dynamic features of the current time period, so it is beneficial to improve the reliability of the predicted traffic flow for the next time period in the current time period. On the other hand, since the traffic flow prediction model is not affected by manual intervention, it is beneficial to improve the reliability of the predicted traffic flow for the next time period in the current time period.
[0057] Among them, the device running the client is simply referred to as: client device.
[0058] Among them, the device running the server is simply referred to as: server device.
[0059] Among them, the client device includes but is not limited to smart phones, personal computers, vehicle networking terminals, tablet computers, and portable wearable devices.
[0060] Among them, the server device can be implemented by an independent server or a server cluster composed of multiple servers. The present invention will be described in detail through specific embodiments. Please refer to Figure 2 , Figure 2 FIG. is a schematic flowchart of a traffic flow prediction method provided by an embodiment of the present invention, including the following steps:
[0061] S21, obtain a traffic flow data set, and divide the traffic flow data set into a training set, a validation set, and a test set;
[0062] Exemplarily, obtaining a traffic flow data set and dividing the traffic flow data set into a training set, a validation set, and a test set includes:
[0063] Access the data set website, obtain the traffic flow data set from the data set website, and divide the traffic flow data set into a training set, a validation set, and a test set according to a preset ratio.
[0064] For example, when the preset ratio is 6:2:2, divide the traffic flow data set into a training set, a validation set, and a test set in the ratio of 6:2:2.
[0065] For example, when the preset ratio is 7:2:1, divide the traffic flow data set into a training set, a validation set, and a test set in the ratio of 7:2:1.
[0066] Among them, the traffic flow dataset refers to a dataset specifically collected and organized to describe and analyze information related to road traffic flow. The traffic flow dataset usually covers the number, type, and speed of vehicles passing through a certain road section, intersection, or the entire traffic network within a specific time period.
[0067] S22. In the training set, based on the preset traffic flow, preset spatio-temporal data, and preset road network topology map for a preset time period, determine the preset input information;
[0068] Among them, the preset traffic flow is the preset traffic flow;
[0069] Among them, the preset spatio-temporal data is the preset spatio-temporal data;
[0070] Among them, the preset road network topology map is the preset road network topology map.
[0071] Among them, spatio-temporal data refers to data containing time attributes and space attributes.
[0072] Among them, traffic flow is the number of vehicles passing through a certain road section, intersection, or traffic node. Traffic flow is a key parameter for measuring the road traffic condition, and traffic flow reflects the traffic capacity of the road.
[0073] Among them, the road network topology map is a graphical representation method used to describe the intersections, section start points, and section end points in the road network, as well as the structural diagram of the connection relationships between intersections, section start points, and section end points. The road network topology map intuitively shows the layout and connection mode of the road network, enabling managers, planners, and researchers to more easily understand and analyze the structural characteristics of the road network.
[0074] Among them, the step of determining the preset input information based on the preset traffic flow, preset spatio-temporal data, and preset road network topology map for a preset time period in the training set includes:
[0075] In the training set, obtain the preset traffic flow, preset spatio-temporal data, and preset road network topology map for a preset time period. Combine the weather information, week information, time point information, holiday information, and number of time slices per day in the preset spatio-temporal data to form the preset time information data, and combine the index information of sensor nodes in space and the index information of urban hotspots in space in the preset spatio-temporal data to form the preset space information data;
[0076] Extract features from the preset traffic flow to obtain the first feature, extract features from the preset time information data to obtain the second feature, extract features from the preset spatial information data to obtain the third feature, extract features from the preset road network topology map to obtain the fourth feature, splice the first feature, the second feature, the third feature, and the fourth feature to obtain the fifth feature, and select the fifth feature as the preset input information.
[0077] Among them, extracting features from the preset road network topology map to obtain the fourth feature, splicing the first feature, the second feature, the third feature, and the fourth feature to obtain the fifth feature, and selecting the fifth feature as the preset input information can significantly increase the amount of information input into the spatio-temporal embedding network, enabling the spatio-temporal embedding network to capture richer data features, thereby improving the prediction ability and accuracy of the spatio-temporal embedding network.
[0078] Exemplarily, a dynamic feature enhancement module is used to extract features from the preset traffic flow to obtain the first feature.
[0079] Among them, the English name of the dynamic feature enhancement module is: Dynamic Feature Enhancement Module. The dynamic feature enhancement module can enhance key features according to the characteristics of the input data by dynamically adjusting its internal parameters. This adaptability enables the dynamic feature enhancement module to extract richer and more useful feature information when processing different modalities or different qualities of image data.
[0080] Among them, the week information, that is, the division of each day in a week, has a significant impact on the traffic flow. This impact is mainly reflected in people's work, life, and travel habits, thereby causing periodic changes in the traffic flow. On the one hand, on weekdays, that is, from Monday to Friday, since most people need to go to work or school, the traffic flow during the morning and evening rush hours will be relatively high. During these periods, people travel concentratedly, resulting in road congestion and a significant increase in traffic flow. In addition, during the lunchtime on weekdays, there may also be a small-scale traffic flow peak because some people will choose to go out for meals or carry out other activities at this time. On the other hand, on weekends, that is, Saturday and Sunday, people's travel habits usually change. Due to the absence of work or study pressure, many people will choose to carry out leisure activities on weekends, such as shopping, traveling, visiting relatives and friends, etc. These activities often lead to an increase in traffic flow in certain areas of the city, especially near commercial centers, tourist attractions, and transportation hubs. However, compared with weekdays, the overall traffic flow on weekends may be relatively low because some people will choose to stay at home and rest or carry out other indoor activities.
[0081] Among them, weather information refers to various meteorological changes occurring in the atmosphere within a certain area and within a certain period of time, including temperature, humidity, air pressure, precipitation, wind, cloud and other conditions. For traffic flow, weather information has a significant impact. On the one hand, adverse weather conditions, such as heavy rain, strong wind, and thick fog, will directly affect the road traffic capacity, reduce the vehicle driving speed, thereby increasing the risk of traffic accidents and resulting in a decrease in traffic flow. For example, the road surface is slippery on rainy days, and drivers need to increase the braking distance and maintain a larger headway, which will reduce the road traffic efficiency. At the same time, thick fog weather will reduce visibility, limit the driver's line of sight, and further exacerbate traffic congestion.
[0082] Among them, the time point information refers to time markers, such as a certain hour or minute of a day. Taking the time points in a day as an example, for the morning rush hour to work, it is usually from 7:00 to 9:00, and for the evening rush hour to leave work, it is usually from 17:00 to 19:00. The morning rush hour to work and the evening rush hour to leave work are the times when the urban traffic flow is the most intensive. During these two time periods, a large number of residents travel concentratedly, resulting in road congestion, high occupancy rates of public transportation, and even possible traffic paralysis. On the contrary, during the non-peak period from midnight to early morning, the traffic flow will decrease significantly, and the road will become relatively unobstructed.
[0083] Among them, holiday information refers to the dates recognized as public holidays or celebration dates, such as the Spring Festival, National Day, Mid-Autumn Festival, etc. These holidays have a significant and predictable impact on traffic flow. For example, the day before the holiday, the first day of the holiday, and the last day of the holiday are usually the times when the traffic flow is the most intensive. For example, on the afternoon before the National Day holiday and the morning of the first day of the holiday, there will be a large number of outbound vehicle and pedestrian flows around highways and railway stations; while on the last day of the holiday, there will be a large number of return vehicle and pedestrian flows, all of which will bring serious pressure to the traffic and may lead to traffic congestion and delays.
[0084] Among them, the number of time slices per day refers to the number of dividing the 24-hour time of a day into several consecutive time periods. For example, dividing a day into 24 one-hour time slices to analyze the traffic conditions per hour; for example, dividing a day into 48 time slices to analyze the traffic conditions every half hour.
[0085] Demonstratively, feature extraction is performed on the preset traffic flow to obtain the first feature, including:
[0086] The preset traffic flow is normalized to obtain the normalized preset traffic flow.
[0087] Feature extraction is performed on the normalized preset traffic flow to obtain the first feature.
[0088] Among them, the preprocessing operation adopts the Min-Max normalization method, and transforms the preset traffic flow:
[0089] ;
[0090] Among them, represents the corresponding normalized preset traffic flow, represents the preset traffic flow at the k-th time step, is the value of the preset traffic flow, N is the total number of time steps of the preset traffic flow, and the value range of j is between 1 and N time steps. The normalized preset traffic flow obtained is regarded as a spatio-temporal sequence.
[0091] Among them, represents the minimum value function. By traversing the given set of numerical values, the minimum value function can return the minimum value in the set of numerical values.
[0092] Among them, represents the maximum value function. By traversing the given set of numerical values, the maximum value function can return the maximum value in the set of numerical values.
[0093] Among them, the magnitude differences of different features may cause the gradient to show imbalance during update, which in turn affects the convergence efficiency of the model. Normalization processing can eliminate this magnitude difference, making all features have similar contribution degrees during the training process of the spatio-temporal embedding network, thus accelerating the convergence process of the spatio-temporal embedding network.
[0094] S23, process the preset input information through a preset spatio-temporal embedding network to generate the predicted traffic flow for the next time period of the preset time period;
[0095] Among them, the spatio-temporal embedding network is a network model that integrates time and space information. In the spatio-temporal embedding network, nodes not only represent entities or objects, but also carry their positions and attributes in time and space. This network captures and represents the dynamic changes of entities or objects in time and space by constructing complex relationships between nodes.
[0096] S24, obtain the loss value between the predicted traffic flow and the actual traffic flow for the next time period of the preset time period;
[0097] Among them, the next time period of the preset time period refers to the next time period immediately following the preset time period in chronological order. For example, if the preset time period is 2 am, then the next time period is 3 am. For example, if the preset time period is 4 am, then the next time period is 5 am.
[0098] Among them, obtaining the loss value between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period includes:
[0099] Obtaining the actual traffic flow in the next time period of the preset time period;
[0100] Obtaining the difference between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period, and selecting the absolute value of the difference as the loss value.
[0101] Among them, the predicted traffic flow in the next time period of the preset time period is the predicted traffic flow in the next time period of the preset time period.
[0102] Among them, the loss value is used to measure the degree of difference between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period. The larger the loss value, the greater the degree of difference between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period. The smaller the loss value, the smaller the degree of difference between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period.
[0103] S25, controlling the optimizer to adjust the model parameters of the spatio-temporal embedding network, and selecting the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model according to the loss value and the predefined method;
[0104] Among them, the adjusted model parameters have been optimized on the training set. Selecting the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model enables the traffic flow prediction model to learn general features and laws, thus having a high generalization ability.
[0105] S26, obtaining the evaluation index values of the traffic flow prediction model on the validation set and the test set. When the evaluation index values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology map in the current time period, determining the current input information, and processing the current input information through the traffic flow prediction model to generate the predicted traffic flow in the next time period of the current time period.
[0106] Among them, the current traffic flow is the current traffic flow;
[0107] Among them, the current spatio-temporal data is the current spatio-temporal data;
[0108] Among them, the current road network topology map is the current road network topology map.
[0109] Among them, the predicted traffic flow in the next time period of the current time period is the predicted traffic flow in the next time period of the current time period.
[0110] Among them, when obtaining the evaluation metric values of the traffic flow prediction model on the validation set and the test set, and when the evaluation metric values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology of the current time period, the current input information is determined, and the current input information is processed through the traffic flow prediction model to generate the predicted traffic flow for the next time period of the current time period. After that, the traffic flow prediction method includes:
[0111] Obtain a display page, create a display window for the display page, and display the predicted traffic flow for the next time period of the current time period through the display window.
[0112] In the embodiments of the present invention, the beneficial effects are in two aspects. On the one hand, when obtaining the evaluation metric values of the traffic flow prediction model on the validation set and the test set, and when the evaluation metric values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology of the current time period, the current input information is determined, and the current input information is processed through the traffic flow prediction model to generate the predicted traffic flow for the next time period of the current time period. Since the current traffic flow, current spatio-temporal data, and current road network topology are all dynamic characteristics of the current time period, the traffic flow prediction model can capture the dynamic characteristics of the current time period, which is beneficial to improving the reliability of the predicted traffic flow for the next time period of the current time period. On the other hand, since the traffic flow prediction model is not affected by manual intervention, it is beneficial to improve the reliability of the predicted traffic flow for the next time period of the current time period.
[0113] Please refer to Figure 3 , Figure 3 is Figure 2 a schematic flowchart of a specific implementation manner of step S23 in
[0114] S31, load a preset spatio-temporal embedding network, and input the preset input information into the spatio-temporal embedding network;
[0115] S32, process the preset input information through the spatio-temporal embedding network to generate the predicted traffic flow for the next time period of the preset time period.
[0116] In the embodiments of the present invention, by processing the preset input information through the spatio-temporal embedding network to generate the predicted traffic flow for the next time period of the preset time period, and by comparing the predicted traffic flow for the next time period of the preset time period with the actual traffic flow, the accuracy and reliability of the spatio-temporal embedding network can be obtained, thereby guiding the further optimization of the spatio-temporal embedding network.
[0117] Please refer to Figure 4 , Figure 4 isFigure 2 A schematic flowchart of a specific implementation manner of step S25 in [the invention] is described in detail as follows:
[0118] S41, control the optimizer to adjust the model parameters of the spatio-temporal embedding network;
[0119] Optionally, the optimizer is the Adam optimizer. The full Chinese name of the Adam optimizer is: Adaptive Moment Estimation Optimizer, and the full English name is: Adaptive Moment Estimation. The Adam optimizer is a gradient descent optimization algorithm used in deep learning.
[0120] S42, when the loss value is the minimum value, stop adjusting the model parameters, save the adjusted model parameters, and select the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model.
[0121] In the embodiment of the present invention, when the loss value is the minimum value, it indicates that the spatio-temporal embedding network has learned the potential laws and features in the data as much as possible. Selecting the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model can ensure the stability and reliability of the traffic flow prediction model.
[0122] Please refer to Figure 5 , Figure 5 is Figure 2 A schematic flowchart of a specific implementation manner of step S26 in [the invention] is described in detail as follows:
[0123] S51, obtain the evaluation index values of the traffic flow prediction model on the validation set and the test set. The evaluation index values include the numerical value of the mean absolute error, the numerical value of the mean absolute percentage error, and the numerical value of the root mean square error;
[0124] S52, when the numerical values of the mean absolute error, the mean absolute percentage error, and the root mean square error are all less than the preset threshold, obtain the current traffic flow, current spatio-temporal data, and current road network topology map at the current time period. The weather information, week information, time point information, holiday information, and number of time slices per day in the current spatio-temporal data are composed into the current time information data, and the index information of the sensor nodes in space and the index information of the urban hotspots in space in the current spatio-temporal data are composed into the current space information data;
[0125] Among them, the index information of sensor nodes in space refers to the position coordinates of sensor nodes. Sensor nodes are usually deployed at key positions on roads, such as intersections, highway entrances, and highway exits, to collect vehicle speeds and vehicle types in real time. Through the index information of sensor nodes in space, the position of each sensor node can be accurately known, thereby ensuring that the collected data can accurately reflect the traffic conditions at the corresponding positions. In traffic flow prediction, by comprehensively considering the data of multiple sensor nodes, more comprehensive traffic condition information can be obtained.
[0126] Among them, urban hotspots refer to locations in the city that receive attention, have a large number of people gathering, and undertake important functions. Urban hotspots include, but are not limited to, parks, shopping centers, pedestrian streets, museums, theaters, schools, and art exhibition centers.
[0127] Among them, the index information of urban hotspots in space refers to the position coordinates used to accurately locate and describe each hotspot area within the city. Through the index information of urban hotspots in space, the specific position of each urban hotspot in the urban spatial layout can be clearly understood.
[0128] Among them, the index information of urban hotspots in space has a certain impact on traffic flow prediction. The index information of urban hotspots in space clarifies the position coordinates of urban hotspots within the city and also reveals the spatial relationship between urban hotspots and the urban traffic network. In traffic flow prediction, it is crucial to know the location of urban hotspots and their proximity to traffic nodes. For example, parks, shopping centers, pedestrian streets, museums, theaters, schools, and art exhibition centers usually attract a large number of people, resulting in a significant increase in traffic flow on the surrounding roads and public transportation facilities. Through the index information of urban hotspots in space, the traffic flow prediction model can more accurately simulate and predict the impact of these hotspot areas on traffic flow.
[0129] S53. Extract features from the current traffic flow to obtain the sixth feature, extract features from the current time information data to obtain the seventh feature, extract features from the current spatial information data to obtain the eighth feature, extract features from the current road network topology map to obtain the ninth feature, splice the sixth feature, the seventh feature, the eighth feature, and the ninth feature to obtain the tenth feature, select the tenth feature as the current input information, input the current input information into the traffic flow prediction model, and through the traffic flow prediction model, process the current input information to generate the predicted traffic flow for the next time period of the current time period.
[0130] Among them, the next time period of the current time period refers to the next time period immediately following the current time period in chronological order. For example, if the current time period is 11 am, then the next time period is 12 pm. For example, if the current time period is 12 pm, then the next time period is 1 pm.
[0131] Among them, the sixth feature, the seventh feature, the eighth feature, and the ninth feature are spliced to obtain the tenth feature, and the tenth feature is selected as the current input information. The current input information can significantly increase the amount of information input into the traffic flow prediction model, enabling the traffic flow prediction model to capture richer data features, thereby improving the prediction ability and accuracy of the traffic flow prediction model.
[0132] In the embodiment of the present invention, through the traffic flow prediction model, the current input information is processed to generate the predicted traffic flow for the next time period of the current time period. Since the current traffic flow, the current spatio-temporal data, and the current road network topology are all dynamic features of the current time period, the traffic flow prediction model can capture the dynamic features of the current time period, which is beneficial to improving the reliability of the predicted traffic flow for the next time period of the current time period.
[0133] Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of a traffic flow prediction device in an embodiment of the present invention. As Figure 6 shown, the traffic flow prediction device includes a first acquisition module 101, a second acquisition module 102, a first generation module 103, a third acquisition module 104, an adjustment module 105, and a second generation module 106. The detailed description of each functional module is as follows:
[0134] The first acquisition module 101 is used to acquire a traffic flow data set and divide the traffic flow data set into a training set, a validation set, and a test set;
[0135] The second acquisition module 102 is used to determine preset input information based on preset traffic flow, preset spatio-temporal data, and preset road network topology in the training set;
[0136] The first generation module 103 is used to process the preset input information through a preset spatio-temporal embedding network to generate the predicted traffic flow for the next time period of the preset time period;
[0137] The third acquisition module 104 is used to acquire the loss value between the predicted traffic flow and the actual traffic flow for the next time period of the preset time period;
[0138] An adjustment module 105 is configured to control the optimizer to adjust the model parameters of the spatio-temporal embedding network, and select the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model according to the loss value and a predefined manner;
[0139] A second generation module 106 is configured to obtain the evaluation metric values of the traffic flow prediction model on the validation set and the test set. When the evaluation metric values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology map in the current time period, determine the current input information, and process the current input information through the traffic flow prediction model to generate the predicted traffic flow in the next time period of the current time period.
[0140] In one embodiment, the second acquisition module 102 includes:
[0141] A first acquisition subunit is configured to acquire the preset traffic flow, preset spatio-temporal data, and preset road network topology map in a preset time period in the training set, form the preset time information data by combining the weather information, week information, time point information, holiday information, and number of time slices per day in the preset spatio-temporal data, and form the preset space information data by combining the index information of the sensor nodes in space and the index information of the urban hotspots in space in the preset spatio-temporal data;
[0142] A first extraction subunit is configured to extract features from the preset traffic flow to obtain a first feature, extract features from the preset time information data to obtain a second feature, extract features from the preset space information data to obtain a third feature, extract features from the preset road network topology map to obtain a fourth feature, splice the first feature, the second feature, the third feature, and the fourth feature to obtain a fifth feature, and select the fifth feature as the preset input information.
[0143] In one embodiment, the first generation module 103 includes:
[0144] A loading subunit is configured to load a preset spatio-temporal embedding network and input the preset input information into the spatio-temporal embedding network;
[0145] A first generation subunit is configured to process the preset input information through the spatio-temporal embedding network to generate the predicted traffic flow in the next time period of the preset time period.
[0146] In one embodiment, the third acquisition module 104 includes:
[0147] A second acquisition subunit is configured to acquire the actual traffic flow in the next time period of the preset time period;
[0148] A third acquisition subunit, configured to acquire the difference between the predicted traffic flow and the actual traffic flow in the next time period of a preset time period, and select the absolute value of the difference as the loss value.
[0149] In one embodiment, the adjustment module 105 includes:
[0150] An adjustment subunit, configured to control an optimizer to adjust the model parameters of the spatio-temporal embedding network;
[0151] A stop subunit, configured to stop adjusting the model parameters when the loss value is the minimum value, save the adjusted model parameters, and select the spatio-temporal embedding network using the adjusted model parameters as the traffic flow prediction model.
[0152] In one embodiment, the second generation module 106 includes:
[0153] A fourth acquisition subunit, configured to acquire the evaluation metric values of the traffic flow prediction model on a validation set and a test set, where the evaluation metric values include the value of the mean absolute error, the value of the mean absolute percentage error, and the value of the root mean square error;
[0154] A fifth acquisition subunit, configured to, when the value of the mean absolute error, the value of the mean absolute percentage error, and the value of the root mean square error are all less than a preset threshold, acquire the current traffic flow, current spatio-temporal data, and current road network topology map of the current time period, form the current time information data by using the weather information, week information, time point information, holiday information, and number of time slices per day in the current spatio-temporal data, and form the current space information data by using the index information of sensor nodes in space and the index information of urban hotspots in space in the current spatio-temporal data;
[0155] A second generation subunit, configured to perform feature extraction on the current traffic flow to obtain a sixth feature, perform feature extraction on the current time information data to obtain a seventh feature, perform feature extraction on the current space information data to obtain an eighth feature, perform feature extraction on the current road network topology map to obtain a ninth feature, splice the sixth feature, the seventh feature, the eighth feature, and the ninth feature to obtain a tenth feature, select the tenth feature as the current input information, input the current input information into the traffic flow prediction model, and process the current input information through the traffic flow prediction model to generate the predicted traffic flow in the next time period of the current time period.
[0156] In one embodiment, the traffic flow prediction device further includes:
[0157] A display module, configured to acquire a display page, create a display window of the display page, and display the predicted traffic flow in the next time period of the current time period through the display window.
[0158] In the embodiments of the present invention, the beneficial effects are in two aspects. On the one hand, the evaluation index values of the traffic flow prediction model on the validation set and the test set are obtained. When the evaluation index values meet the preset conditions, based on the current traffic flow, current spatio-temporal data, and current road network topology map in the current time period, the current input information is determined. Through the traffic flow prediction model, the current input information is processed to generate the predicted traffic flow for the next time period of the current time period. Since the current traffic flow, current spatio-temporal data, and current road network topology map are all dynamic characteristics of the current time period, the traffic flow prediction model can capture the dynamic characteristics of the current time period, which is beneficial to improving the reliability of the predicted traffic flow for the next time period of the current time period. On the other hand, since the traffic flow prediction model is not affected by manual intervention, it is beneficial to improve the reliability of the predicted traffic flow for the next time period of the current time period.
[0159] For the specific limitations of the traffic flow prediction device, reference can be made to the limitations of the traffic flow prediction method in the above text, which will not be elaborated here.
[0160] Each module in the above traffic flow prediction device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so as to facilitate the processor to call and execute the operations corresponding to the above respective modules.
[0161] Please refer to Figure 7 , Figure 7 which is another structural schematic diagram of a computer device in an embodiment of the present invention. In one embodiment, a computer device is provided. The computer device is a server device or a client device, and its internal structure diagram can be as Figure 7 shown. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with external devices. When the computer program is executed by the processor, it can implement the functions or steps of a traffic flow prediction method based on spatio-temporal data.
[0162] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor.
[0163] It should be noted that the functions or steps that can be implemented by the above computer-readable storage medium or computer device can be correspondingly referred to the relevant descriptions in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0164] The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU for short), a graphics processing unit (GPU for short), and a network processor (NP for short); it may also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0165] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure, enabling those skilled in the art to practice them. In this article, what each embodiment focuses on can be the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the methods and products disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, the relevant parts can be referred to the description of the method part.
[0166] Those skilled in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner can depend on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of the embodiments of the present disclosure. Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated here.
[0167] In the embodiments disclosed herein, the disclosed methods, products (including but not limited to devices, equipment) can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units can be merely a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some sub-samples can be ignored or not executed. Additionally, the couplings or direct couplings or communication connections shown or discussed among each other can be through some interfaces. The indirect couplings or communication connections of devices or units can be in electrical, mechanical, or other forms. The units described as separate components can be or can not be physically separated. The components shown as units can be or can not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to implement this embodiment. Additionally, in the embodiments of the present disclosure, each functional unit can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit.
[0168] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the block can occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, which can depend on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different blocks can also occur in a different order than disclosed in the description. Sometimes, there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, which can depend on the functions involved. Each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
Claims
1. A traffic flow prediction method based on spatiotemporal data, characterized in that: include: Obtain a traffic flow dataset, and divide the traffic flow dataset into a training set, a validation set, and a test set; In the training set, the preset traffic flow, preset spatiotemporal data, and preset road network topology map of the preset time period are obtained, and the weather information, week information, time point information, holiday information, and the number of time slices per day in the preset spatiotemporal data are combined into the preset time information data, and the spatial index information of the sensor nodes and the spatial index information of the city hotspots in the preset spatiotemporal data are combined into the preset spatial information data; Normalizing the preset traffic flow to obtain the normalized preset traffic flow, extracting features of the normalized preset traffic flow to obtain a first feature, extracting features of the preset time information data to obtain a second feature, extracting features of the preset spatial information data to obtain a third feature, extracting features of the preset road network topology map to obtain a fourth feature, concatenating the first feature, the second feature, the third feature, and the fourth feature to obtain a fifth feature, and selecting the fifth feature as the preset input information; The preset input information is processed by a preset spatiotemporal embedding network to generate a predicted traffic flow for the next time period of the preset time period; Obtaining a loss value between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period; The control optimizer adjusts the model parameters of the spatiotemporal embedding network, and selects the spatiotemporal embedding network using the adjusted model parameters as a traffic flow prediction model according to the loss value and a predefined method; The evaluation index value of the traffic flow prediction model on the validation set and the test set is obtained. When the evaluation index value meets the preset conditions, the current input information is determined based on the current traffic flow in the current time period, the current spatiotemporal data, and the current road network topology map. The current input information is processed through the traffic flow prediction model to generate the predicted traffic flow for the next time period of the current time period.
2. The traffic flow prediction method according to claim 1, characterized in that: The method of processing the preset input information through a preset spatiotemporal embedding network to generate a predicted traffic flow in the next time period of the preset time period includes: Loading a preset spatiotemporal embedding network, and inputting the preset input information into the spatiotemporal embedding network; The preset input information is processed through a spatiotemporal embedding network to generate a predicted traffic flow in the next time period of the preset time period.
3. The traffic flow prediction method according to claim 1, characterized in that: The step of obtaining the loss value between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period includes: Obtaining the actual traffic flow in the next time period of the preset time period; The difference between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period is obtained, and the absolute value of the difference is selected as the loss value.
4. The traffic flow prediction method according to claim 1, characterized in that: The control optimizer adjusts the model parameters of the spatiotemporal embedding network, and selects the spatiotemporal embedding network using the adjusted model parameters as a traffic flow prediction model according to the loss value and a predefined method, including: The control optimizer adjusts the model parameters of the spatiotemporal embedding network; When the loss value reaches the minimum value, the adjustment of the model parameters is stopped, the adjusted model parameters are saved, and the spatiotemporal embedding network using the adjusted model parameters is selected as the traffic flow prediction model.
5. The traffic flow prediction method according to claim 1, characterized in that: The step of obtaining the evaluation index value of the traffic flow prediction model on the validation set and the test set, and when the evaluation index value meets the preset conditions, determining the current input information based on the current traffic flow in the current time period, the current spatiotemporal data, and the current road network topology map, and processing the current input information through the traffic flow prediction model to generate the predicted traffic flow in the next time period of the current time period, includes: Obtaining evaluation index values of the traffic flow prediction model on the validation set and the test set, wherein the evaluation index values include a value of a mean absolute error, a value of a mean absolute percentage error, and a value of a root mean square error; When the values of the mean absolute error, the mean absolute percentage error, and the root mean square error are all less than the preset thresholds, the current traffic flow, the current spatiotemporal data, and the current road network topology map of the current time period are obtained, and the weather information, week information, time point information, holiday information, and the number of time slices per day in the current spatiotemporal data are combined into the current time information data, and the spatial index information of the sensor nodes and the spatial index information of the city hotspots in the current spatiotemporal data are combined into the current spatial information data; Perform feature extraction on the current traffic flow to obtain a sixth feature, perform feature extraction on the current time information data to obtain a seventh feature, perform feature extraction on the current spatial information data to obtain an eighth feature, perform feature extraction on the current road network topology map to obtain a ninth feature, concatenate the sixth feature, the seventh feature, the eighth feature, and the ninth feature to obtain a tenth feature, select the tenth feature as current input information, input the current input information into the traffic flow prediction model, process the current input information through the traffic flow prediction model, and generate a predicted traffic flow for the next time period of the current time period.
6. The traffic flow prediction method according to claim 1, characterized in that: In the step of obtaining the evaluation index value of the traffic flow prediction model on the validation set and the test set, when the evaluation index value meets the preset conditions, based on the current traffic flow in the current time period, the current spatiotemporal data, and the current road network topology map, the current input information is determined, and the current input information is processed by the traffic flow prediction model to generate the predicted traffic flow in the next time period of the current time period. The traffic flow prediction method includes: A display page is obtained, a display window of the display page is created, and the predicted traffic flow in the next time period of the current time period is displayed through the display window.
7. A traffic flow prediction device based on spatiotemporal data, characterized in that: include: The first acquisition module is used to acquire a traffic flow data set and divide the traffic flow data set into a training set, a validation set and a test set; A second acquisition module is used to obtain the preset traffic flow, preset spatiotemporal data, and preset road network topology map of the preset time period in the training set, combine the weather information, week information, time point information, holiday information, and the number of time slices per day in the preset spatiotemporal data into preset time information data, combine the spatial index information of sensor nodes and the spatial index information of urban hotspots in the preset spatiotemporal data into preset spatial information data, normalize the preset traffic flow to obtain the normalized preset traffic flow, perform feature extraction on the normalized preset traffic flow to obtain a first feature, perform feature extraction on the preset time information data to obtain a second feature, perform feature extraction on the preset spatial information data to obtain a third feature, perform feature extraction on the preset road network topology map to obtain a fourth feature, concatenate the first feature, the second feature, the third feature, and the fourth feature to obtain a fifth feature, and select the fifth feature as the preset input information; A first generating module is used to process the preset input information through a preset spatiotemporal embedding network to generate a predicted traffic flow in the next time period of the preset time period; A third acquisition module is used to obtain a loss value between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period; An adjustment module, used for controlling the optimizer to adjust the model parameters of the spatiotemporal embedding network, and selecting the spatiotemporal embedding network using the adjusted model parameters as a traffic flow prediction model according to the loss value and a predefined method; The second generation module is used to obtain the evaluation index value of the traffic flow prediction model on the verification set and the test set. When the evaluation index value meets the preset conditions, the current input information is determined based on the current traffic flow in the current time period, the current spatiotemporal data, and the current road network topology map. The current input information is processed through the traffic flow prediction model to generate the predicted traffic flow for the next time period of the current time period.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the traffic flow prediction method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the traffic flow prediction method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Traffic flow prediction method and device based on space-time sequence deep learning
CN117116045A