Disclosure of Invention
The invention provides a traffic flow prediction method, a traffic flow prediction device, computer equipment and a storage medium based on space-time data, which are used for solving the technical problem of how to predict traffic flow based on the space-time data.
In a first aspect, a traffic flow prediction method based on spatiotemporal data is provided, including:
Acquiring a traffic flow data set, and dividing the traffic flow data set into a training set, a verification set and a test set;
in the training set, determining preset input information based on preset traffic flow, preset space-time data and a preset road network topological graph in a preset time period;
processing the preset input information through a preset space-time embedded network to generate a predicted traffic flow of the next time period of a preset time period;
acquiring 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 model parameters of the space-time embedded network, and the space-time embedded network using the adjusted model parameters is selected to serve as a traffic flow prediction model according to the loss value and a predefined mode;
And acquiring evaluation index values of the traffic flow prediction model on the verification set and the test set, and determining current input information based on the current traffic flow, the current time-space data and the current road network topological graph of the current time period when the evaluation index values meet preset conditions, and processing the current input information through the traffic flow prediction model to generate the predicted traffic flow of the next time period of the current time period.
Further, in the training set, determining the preset input information based on the preset traffic flow, the preset space-time data and the preset road network topological graph in the preset time period includes:
In the training set, acquiring preset traffic flow, preset space-time data and a preset road network topological graph in a preset time period, forming weather information, week information, time point information, holiday information and the number of time slices per day in the preset space-time data into preset time information data, and forming index information of sensor nodes in the preset space-time data and index information of urban hot spots in space into preset space information data;
Performing feature extraction on preset traffic flow to obtain a first feature, performing feature extraction on preset time information data to obtain a second feature, performing feature extraction on preset space information data to obtain a third feature, performing feature extraction on a preset road network topological graph to obtain a fourth feature, splicing the first feature, the second feature, the third feature and the fourth feature to obtain a fifth feature, and selecting the fifth feature as preset input information.
Further, the processing, through a preset space-time embedded network, the preset input information to generate a predicted traffic flow of a next time period of a preset time period includes:
Loading a preset space-time embedded network, and inputting the preset input information into the space-time embedded network;
and processing the preset input information through a space-time embedded network to generate the predicted traffic flow of the next time period of the preset time period.
Further, the 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:
acquiring actual traffic flow of the next time period of the preset time period;
and obtaining a difference value between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period, and selecting an absolute value of the difference value as a loss value.
Further, the control optimizer adjusts model parameters of the space-time embedded network, and selects the space-time embedded network using the adjusted model parameters as a traffic flow prediction model according to a loss value and a predefined mode, including:
the control optimizer adjusts model parameters of the space-time embedded network;
And when the loss value is the minimum value, stopping adjusting the model parameter, storing the adjusted model parameter, and selecting the space-time embedded network using the adjusted model parameter as a traffic flow prediction model.
Further, the obtaining 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 condition, determining current input information based on the current traffic flow, the current space-time data and the current road network topology map of the current time period, and processing the current input information through the traffic flow prediction model to generate the predicted traffic flow of the next time period of the current time period, including:
Acquiring evaluation index values of the traffic flow prediction model on a verification set and a test set, wherein the evaluation index values comprise a value of an average absolute error, a value of an average absolute percentage error and a value of a root mean square error;
When the value of the average absolute error, the value of the average absolute percentage error and the value of the root mean square error are smaller than a preset threshold value, acquiring current traffic flow, current space-time data and a current road network topological graph in a current time period, forming weather information, week information, time point information, holiday information and the number of time slices per day in the current space-time data into current time information data, and forming index information of a sensor node in the current space-time data in space and index information of a city hot spot in space into current space information data;
Extracting features of the current traffic flow to obtain sixth features, extracting features of the current time information data to obtain seventh features, extracting features of the current space information data to obtain eighth features, extracting features of the current road network topological graph to obtain ninth features, splicing the sixth features, the seventh features, the eighth features and the ninth features to obtain tenth features, selecting the tenth features as current input information, inputting the current input information into the traffic flow prediction model, and processing the current input information through the traffic flow prediction model to generate predicted traffic flow of the next time period of the current time period.
Further, when the evaluation index value of the traffic flow prediction model on the verification set and the test set is obtained and the evaluation index value meets a preset condition, determining current input information based on current traffic flow, current space-time data and current road network topology map of a current time period, processing the current input information through the traffic flow prediction model, and generating predicted traffic flow of a next time period of the current time period, the traffic flow prediction method comprises the following steps:
And acquiring a display page, creating a display window of the display page, and displaying the predicted traffic flow of the next time period of the current time period through the display window.
In a second aspect, there is provided a traffic flow prediction device based on spatiotemporal data, comprising:
The first acquisition module is used for acquiring a traffic flow data set and dividing the traffic flow data set into a training set, a verification set and a test set;
The second acquisition module is used for determining preset input information in the training set based on preset traffic flow, preset space-time data and a preset road network topological graph in a preset time period;
The first generation module is used for processing the preset input information through a preset space-time embedded network to generate predicted traffic flow of the next time period of a preset time period;
A third obtaining module, configured to obtain a loss value between the predicted traffic flow and the actual traffic flow in a next time period of the preset time period;
The adjustment module is used for controlling the optimizer to adjust model parameters of the space-time embedded network, and selecting the space-time embedded network using the adjusted model parameters as a traffic flow prediction model according to the loss value and a predefined mode;
The second generation module is used for acquiring the evaluation index values of the traffic flow prediction model on the verification set and the test set, determining current input information based on the current traffic flow, the current space-time data and the current road network topological graph of the current time period when the evaluation index values meet preset conditions, and processing the current input information through the traffic flow prediction model to generate the predicted traffic flow of the next time period of the current time period.
In a third aspect, a computer device is provided comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the traffic flow prediction method described above when executing the computer program.
In a fourth aspect, a computer readable storage medium is provided, the computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the traffic flow prediction method described above.
The application provides a traffic flow prediction method, a device, computer equipment and a storage medium based on space-time data, which have the beneficial effects that on one hand, an evaluation index value of a traffic flow prediction model on a verification set and a test set is obtained, when the evaluation index value meets a preset condition, current input information is determined based on the current traffic flow, the current space-time data and a current road network topological graph of a current time period, the current input information is processed through the traffic flow prediction model, the predicted traffic flow of the next time period of the current time period is generated, and the traffic flow prediction model can capture the dynamic characteristics of the current time period because the current traffic flow, the current space-time data and the current road network topological graph are all dynamic characteristics of the current time period, so that the reliability of the predicted traffic flow of the next time period of the current time period is improved, and on the other hand, the traffic flow prediction model cannot be influenced by manual intervention, so that the reliability of the predicted traffic flow of the next time period of the current time period is improved.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic view of an application environment of a traffic flow prediction method according to an embodiment of the present invention, and the traffic flow prediction method provided by the embodiment of the present invention can be applied to the application environment as shown in fig. 1, where a client communicates with a server through a network.
The method comprises the steps that a server side obtains a traffic flow data set through a client side, and the traffic flow data set is divided into a training set, a verification set and a test set;
in the training set, determining preset input information based on preset traffic flow, preset space-time data and a preset road network topological graph in a preset time period;
processing the preset input information through a preset space-time embedded network to generate a predicted traffic flow of the next time period of a preset time period;
acquiring 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 model parameters of the space-time embedded network, and the space-time embedded network using the adjusted model parameters is selected to serve as a traffic flow prediction model according to the loss value and a predefined mode;
And acquiring evaluation index values of the traffic flow prediction model on the verification set and the test set, and determining current input information based on the current traffic flow, the current time-space data and the current road network topological graph of the current time period when the evaluation index values meet preset conditions, and processing the current input information through the traffic flow prediction model to generate the predicted traffic flow of the next time period of the current time period.
In the scheme realized by the traffic flow prediction method, the device, the equipment and the medium, the method has the advantages that on 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 condition, the current input information is determined based on the current traffic flow, the current space-time 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, the predicted traffic flow of the next time period of the current time period is generated, and the traffic flow prediction model can capture the dynamic characteristics of the current time period because the current traffic flow, the current space-time data and the current road network topology map are dynamic characteristics of the current time period, so that the reliability of the predicted traffic flow of the next time period of the current time period is improved, and on the other hand, the traffic flow prediction model cannot be influenced by manual intervention, so that the reliability of the predicted traffic flow of the next time period of the current time period is improved.
The device running the client is called client device for short.
The device for running the server is called as server device for short.
Client devices include, but are not limited to, smart phones, personal computers, internet of vehicles terminals, tablet computers, and portable wearable devices.
The server device may be implemented by a stand-alone server or a server cluster formed by a plurality of servers. The present invention will be described in detail with reference to specific examples. Referring to fig. 2, fig. 2 is a flow chart of a traffic flow prediction method according to an embodiment of the invention, which includes the following steps:
s21, acquiring a traffic flow data set, and dividing the traffic flow data set into a training set, a verification set and a test set;
illustratively, obtaining a traffic flow dataset, dividing the traffic flow dataset into a training set, a validation set, and a test set, comprising:
The method comprises the steps of accessing a data set website, acquiring a traffic flow data set from the data set website, and dividing the traffic flow data set into a training set, a verification set and a test set according to a preset proportion.
For example, when the preset ratio is 6:2:2, the traffic flow data set is divided into a training set, a verification set and a test set according to the ratio of 6:2:2.
For example, when the preset ratio is 7:2:1, the traffic flow data set is divided into a training set, a verification set and a test set according to the ratio of 7:2:1.
Wherein, the traffic flow data set refers to a data set which is specially collected and arranged for describing and analyzing the related information of the road traffic flow. Traffic flow data sets typically cover the number, type, speed of vehicles passing through a road segment, intersection, or the entire traffic network over a particular period of time.
S22, in the training set, determining preset input information based on preset traffic flow, preset space-time data and a preset road network topological graph in a preset time period;
The preset traffic flow is the preset traffic flow;
Wherein the preset spatiotemporal data are preset spatiotemporal data;
The preset road network topological graph is a preset road network topological graph.
The spatiotemporal data refers to data containing time attributes and space attributes.
Where traffic flow is the number of vehicles passing through a road segment, intersection or traffic node. Traffic flow is a key parameter for measuring road traffic conditions, and reflects the traffic capacity of roads.
The road network topological graph is a graphical representation method and is used for describing an intersection, a road section starting point and a road section ending point in a road network and a structure diagram of a connection relationship among the intersection, the road section starting point and the road section ending point. The road network topology map presents the layout and connection patterns of the road network in an intuitive manner so that the manager, planner and researcher can more easily understand and analyze the structural characteristics of the road network.
Wherein, in the training set, based on the preset traffic flow, the preset space-time data and the preset road network topological graph of the preset time period, the determining of the preset input information comprises:
In the training set, acquiring preset traffic flow, preset space-time data and a preset road network topological graph in a preset time period, forming weather information, week information, time point information, holiday information and the number of time slices per day in the preset space-time data into preset time information data, and forming index information of sensor nodes in the preset space-time data and index information of urban hot spots in space into preset space information data;
Performing feature extraction on preset traffic flow to obtain a first feature, performing feature extraction on preset time information data to obtain a second feature, performing feature extraction on preset space information data to obtain a third feature, performing feature extraction on a preset road network topological graph to obtain a fourth feature, splicing the first feature, the second feature, the third feature and the fourth feature to obtain a fifth feature, and selecting the fifth feature as preset input information.
The method comprises the steps of extracting features of a preset road network topological graph to obtain a fourth feature, splicing the first feature, the second feature, the third feature and the fourth feature to obtain a fifth feature, selecting the fifth feature as preset input information, and enabling the information quantity input by a space-time embedded network to be remarkably increased, so that the space-time embedded network can capture richer data features, and the prediction capability and accuracy of the space-time embedded network are improved.
By way of example, a dynamic feature enhancement module is adopted to perform feature extraction on the preset traffic flow to obtain a first feature.
The English name of the dynamic characteristic enhancement module is Dynamic Feature Enhancement Module. The dynamic characteristic enhancement module can enhance key characteristics according to the characteristics of input data by dynamically adjusting internal parameters thereof. This adaptation enables the dynamic feature enhancement module to extract more rich and useful feature information when processing image data of different modalities or different qualities.
Among other things, week information, i.e. the division of the days of the week, has a significant impact on traffic flow. The influence is mainly reflected in the working, living and traveling habits of people, and then the periodic change of traffic flow is caused. On the one hand, on weekdays, monday through friday, traffic flow during the morning and evening peak hours may be relatively high because most people need to go to work or school. In these periods, people travel intensively, resulting in road congestion and a significant increase in traffic flow. In addition, during the midday hours of the workday, a small range of peaks in traffic flow may also occur, as some people may choose to go out for dining or perform other activities during this time period. On the other hand, on weekends, i.e., saturday and Sunday, people's travel habits often change. Because of the lack of work or learning pressure, many people choose to conduct recreational activities on weekends, such as shopping, travel, visiting friends, etc. These activities tend to result in increased traffic flow in certain areas of the city, especially near business centers, tourist attractions and transportation hubs. However, the overall traffic flow on weekends may be relatively low compared to weekdays, as some people may choose to rest at home or perform other indoor activities.
The weather information refers to various weather changes in the atmosphere in a certain area within a certain period of time, including conditions such as temperature, humidity, air pressure, precipitation, wind, cloud and the like. Weather information has a significant impact on traffic flow. On the one hand, severe weather conditions, such as heavy rain, strong wind, and heavy fog, can directly affect the road traffic capacity, reduce the running speed of the vehicle, and thus increase the risk of traffic accidents, resulting in reduced traffic flow. For example, in rainy days where the road surface is slippery, the driver needs to increase the braking distance, maintaining a larger head-to-head spacing, which reduces road traffic efficiency. Meanwhile, the visibility is reduced in the foggy weather, so that the sight of a driver is limited, and traffic jam is further aggravated.
Wherein the time point information refers to a time stamp, such as a certain hour, minute of a day. Taking the time point of the day as an example, the rush hour of the morning is usually 7 to 9, the rush hour of the evening is usually 17 to 19, and the rush hour of the morning and the rush hour of the evening are the times when the urban traffic flow is the most dense. In the two time periods, a large number of residents go out in a concentrated mode, so that road congestion, high public transportation full rate and even traffic paralysis can occur. In contrast, during off-peak hours from midnight to early morning, traffic flow may decrease significantly and the road may become relatively clear.
The holiday information refers to a date which is considered to be a public rest or celebration date, such as spring festival, national celebration festival, mid-autumn festival, and the like. These holidays have a significant and predictable impact on traffic flow. For example, the day before the holiday, the day first, and the day last of the holiday are typically when traffic flow is most intense. For example, during the afternoon and morning of the day before the holiday, a large amount of urban traffic and traffic flow will occur around the expressway and railway station, and during the last day of the holiday, a large amount of return traffic and traffic flow will occur, which will bring serious stress to traffic and may cause traffic jams and delays.
The number of time slices per day refers to the number of time slices obtained by dividing 24 hours a day into a plurality of consecutive time periods. For example, a day is divided into 24 time slices of one hour to analyze traffic conditions every hour, and for example, a day is divided into 48 time slices to analyze traffic conditions every half hour.
Illustratively, extracting features of the preset traffic flow to obtain a first feature, including:
normalizing the preset traffic flow to obtain normalized preset traffic flow,
And extracting the characteristics of the normalized preset traffic flow to obtain a first characteristic.
The pretreatment operation adopts a Min-Max standardization method, and a preset traffic flow is transformed:
;
Wherein, theRepresenting the corresponding normalized preset traffic flow,A preset traffic flow representing the kth time step,And N is the total time step number of the preset traffic flow, and the value range of j is between 1 and N time steps. And regarding the obtained normalized preset traffic flow as a time-space sequence.
Wherein, theRepresenting a minimum function that can return the minimum value in a set of values by traversing a given set of values.
Wherein, theRepresenting the maximum function. The maximum function can return the maximum value in a set of values by traversing a given set of values.
The magnitude difference of different features may cause the gradient to show unbalance when updated, thereby affecting the convergence efficiency of the model, and the normalization processing can eliminate the magnitude difference, so that all features have similar contribution degree in the training process of the space-time embedded network, thereby accelerating the convergence process of the space-time embedded network.
S23, processing the preset input information through a preset space-time embedded network to generate predicted traffic flow of the next time period of a preset time period;
Wherein, the space-time embedded network is a network model integrating time and space information. In a space-time embedded network, nodes represent not only entities or objects, but also their locations and properties in time and space. Such networks capture and represent dynamic changes in time and space of entities or objects by building complex relationships between nodes.
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;
wherein, the next time period of the preset time period refers to the next time period immediately following the preset time period in time sequence. For example, if the preset time period is 2 am, the next time period is 3 am. For example, if the preset time period is 4 am, the next time period is 5 am.
The 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:
acquiring actual traffic flow of the next time period of the preset time period;
and obtaining a difference value between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period, and selecting an absolute value of the difference value as a loss value.
The predicted traffic flow of the next time period of the preset time period is the predicted traffic flow of the next time period of the preset time period.
The loss value is used for measuring the degree of difference between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period, and the larger the loss value is, the larger the degree of difference between the predicted traffic flow and the actual traffic flow in the next time period of the preset time period is, the smaller the loss value is, and 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 is.
S25, controlling an optimizer to adjust model parameters of the space-time embedded network, and selecting the space-time embedded network using the adjusted model parameters as a traffic flow prediction model according to a loss value and a predefined mode;
the model parameters after adjustment are optimized on a training set, and the space-time embedded network using the model parameters after adjustment is selected as a traffic flow prediction model, so that the traffic flow prediction model can learn general characteristics and rules, and has higher generalization capability.
S26, acquiring evaluation index values of the traffic flow prediction model on a verification set and a test set, and determining current input information based on current traffic flow, current space-time data and a current road network topological graph in a current time period when the evaluation index values meet preset conditions, and processing the current input information through the traffic flow prediction model to generate predicted traffic flow in the next time period in the current time period.
Wherein the current traffic flow is the current traffic flow;
Wherein the current spatiotemporal data is current spatiotemporal data;
The current road network topological graph is the current road network topological graph.
The predicted traffic flow of the next time period of the current time period is the predicted traffic flow of the next time period of the current time period.
When the evaluation index value meets a preset condition, determining current input information based on current traffic flow, current space-time data and current road network topology diagram of a current time period, processing the current input information through the traffic flow prediction model, and generating predicted traffic flow of a next time period of the current time period, wherein the traffic flow prediction method comprises the following steps:
And acquiring a display page, creating a display window of the display page, and displaying the predicted traffic flow of the next time period of the current time period through the display window.
The traffic flow prediction model has the advantages that on 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 condition, the current input information is determined based on the current traffic flow, the current time-space data and the current road network topological graph of the current time period, the current input information is processed through the traffic flow prediction model to generate the predicted traffic flow of the next time period of the current time period, and the traffic flow prediction model can capture the dynamic characteristics of the current time period because the current traffic flow, the current time-space data and the current road network topological graph are all dynamic characteristics of the current time period, so that the reliability of the predicted traffic flow of the next time period of the current time period is improved, and on the other hand, the traffic flow prediction model is not influenced by manual intervention, so that the reliability of the predicted traffic flow of the next time period of the current time period is improved.
Referring to fig. 3, fig. 3 is a flowchart of step S23 in fig. 2, which is described in detail below:
s31, loading a preset space-time embedded network, and inputting the preset input information into the space-time embedded network;
s32, processing the preset input information through a space-time embedded network to generate the predicted traffic flow of the next time period of the preset time period.
In the embodiment of the invention, the preset input information is processed through the space-time embedded network to generate the predicted traffic flow of the next time period of the preset time period, and the accuracy and the reliability of the space-time embedded network can be improved by comparing the predicted traffic flow of the next time period of the preset time period with the actual traffic flow, so that the further optimization of the space-time embedded network is guided.
Referring to fig. 4, fig. 4 is a flowchart of step S25 in fig. 2, which is described in detail below:
S41, controlling an optimizer to adjust model parameters of the space-time embedded network;
alternatively, the optimizer is an Adam optimizer, which is chinese fully called an adaptive moment estimation optimizer, and english fully called Adaptive Moment Estimation. Adam optimizer is a gradient descent optimization algorithm used in deep learning.
And S42, stopping adjusting the model parameters when the loss value is the minimum value, storing the adjusted model parameters, and selecting the space-time embedded network using the adjusted model parameters as a traffic flow prediction model.
In the embodiment of the invention, when the loss value is the minimum value, the space-time embedded network is shown to learn potential rules and features in the data as much as possible, and the space-time embedded network using the adjusted model parameters is selected as a traffic flow prediction model, so that the stability and reliability of the traffic flow prediction model can be ensured.
Referring to fig. 5, fig. 5 is a flowchart of step S26 in fig. 2, which is described in detail below:
s51, acquiring evaluation index values of the traffic flow prediction model on a verification set and a test set, wherein the evaluation index values comprise a value of an average absolute error, a value of an average absolute percentage error and a value of a root mean square error;
S52, when the value of the average absolute error, the value of the average absolute percentage error and the value of the root mean square error are smaller than a preset threshold value, acquiring current traffic flow, current space-time data and a current road network topological graph in a current time period, forming weather information, week information, time point information, holiday information and the number of time slices per day in the current space-time data into current time information data, and forming index information of sensor nodes in the current space-time data in space and index information of urban hot spots in space into current space information data;
Wherein, the index information of the sensor node in space refers to the position coordinates of the sensor node. Sensor nodes are typically deployed at strategic locations on roads, such as intersections, highway entrances, and highway exits, to collect vehicle speed and vehicle type in real time. The position of each sensor node can be accurately known through the index information of the sensor nodes in space, so that the collected data can accurately reflect the traffic condition of the corresponding position. In the traffic flow prediction, the data of a plurality of sensor nodes are comprehensively considered, so that more comprehensive traffic condition information can be obtained.
Urban hotspots refer to sites in cities that have a degree of attention, a large number of people gathering and bearing important functions. Urban hotspots include, but are not limited to, parks, shopping malls, pedestrian streets, museums, theatres, schools, and art exhibition centers.
The index information of the urban hot spot in space refers to position coordinates used for precisely positioning and describing each hot spot area in the city. The specific position of each urban hot spot in the urban space layout can be clearly known through the index information of the urban hot spot in space.
The index information of the urban hot spot in space has a certain influence on traffic flow prediction. The index information of the urban hot spot on the space defines the position coordinates of the urban hot spot in the city, and also reveals the spatial relationship between the urban hot spot and the urban traffic network. In traffic flow prediction, it is important to know the location of urban hot spots and their proximity to traffic nodes. For example, parks, shopping malls, pedestrian streets, museums, theatres, schools and art exhibition centers, often attract a great deal of traffic, resulting in a significant increase in traffic flow on surrounding roads and public transportation facilities. The traffic flow prediction model can more accurately simulate and predict the influence of the hot spot areas on the traffic flow through index information of the urban hot spots in space.
And S53, carrying out feature extraction on the current traffic flow to obtain a sixth feature, carrying out feature extraction on the current time information data to obtain a seventh feature, carrying out feature extraction on the current space information data to obtain an eighth feature, carrying out feature extraction on the current road network topological graph to obtain a ninth feature, splicing the sixth feature, the seventh feature, the eighth feature and the ninth feature to obtain a tenth feature, selecting the tenth feature as current input information, inputting the current input information into the traffic flow prediction model, and processing the current input information through the traffic flow prediction model to generate the predicted traffic flow of the next time period of the current time period.
Wherein the next time period of the current time period refers to the time period immediately next to the current time period in time sequence. For example, if the current time period is 11 am, then the next time period is 12 am. For example, if the current time period is 12 am, then the next time period is 1 pm.
The sixth feature, the seventh feature, the eighth feature and the ninth feature are spliced to obtain a tenth feature, the tenth feature is selected as current input information, the current input information can obviously increase the information quantity input by the traffic flow prediction model, the traffic flow prediction model can capture richer data features, and accordingly the prediction capability and accuracy of the traffic flow prediction model are improved.
In the embodiment of the invention, the current input information is processed through the traffic flow prediction model to generate the predicted traffic flow of the next time period of the current time period, and the traffic flow prediction model can capture the dynamic characteristics of the current time period because the current traffic flow, the current space-time data and the current road network topological graph are all dynamic characteristics of the current time period, so that the reliability of the predicted traffic flow of the next time period of the current time period is improved.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a traffic flow prediction device according to an embodiment of the invention, and as shown in fig. 6, the traffic flow prediction device includes a first obtaining module 101, a second obtaining module 102, a first generating module 103, a third obtaining module 104, an adjusting module 105, and a second generating module 106. The functional modules are described in detail as follows:
A first obtaining module 101, configured to obtain a traffic flow data set, and divide the traffic flow data set into a training set, a verification set and a test set;
A second obtaining module 102, configured to determine, in the training set, preset input information based on a preset traffic flow, preset spatiotemporal data, and a preset road network topology map in a preset time period;
a first generation module 103, configured to process the preset input information through a preset space-time embedded network, and generate a predicted traffic flow of a next time period of a preset time period;
a third obtaining module 104, configured to obtain a loss value between the predicted traffic flow and the actual traffic flow in a period next to the preset period;
The adjusting module 105 is configured to control the optimizer to adjust model parameters of the space-time embedded network, and select the space-time embedded network using the adjusted model parameters as a traffic flow prediction model according to a loss value and a predefined manner;
And the second generating module 106 is configured to obtain evaluation index values of the traffic flow prediction model on the verification set and the test set, determine current input information based on the current traffic flow, the current space-time data and the current road network topology map in the current time period when the evaluation index values meet the preset conditions, and process the current input information through the traffic flow prediction model to generate the predicted traffic flow in the next time period in the current time period.
In one embodiment, the second obtaining module 102 includes:
The first acquisition subunit is used for acquiring preset traffic flow, preset space-time data and a preset road network topological graph in a preset time period in the training set, forming weather information, week information, time point information, holiday information and the number of time slices per day in the preset space-time data into preset time information data, and forming index information of sensor nodes in the preset space-time data and index information of urban hot spots in space into preset space information data;
The first extraction subunit is configured to perform feature extraction on a preset traffic flow to obtain a first feature, perform feature extraction on preset time information data to obtain a second feature, perform feature extraction on preset space information data to obtain a third feature, perform feature extraction on a 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 preset input information.
In one embodiment, the first generating module 103 includes:
The loading subunit is used for loading a preset space-time embedded network and inputting the preset input information into the space-time embedded network;
The first generation subunit is used for processing the preset input information through a space-time embedded network to generate the predicted traffic flow of the next time period of the preset time period.
In one embodiment, the third obtaining module 104 includes:
the second acquisition subunit is used for acquiring the actual traffic flow of the next time period of the preset time period;
And the third acquisition subunit is used for acquiring the difference value 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 value as a loss value.
In one embodiment, the adjustment module 105 includes:
the adjusting subunit is used for controlling the optimizer to adjust model parameters of the space-time embedded network;
And the stopping subunit is used for stopping adjusting the model parameters when the loss value is the minimum value, storing the adjusted model parameters, and selecting the space-time embedded network using the adjusted model parameters as a traffic flow prediction model.
In one embodiment, the second generating module 106 includes:
a fourth obtaining subunit, configured to obtain an evaluation index value of the traffic flow prediction model on a verification set and a test set, where the evaluation index value includes a value of an average absolute error, a value of an average absolute percentage error, and a value of a root mean square error;
A fifth obtaining subunit, configured to obtain, when the value of the average absolute error, the value of the average absolute percentage error, and the value of the root mean square error are all smaller than a preset threshold, a current traffic flow, current space-time data, and a current road network topology map in a current time period, form weather information, week information, time point information, holiday information, and the number of time slices per day in the current space-time data, and form current space information data from index information of a sensor node in the current space-time data and index information of a city hotspot in space;
The second generating subunit is 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 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 in a next time period of the current time period.
In one embodiment, the traffic flow prediction device further comprises:
The display module is used for acquiring a display page, creating a display window of the display page, and displaying the predicted traffic flow of the next time period of the current time period through the display window.
The traffic flow prediction model has the advantages that on 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 condition, the current input information is determined based on the current traffic flow, the current time-space data and the current road network topological graph of the current time period, the current input information is processed through the traffic flow prediction model to generate the predicted traffic flow of the next time period of the current time period, and the traffic flow prediction model can capture the dynamic characteristics of the current time period because the current traffic flow, the current time-space data and the current road network topological graph are all dynamic characteristics of the current time period, so that the reliability of the predicted traffic flow of the next time period of the current time period is improved, and on the other hand, the traffic flow prediction model is not influenced by manual intervention, so that the reliability of the predicted traffic flow of the next time period of the current time period is improved.
The specific limitation of the traffic flow prediction device may be referred to the limitation of the traffic flow prediction method hereinabove, and will not be described herein.
The various modules in the traffic flow prediction device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
Referring to fig. 7, fig. 7 is another schematic structural diagram of a computer device according to an embodiment of the present invention, and in one embodiment, a computer device is provided, where the computer device is a server device or a client device, and an internal structure diagram of the computer device may be shown in fig. 7. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured 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 computer programs in the non-volatile storage media. The network interface of the computer device is used for communicating with an external device. The computer program, when executed by a processor, may implement the functions or steps of a traffic flow prediction method based on spatio-temporal data.
In one embodiment, a computer device is provided that includes a memory, a processor, and a computer program stored on the memory and executable on the processor.
It should be noted that, the functions or steps implemented by the computer readable storage medium or the computer device may correspond to the relevant descriptions of the foregoing method embodiments, and are not described herein for avoiding repetition.
The processor may be a general-purpose processor including a central Processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU), a network processor (Network Processor, NP), a digital signal processor (DIGITAL SIGNAL Processing, DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable gate array (FPGA) or other Programmable logic device, discrete gate or transistor logic device, or discrete hardware components.
The above description and the drawings illustrate embodiments of the disclosure sufficiently to enable those skilled in the art to practice them. In this context, each embodiment may be described with emphasis on the differences from the other embodiments, and the same similar parts between the various embodiments may be referred to each other. For the methods, products disclosed in the examples, if they correspond to the method portions disclosed in the examples, then reference may be made to the description of the method portions for relevance.
Those of skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. The skilled person may use different methods for each particular application to achieve the described functionality, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again.
In the embodiments disclosed herein, the disclosed methods, articles of manufacture (including but not limited to devices, apparatuses) may be practiced in other ways. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of elements may be merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple elements or components may be combined or integrated into another system, or some sub-samples may be omitted, or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form. The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to implement the present embodiment. In addition, each functional unit in the embodiments of the present disclosure may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. In the description corresponding to the flowcharts and block diagrams in the figures, operations or steps corresponding to different blocks may also occur in different orders than that disclosed in the description, and sometimes no specific order exists between different operations or steps. For example, two consecutive operations or steps may actually be performed substantially in parallel, they may sometimes be performed in reverse order, which may be dependent on the functions involved. Each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.