Traffic flow prediction method and device based on spatio-temporal data, equipment and medium
By using the method of adjusting model parameters using spatiotemporal embedding network and optimizer, the problem of insufficient traffic flow prediction in the prior art is solved, and more efficient traffic flow prediction and better dynamic feature capture are achieved.
Patent Information
- Application Number
- CN202510228756.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-03-28
- 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 input information is processed using the spatiotemporal embedding network, predicted traffic flow is generated, and model parameters are adjusted through the optimizer to reduce the loss value, and finally prediction is made 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 CN119723895A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of traffic prediction technology and information technology, and in particular to a traffic flow prediction method, device, equipment and medium based on spatiotemporal data. Background Art
[0002] In the process of urbanization, the urban road network is bearing increasingly severe load pressure, which has greatly reduced 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 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 will change over time, and the existing prediction model cannot capture the dynamic characteristics of the current time period. Therefore, the predicted traffic flow generated by the existing prediction model is not reliable enough. Therefore, how to predict traffic flow based on spatiotemporal 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 spatiotemporal data to solve the technical problem of how to predict traffic flow based on spatiotemporal data.
[0005] In a first aspect, a traffic flow prediction method based on spatiotemporal data is provided, comprising: 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 input information is determined based on the preset traffic flow, preset spatiotemporal data, and preset road network topology map in the preset time period; 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.
[0006] Furthermore, in the training set, based on the preset traffic flow, preset spatiotemporal data, and preset road network topology map in the preset time period, the preset input information is determined, including: 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; Perform feature extraction on the 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.
[0007] Furthermore, the preset input information is processed by a preset spatiotemporal embedding network to generate a predicted traffic flow in the next time period of the preset time period, including: 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.
[0008] Furthermore, 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.
[0009] Further, the control optimizer adjusts the model parameters of the spatiotemporal embedding network, and selects the spatiotemporal embedding network using the adjusted model parameters as the 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.
[0010] Furthermore, 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, the current spatiotemporal data, and the current road network topology map of the current time period. 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, including: 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.
[0011] Further, 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, 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, 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.
[0012] In a second aspect, a traffic flow prediction device based on spatiotemporal data is provided, comprising: 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 determine preset input information based on preset traffic flow, preset spatiotemporal data, and preset road network topology map in a preset time period in the training set; 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.
[0013] 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, wherein the processor implements the steps of the above-mentioned traffic flow prediction method when executing the computer program.
[0014] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned traffic flow prediction method are implemented.
[0015] The present application provides a traffic flow prediction method, device, computer equipment and storage medium based on spatiotemporal data, and the beneficial effects are in two aspects. On the one hand, the evaluation index value of the traffic flow prediction model on the verification 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, the current spatiotemporal data and the current road network topology map of the current time period. The current input information is processed by 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, the current spatiotemporal data and the 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 conducive 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 will not be affected by human intervention, it is conducive to improving the reliability of the predicted traffic flow for the next time period of the current time period. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0017] Figure 1 is a schematic diagram of an application environment of a traffic flow prediction method in one embodiment of the present invention; Figure 2 A flow chart of a traffic flow prediction method provided by an embodiment of the present invention; Figure 3 yes Figure 2 A schematic flow chart of a specific implementation of step S23; Figure 4 yes Figure 2 A schematic flow chart of a specific implementation of step S25; Figure 5 yes Figure 2 A schematic flow chart of a specific implementation of step S26; Figure 6 is a schematic diagram of the structure of a traffic flow prediction device in one embodiment of the present invention; Figure 7 It is a structural diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] See also Figure 1 , Figure 1 FIG. 1 is a schematic diagram of an application environment of a traffic flow prediction method according to an embodiment of the present invention. The traffic flow prediction method provided by the embodiment of the present invention can be applied in the following embodiments: Figure 1 In an application environment, a client communicates with a server through a network.
[0020] The server obtains the 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; In the training set, the preset input information is determined based on the preset traffic flow, preset spatiotemporal data, and preset road network topology map in the preset time period; 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.
[0021] In the scheme implemented by the above-mentioned traffic flow prediction method, device, equipment and medium, the beneficial effects are in two aspects. On the one hand, the evaluation index value of the traffic flow prediction model on the verification 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, current spatiotemporal data, and current road network topology map of the current time period. The current input information is processed by 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 spatiotemporal 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 conducive 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 will not be affected by human intervention, it is conducive to improving the reliability of the predicted traffic flow for the next time period of the current time period.
[0022] The device running the client is referred to as a client device.
[0023] The device running the server is referred to as the server device.
[0024] Among them, client devices include but are not limited to smartphones, personal computers, Internet of Vehicles terminals, tablets and portable wearable devices.
[0025] The server device may be implemented by an independent server or a server cluster composed of multiple servers. The present invention is described in detail below through specific embodiments. Figure 2 , Figure 2 A flow chart of a traffic flow prediction method provided by an embodiment of the present invention includes the following steps: S21, obtaining a traffic flow data set, and dividing the traffic flow data set into a training set, a validation set, and a test set; Exemplarily, a traffic flow data set is obtained, and the traffic flow data set is divided into a training set, a validation set, and a test set, including: Visit the dataset website, obtain the traffic flow dataset from the dataset website, and divide the traffic flow dataset into a training set, a validation set, and a test set according to a preset ratio.
[0026] For example, when the preset ratio is 6:2:2, the traffic flow dataset is divided into a training set, a validation set, and a test set in a ratio of 6:2:2.
[0027] For example, when the preset ratio is 7:2:1, the traffic flow dataset is divided into a training set, a validation set, and a test set in a ratio of 7:2:1.
[0028] Traffic flow datasets refer to datasets that are specially collected and collated for describing and analyzing road traffic flow related information. Traffic flow datasets usually cover the number, type, and speed of vehicles passing through a road section, intersection, or the entire traffic network within a specific time period.
[0029] S22, determining preset input information in the training set based on preset traffic flow, preset spatiotemporal data, and preset road network topology map in a preset time period; Wherein, the preset traffic flow is a preset traffic flow; Wherein, the preset spatiotemporal data is the preset spatiotemporal data; Among them, the preset road network topology map is a preset road network topology map.
[0030] Among them, spatiotemporal data refers to data that contains time attributes and space attributes.
[0031] 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 to measure road traffic conditions, and traffic flow reflects the road's capacity.
[0032] 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 relationship between intersections, section start points and section end points. The road network topology map shows the layout and connection mode of the road network in an intuitive way, making it easier for managers, planners and researchers to understand and analyze the structural characteristics of the road network.
[0033] Wherein, in the training set, based on the preset traffic flow, preset spatiotemporal data, and preset road network topology map in the preset time period, the preset input information is determined, including: 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; Perform feature extraction on the 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.
[0034] Among them, feature extraction is performed on the preset road network topology map to obtain the fourth feature, and the first feature, the second feature, the third feature, and the fourth feature are spliced to obtain the fifth feature. Selecting the fifth feature as the preset input information can significantly increase the amount of information input to the spatiotemporal embedding network, so that the spatiotemporal embedding network can capture richer data features, thereby improving the prediction ability and accuracy of the spatiotemporal embedding network.
[0035] Exemplarily, a dynamic feature enhancement module is used to extract features of a preset traffic flow to obtain a first feature.
[0036] 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 image data of different modalities or different qualities.
[0037] Among them, the week information, that is, the division of days in a week, has a significant impact on traffic flow. This impact is mainly reflected in people's work, life and travel habits, which in turn causes periodic changes in traffic flow. On the one hand, on weekdays, that is, Monday to Friday, since most people need to go to work or school, the traffic flow during peak hours in the morning and evening will be relatively high. During these periods, people travel in large numbers, resulting in road congestion and a significant increase in traffic flow. In addition, there may also be a small-scale traffic flow peak during the noon period on weekdays, because some people choose to go out for dinner or other activities during this period. On the other hand, on weekends, that is, Saturdays and Sundays, people's travel habits usually change. Without the pressure of work or study, many people choose to engage in 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 choose to rest at home or do other indoor activities.
[0038] Among them, weather information refers to various meteorological changes that occur in the atmosphere in a certain area within a certain period of time, including temperature, humidity, air pressure, precipitation, wind, clouds and other conditions. Weather information has a significant impact on traffic flow. On the one hand, severe weather conditions, such as heavy rain, strong winds, and dense fog, will directly affect road capacity and reduce vehicle speeds, thereby increasing the risk of traffic accidents and reducing traffic flow. For example, the road surface is slippery on rainy days, and drivers need to increase braking distances and maintain a larger head-to-head distance, which will reduce road traffic efficiency. At the same time, dense fog will reduce visibility, limiting the driver's line of sight and further exacerbating traffic congestion.
[0039] Among them, time point information refers to time markers, such as a certain hour or minute of the day. Taking the time point of the day as an example, the morning rush hour is usually from 7 to 9 o'clock, and the evening rush hour is usually from 17 to 19 o'clock. The morning rush hour and the evening rush hour are the times when urban traffic flow is the most intensive. During these two time periods, a large number of residents travel together, resulting in road congestion, high public transportation load rates, and even possible traffic paralysis. On the contrary, during the non-peak hours from midnight to early morning, traffic flow will be significantly reduced and the roads will become relatively smooth.
[0040] Among them, holiday information refers to specific dates that are identified as dates for public rest or celebration, 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 traffic flow is the most concentrated. For example, on the afternoon before the National Day holiday and the morning of the first day, there will be a large number of outbound vehicles and people around the highway and railway station; and on the last day of the holiday, there will be a large number of return vehicles and people, all of which will bring serious pressure to traffic and may cause traffic congestion and delays.
[0041] The number of time slices per day refers to the number of consecutive time periods into which the 24 hours of a day are divided. For example, a day is divided into 24 one-hour time slices to analyze the traffic conditions every hour; for example, a day is divided into 48 time slices to analyze the traffic conditions every half hour.
[0042] In an exemplary manner, feature extraction is performed on the preset traffic flow to obtain a first feature, including: The preset traffic flow is normalized to obtain the normalized preset traffic flow. The normalized preset traffic flow is subjected to feature extraction to obtain a first feature.
[0043] The preprocessing operation adopts the Min-Max standardization method, which transforms the preset traffic flow: ; in, represents the corresponding normalized preset traffic flow, represents the preset traffic flow at the kth 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 of j ranges from 1 to N time steps. The normalized preset traffic flow is regarded as a spatiotemporal sequence.
[0044] in, Represents the minimum function, which can return the minimum value in a given set of values by traversing the given set of values.
[0045] in, Represents the maximum value function. The maximum value function can return the maximum value in a given set of values by traversing the given set of values.
[0046] Among them, the magnitude difference of different features may cause the gradient to be unbalanced during updating, which in turn affects the convergence efficiency of the model. The normalization process can eliminate this magnitude difference, so that all features have similar contributions during the training process of the spatiotemporal embedding network, thereby accelerating the convergence process of the spatiotemporal embedding network.
[0047] S23, 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; Among them, the spatiotemporal embedding network is a network model that integrates time and space information. In the spatiotemporal 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.
[0048] S24, 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 next time period of the preset time period refers to the next time period immediately following the preset time period in the time sequence. For example, if the preset time period is 2 a.m., then the next time period is 3 a.m. For example, if the preset time period is 4 a.m., then the next time period is 5 a.m.
[0049] 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.
[0050] 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.
[0051] Among them, the loss value is used to measure the difference between the predicted traffic flow in the next time period of the preset time period and the actual traffic flow. The larger the loss value, the greater the difference between the predicted traffic flow in the next time period of the preset time period and the actual traffic flow. The smaller the loss value, the smaller the difference between the predicted traffic flow in the next time period of the preset time period and the actual traffic flow.
[0052] S25, 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; Among them, the adjusted model parameters have been optimized on the training set, and the spatiotemporal embedding network using the adjusted model parameters is selected as the traffic flow prediction model, which enables the traffic flow prediction model to learn common features and rules, thereby having a higher generalization ability.
[0053] S26, 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, 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.
[0054] Among them, current traffic flow is the current traffic flow; Among them, current spatiotemporal data is the current spatiotemporal data; Among them, the current road network topology map is the current road network topology map.
[0055] 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.
[0056] Wherein, 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.
[0057] In the embodiment of the present invention, the beneficial effects lie in two aspects. On the one hand, the evaluation index value of the traffic flow prediction model on the verification 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, the current spatiotemporal data, and the current road network topology map of the current time period. The current input information is processed by 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, the current spatiotemporal data, and the current road network topology map 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. On the other hand, since the traffic flow prediction model will not be affected by human intervention, it is beneficial to improving the reliability of the predicted traffic flow for the next time period of the current time period.
[0058] See also Figure 3 , Figure 3 yes Figure 2 A specific implementation flow diagram of step S23 is described in detail as follows: S31, loading a preset spatiotemporal embedding network, and inputting the preset input information into the spatiotemporal embedding network; S32, processing the preset input information through a spatiotemporal embedding network to generate a predicted traffic flow in the next time period of the preset time period.
[0059] In an embodiment of the present invention, the preset input information is processed through a spatiotemporal embedding network to generate a predicted traffic flow for the next time period of the preset time period. 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 spatiotemporal embedding network can be improved, thereby guiding further optimization of the spatiotemporal embedding network.
[0060] See also Figure 4 , Figure 4 yes Figure 2 A specific implementation flow diagram of step S25 is described in detail as follows: S41, controlling the optimizer to adjust the model parameters of the spatiotemporal embedding network; Optionally, the optimizer is an Adam optimizer, which is an Adaptive Moment Estimation Optimizer. The Adam optimizer is a gradient descent optimization algorithm used in deep learning.
[0061] S42, when the loss value is the minimum value, stop adjusting the model parameters, save the adjusted model parameters, and select the spatiotemporal embedding network using the adjusted model parameters as the traffic flow prediction model.
[0062] In this embodiment of the present invention, when the loss value is the minimum, it indicates that the spatiotemporal embedding network has learned the potential rules and features in the data as much as possible. Selecting the spatiotemporal 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.
[0063] See also Figure 5 , Figure 5 yes Figure 2 A specific implementation flow diagram of step S26 is described in detail as follows: S51, 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; S52, 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 the preset threshold value, 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; Among them, the spatial index information of the sensor node refers to the location coordinates of the sensor node. Sensor nodes are usually deployed at key locations on the road, such as intersections, entrances to highways, and exits of highways, to collect vehicle speeds and vehicle types in real time. Through the spatial index information of the sensor node, the location of each sensor node can be accurately known, thereby ensuring that the collected data can accurately reflect the traffic conditions at the corresponding location. In traffic flow prediction, by comprehensively considering the data of multiple sensor nodes, more comprehensive traffic condition information can be obtained.
[0064] Urban hotspots refer to places in the city that attract a lot of attention, gather a large number of people and perform important functions. Urban hotspots include but are not limited to parks, shopping centers, pedestrian streets, museums, theaters, schools and art exhibition centers.
[0065] The spatial index information of urban hotspots refers to the location coordinates used to accurately locate and describe the hotspot areas in the city. Through the spatial index information of urban hotspots, the specific location of each urban hotspot in the urban spatial layout can be clearly understood.
[0066] Among them, the spatial index information of urban hotspots has a certain impact on traffic flow prediction. The spatial index information of urban hotspots clarifies the location coordinates of urban hotspots within the city, and also reveals the spatial relationship between urban hotspots and urban transportation networks. In traffic flow prediction, it is crucial to understand the location of urban hotspots and their proximity to transportation nodes. For example, parks, shopping malls, 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 surrounding roads and public transportation facilities. Through the spatial index information of urban hotspots, the traffic flow prediction model can more accurately simulate and predict the impact of these hotspot areas on traffic flow.
[0067] S53, extract features of the current traffic flow to obtain the sixth feature, extract features of the current time information data to obtain the seventh feature, extract features of the current spatial information data to obtain the eighth feature, extract features of the current road network topology map to obtain the ninth feature, concatenate 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, process the current input information through the traffic flow prediction model, and generate the predicted traffic flow for the next time period of the current time period.
[0068] The next time period of the current time period refers to the next time period immediately following the current time period in the time sequence. For example, if the current time period is 11:00 a.m., the next time period is 12:00 a.m. For example, if the current time period is 12:00 a.m., the next time period is 1:00 p.m.
[0069] 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, so that the traffic flow prediction model can capture richer data features, thereby improving the prediction ability and accuracy of the traffic flow prediction model.
[0070] In an embodiment of the present invention, the current input information is processed by 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 spatiotemporal 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.
[0071] See also Figure 6 , Figure 6FIG. 1 is a schematic diagram of a traffic flow prediction device according to an embodiment of the present invention. Figure 6 As 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 functional modules are described in detail as follows: 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; The second acquisition module 102 is used to determine the preset input information based on the preset traffic flow, preset spatiotemporal data, and preset road network topology map in the preset time period in the training set; The first generating module 103 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; The third acquisition module 104 is used to obtain the 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 105, used to control the optimizer to adjust the model parameters of the spatiotemporal embedding network, and select 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 106 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.
[0072] In one embodiment, the second acquisition module 102 includes: A first acquisition subunit is used to obtain, in the training set, a preset traffic flow, preset spatiotemporal data, and a preset road network topology map for a preset time period, and to form preset time information data with weather information, week information, time point information, holiday information, and the number of time slices per day in the preset spatiotemporal data, and to form preset spatial information data with spatial index information of sensor nodes and spatial index information of city hotspots in the preset spatiotemporal data; The first extraction subunit is used to perform feature extraction on the preset traffic flow to obtain the first feature, perform feature extraction on the preset time information data to obtain the second feature, perform feature extraction on the preset spatial information data to obtain the third feature, perform feature extraction on the preset road network topology map to obtain the fourth feature, concatenate 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.
[0073] In one embodiment, the first generating module 103 includes: A loading subunit, used to load a preset spatiotemporal embedding network and input the preset input information into the spatiotemporal embedding network; The first generating subunit is used to process the preset input information through a spatiotemporal embedding network to generate a predicted traffic flow in the next time period of the preset time period.
[0074] In one embodiment, the third acquisition module 104 includes: A second acquisition subunit is used to acquire the actual traffic flow in the next time period of the preset time period; The third acquisition subunit is used to obtain the difference between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period, and select the absolute value of the difference as the loss value.
[0075] In one embodiment, the adjustment module 105 includes: An adjustment subunit, used to control the optimizer to adjust the model parameters of the spatiotemporal embedding network; The stop subunit is used to stop adjusting the model parameters when the loss value is the minimum value, save the adjusted model parameters, and select the spatiotemporal embedding network using the adjusted model parameters as the traffic flow prediction model.
[0076] In one embodiment, the second generating module 106 includes: A fourth acquisition subunit is used to obtain evaluation index values of the traffic flow prediction model on the validation set and the test set, wherein the evaluation index 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; The fifth acquisition subunit is used to obtain the current traffic flow, current spatiotemporal data, and current road network topology map of the current time period 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 the preset threshold value, and to form the current time information data with the weather information, week information, time point information, holiday information, and the number of time slices per day in the current spatiotemporal data, and to form the current spatial information data with the spatial index information of the sensor nodes and the spatial index information of the city hotspots in the current spatiotemporal data; The second generating subunit is used to extract features of the current traffic flow to obtain a sixth feature, extract features of the current time information data to obtain a seventh feature, extract features of the current spatial information data to obtain an eighth feature, extract features of 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.
[0077] In one embodiment, the traffic flow prediction device further includes: The display module is used to obtain 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.
[0078] In the embodiment of the present invention, the beneficial effects lie in two aspects. On the one hand, the evaluation index value of the traffic flow prediction model on the verification 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, the current spatiotemporal data, and the current road network topology map of the current time period. The current input information is processed by 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, the current spatiotemporal data, and the current road network topology map 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. On the other hand, since the traffic flow prediction model will not be affected by human intervention, it is beneficial to improving the reliability of the predicted traffic flow for the next time period of the current time period.
[0079] The specific limitations of the traffic flow prediction device can be found in the above limitations of the traffic flow prediction method, which will not be repeated here.
[0080] Each module in the above-mentioned traffic flow prediction device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each of the above modules.
[0081] See also Figure 7 , Figure 7 1 is another structural diagram of a computer device in one embodiment of the present invention. In one embodiment, a computer device is provided. The computer device is a server device or a client device. The internal structure diagram thereof can be as shown in FIG. Figure 7 As 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 an external device. When the computer program is executed by the processor, the functions or steps of a traffic flow prediction method based on spatiotemporal data can be implemented.
[0082] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor.
[0083] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant description of the aforementioned method embodiment. In order to avoid repetition, they will not be described one by one here.
[0084] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU), and a network processor (NP); it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components.
[0085] The above description and the accompanying drawings sufficiently illustrate the embodiments of the present disclosure to enable those skilled in the art to practice them. In this article, each embodiment may focus on the differences from other embodiments, and the same or similar parts between the embodiments may refer to each other. For the methods and products disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
[0086] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. Technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. Technicians can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0087] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices and equipment) can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units can be only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some sub-samples can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit.
[0088] The flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and the block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and 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 opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may 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 input information is determined based on the preset traffic flow, preset spatiotemporal data, and preset road network topology map in the preset time period; 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: In the training set, the preset input information is determined based on the preset traffic flow, preset spatiotemporal data, and preset road network topology map in the preset time period, including: 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; Perform feature extraction on the 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.
3. 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.
4. 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.
5. 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.
6. 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.
7. 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.
8. 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 determine preset input information based on preset traffic flow, preset spatiotemporal data, and preset road network topology map in a preset time period in the training set; 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.
9. 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 7 are implemented.
10. 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 7 are implemented.
Citation Information
Patent Citations
Traffic flow prediction method and device based on space-time sequence deep learning
CN117116045A
Convolutional switching network-based traffic flow integrated prediction device and prediction method
CN117423238A
AU2020101405A4
Cited By
Road traffic flow prediction method based on space-time mixed attention network
CN120526608A