Traffic data prediction method, device and equipment, and storage medium
By training the model with graph-structured time-series data and processing traffic data using encoders, decoders, and correctors, the low accuracy of existing methods under complex and imbalanced data is solved, achieving higher prediction accuracy.
Patent Information
- Application Number
- CN202210938954.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-05
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-08-05
AI Technical Summary
Existing traffic data prediction methods have low accuracy when faced with complex and imbalanced data, and traditional deep learning methods perform poorly in predicting irregularly sampled data.
A traffic data prediction model is trained using graph-structured time-series data. Data processing is performed using an encoder, decoder, and corrector. The encoder is constructed based on natural interpolation equations or graph attention mechanism equations, the decoder is based on recurrent neural networks, and the corrector is based on graph neural stochastic differential equations for correction, taking into account the spatiotemporal correlation of traffic data.
It improves the accuracy of traffic data prediction, effectively handles irregular sampling data, reduces the error between prediction results and actual results, and is in line with practical application scenarios.
Smart Images

Figure CN115374844B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a traffic data prediction method and device, equipment and a storage medium. BACKGROUND
[0002] Traffic plays a vital role in everyone's daily life, and everyone needs to spend a lot of time on traffic every day. In this case, accurate real-time traffic prediction is very important for road users, the private sector and the government. Widely used traffic services, such as flow control, route planning and navigation, also depend heavily on high-quality traffic condition assessment. Therefore, it is very meaningful to accurately predict the traffic state, and the purpose of traffic prediction is to predict the future traffic state of the connected road segment according to the historical traffic data in the basic road network structure. Researchers have made many method results for this, and there are generally three methods, statistical analysis method, nonlinear theory method and deep learning method. The earliest one is to use statistical methods, such as autoregressive integrated moving average (ARIMA) and its variants. In recent years, with the continuous development of deep learning, statistical methods have gradually been replaced by deep learning, such as using neural network LSTM and its variants to predict traffic volume, such as patent number CN111292525A.
[0003] Among the existing methods, statistical analysis methods such as autoregressive integrated moving average (ARIMA) and multivariate time series vector autoregressive model (VAR) are needed to meet certain assumptions, but traffic data is too complex to meet these assumptions, so in practice, the model is usually simple and the precision is general; In the nonlinear method, such as wavelet analysis model, chaos theory model, etc., the model is complex and the calculation amount is large. With the continuous development of computer technology and artificial intelligence technology, people gradually shift their focus from nonlinear methods to machine learning and deep learning methods; At present, the deep learning used for traffic prediction is based on the rule-based data form, that is, the data sampling interval is equal, but this is an ideal state. When the traffic flow data sampling is unbalanced, the error between the prediction result obtained by using the above method and the true result is large, and the prediction effect is poor. SUMMARY
[0004] Therefore, the present application provides a traffic data prediction method, device, equipment and storage medium to solve the problem of low accuracy of existing traffic data prediction.
[0005] To solve the above technical problems, one of the technical solutions adopted by the present application is to provide a traffic data prediction method, comprising: obtaining historical traffic data in a preset time period, and converting the historical traffic data into time series data; inputting the time series data into a pre-trained traffic data prediction model, the traffic data prediction model comprising an encoder, a decoder and a corrector, the traffic data prediction model being trained using time series data samples with a graph structure, the data in the graph structure comprising regular time stamps or irregular time stamps; using the encoder to encode the time series data to obtain an encoding vector, the encoder being constructed based on a neural differential equation controlled by a natural interpolation equation or a graph attention mechanism equation; using the decoder to decode the encoding vector to obtain an initial traffic data prediction result of a to-be-predicted time period, the decoder being constructed based on a recurrent neural network; using the corrector to correct the initial traffic data prediction result to obtain a final traffic data prediction result, the corrector being constructed based on a graph neural random differential equation.
[0006] As a further improvement of the present application, the encoder constructed based on the graph neural differential equation controlled by the natural interpolation equation is represented as:
[0007]
[0008] h n (t+1)=h n (t)+r(t+1);
[0009] Wherein, h n (t) represents the hidden state of the nth node at time t, ζ represents a multi-layer perceptron to be trained, represents a pre-constructed control equation, t represents a time stamp, t∈[0,T], σ represents a nonlinear function tanh, i and j represent different nodes respectively, N i represents the neighborhood of node i, softmax and LeakyReLU represent activation functions, a · , W, W h represent parameters obtained by traffic data prediction, h i , h j represent the values corresponding to the i-th and j-th nodes after the time series data is converted into a vector and decomposed, and represents the splicing of matrices.
[0010] As a further improvement of the present application, the encoder constructed based on the neural differential equation controlled by the graph attention mechanism equation is represented as:
[0011]
[0012] h n (t+1)=h n (t)+r(t+1);
[0013] where h n (t) represents the hidden state of the nth node at time t, ζ and represents a multi-layer perceptron that needs to be trained, t represents a timestamp, t∈[0,T], σ represents a nonlinear function tanh, i, j represent different nodes respectively, N i represents the neighborhood of node i, softmax and LeakyReLU represent activation functions, a · , W, W h represent parameters obtained by predicting traffic data, h i , h j represent the values corresponding to the ith and jth nodes after the time series data is converted into a vector and decomposed, and represents the splicing of matrices.
[0014] As a further improvement of the present application, the decoder constructed based on the recurrent neural network is represented as:
[0015] r d =σ(υ r ·[P d-1 ,W d ]);
[0016] z d =σ(υ z ·[P d-1 ,W d ]);
[0017]
[0018]
[0019] Q=σ(W o ·P d );
[0020] where r d , z d , P d are all intermediate variables, σ represents a nonlinear function tanh, υ r , υ z , W o represents parameters obtained by predicting traffic data, W d represents the hidden state output by the encoder at time d, Q represents the output of the decoder, i.e., the initial traffic data prediction result, h d-1 represents the state at time d-1 in the cycle process.
[0021] As a further improvement of the present application, the corrector constructed based on the graph neural random differential equation is represented as:
[0022]
[0023] D = ∫μ(Q, D(Q))dQ + ρ(Q, D(Q))·dw(Q);
[0024] wherein, denotes the final traffic data prediction result, Q denotes the initial traffic data prediction result, D denotes the graph neural random differential equation, μ denotes the graph-based model, ρ denotes the multi-layer perception, and w denotes the random process subject to the normal distribution.
[0025] As a further improvement of the present application, the method further comprises pre-training the traffic data prediction model, specifically comprising: obtaining time series data samples with a graph structure, and dividing the time series data samples into a training set and a validation set; dividing the time series data samples in the training set into input data and expected data according to time periods; inputting the input data into the traffic data prediction model to be trained, the traffic data prediction model comprising an encoder, a decoder and a corrector; encoding the input data using the encoder, and then decoding the encoding result using the decoder to obtain preliminary prediction data; correcting the preliminary prediction data using the corrector to obtain final prediction data; iteratively training the encoder, the decoder and the corrector based on a pre-constructed loss function, the final prediction data and the expected data; verifying the traffic data prediction model after the iterative training using the time series data samples in the validation set, and retaining the traffic data prediction model with the minimum loss function value.
[0026] As a further improvement of the present application, the loss function is represented as:
[0027]
[0028] wherein, MSELOSS denotes the loss function value, M denotes a time period corresponding to the expected data, d denotes a time instant in the time period, and P denotes the expected data, denotes the final prediction data.
[0029] To solve the above technical problems, the technical scheme adopted by the present application is: a traffic data prediction device is provided, comprising: an acquisition module configured to acquire historical traffic data in a preset time period and convert the historical traffic data into time series data; an input module configured to input the time series data into a pre-trained traffic data prediction model, the traffic data prediction model comprising an encoder, a decoder and a corrector, the traffic data prediction model being trained using time series data samples with a graph structure, the data in the graph structure comprising regular time stamps or irregular time stamps; an encoding module configured to encode the time series data using the encoder to obtain an encoded vector, the encoder being constructed based on a neural differential equation controlled by a natural interpolation equation or a graph attention mechanism equation; a decoding module configured to decode the encoded vector using the decoder to obtain an initial traffic data prediction result for a to-be-predicted time period, the decoder being constructed based on a recurrent neural network; and a correction module configured to correct the initial traffic data prediction result using the corrector to obtain a final traffic data prediction result, the corrector being constructed based on a graph neural random differential equation.
[0030] To solve the above technical problems, the technical scheme adopted by the present application is: a computer device is provided, comprising a processor and a memory coupled to the processor, the memory storing program instructions, the program instructions being executed by the processor to cause the processor to perform the steps of the traffic data prediction method of any one of the above.
[0031] To solve the above technical problems, the technical scheme adopted by the present application is: a storage medium is provided, storing program instructions capable of implementing the traffic data prediction method of any one of the above.
[0032] The traffic data prediction method of the present application has the following beneficial effects: the traffic data prediction model is trained using time series data samples with a graph structure, the data in the graph structure comprising regular time stamps or irregular time stamps, i.e. the traffic data prediction model has been trained using irregular sampling data in the training stage, so that the traffic data prediction model can be applied to the prediction of irregular sampling data, which comprehensively considers the time correlation and spatial correlation of traffic data, is a prediction method that fuses time and space, is more consistent with actual application scenarios, and further improves the prediction accuracy by correcting the prediction result output by the decoder using the corrector constructed based on a graph neural random differential equation, reducing the error between the prediction result and the true result. BRIEF DESCRIPTION OF DRAWINGS
[0033] Figure 1 is a flowchart of the traffic data prediction method of the embodiment of the present application;
[0034] Figure 2is a flowchart of a traffic data prediction model training process of an embodiment of the present application;
[0035] Figure 3 is a functional module schematic diagram of a traffic data prediction device of an embodiment of the present application;
[0036] Figure 4 is a structural schematic diagram of a computer device of an embodiment of the present application;
[0037] Figure 5 is a structural schematic diagram of a storage medium of an embodiment of the present application. DETAILED DESCRIPTION
[0038] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0039] The terms "first", "second", "third" in the present application are only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second", "third" can explicitly or implicitly include at least one of the features. In the description of the present application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise explicitly specified. All directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present application are only used to explain the relative positional relationship, movement condition, etc. between the components in a certain posture (as shown in the drawings), and if the certain posture changes, the directional indications also change accordingly. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, product or device.
[0040] In this document, the term "embodiment" means that the specific features, structures or characteristics described in connection with the embodiment can be included in at least one embodiment of the present application. The phrase appears at various places in the specification does not necessarily all refer to the same embodiment, nor is it necessarily mutually exclusive or alternative embodiments to each other. The person skilled in the art explicitly and implicitly understands that the embodiments described herein can be combined with other embodiments.
[0041] Figure 1is a flowchart of a traffic data prediction method according to an embodiment of the present application. It should be noted that the method of the present application is not limited to the flow order shown Figure 1 as shown. As shown, the traffic data prediction method includes the steps of: Figure 1
[0042] Step S101: Obtain historical traffic data in a preset time period, and convert the historical traffic data into time series data.
[0043] Specifically, before performing traffic data prediction, data collection is first required. In this embodiment, the collected historical traffic data includes traffic flow density, traffic flow, traffic speed, and any other data with spatiotemporal properties. The historical traffic data is then converted into time series data with a graph structure, denoted as where G represents the data in the graph structure, including timestamps. It should be understood that the timestamps include regular timestamps or irregular timestamps. In addition, the topological data of the graph, i.e., the information of the edges of the graph, is also collected.
[0044] Step S102: Input the time series data into a pre-trained traffic data prediction model, which includes an encoder, a decoder, and a corrector. The traffic data prediction model is trained using time series data samples with a graph structure, and the data in the graph structure includes regular timestamps or irregular timestamps.
[0045] Specifically, after obtaining the time series data, the time series data is input into a pre-trained traffic data prediction model for prediction. The traffic data prediction model is trained using time series data samples with a graph structure, and the data in the graph structure includes regular timestamps or irregular timestamps. Therefore, the traffic data prediction model can be applied to the prediction of non-regularly sampled data.
[0046] Step S103: Encode the time series data using the encoder to obtain an encoding vector. The encoder is constructed based on a neural differential equation controlled by a natural interpolation equation or a graph attention mechanism equation.
[0047] Specifically, the encoder of the traffic data prediction model is used to encode the time series data. The encoder can be constructed based on a graph neural differential equation controlled by a natural interpolation equation, or based on a neural differential equation controlled by a graph attention mechanism equation. In this embodiment, the controlled neural differential equation is applied to traffic spatiotemporal data for the first time, and the graph attention network is embedded into the controlled neural differential equation for the first time, to realize the processing of data with spatiotemporal properties.
[0048] Further, in this embodiment, the encoder constructed based on the graph neural differential equation controlled by the natural interpolation equation is represented as:
[0049]
[0050] h n (t+1)=h n (t)+r(t+1);
[0051] Among them, h n (t) represents the hidden state of the nth node at time t, and ζ represents the multilayer perceptron that needs to be trained. This represents the pre-constructed governing equations, where t represents the timestamp, t∈[0,T], σ represents the nonlinear function tanh, i and j represent different nodes, and N represents the number of nodes. i Let a represent the neighborhood of node i, and let softmax and LeakyReLU represent the activation functions. · W, W h h represents the parameter obtained from traffic data prediction. i h j This represents the values of the i-th and j-th nodes after the time series data is converted into a vector and decomposed. □ represents the concatenation of matrices.
[0052] The softmax function is expressed as:
[0053]
[0054] The LeakyReLU function is represented as:
[0055]
[0056] In the softmax and LeakyReLU functions, x represents the input to the two functions, R represents a real number, and a represents the preset parameter.
[0057] The governing equation, in this embodiment, is calculated using a quadratic interpolation method. The quadratic interpolation method formula is expressed as:
[0058]
[0059] Among them, (x i ,y i ), (x i+1 ,y i+1 ), (x i+2 ,y i+2 Let (x, y) represent three known points, and (x, y) represent the point to be found.
[0060] Furthermore, the encoder constructed from the neural differential equations controlled by the graph attention mechanism equation is represented as:
[0061]
[0062] h n (t+1)=h n (t)+r(t+1);
[0063] Among them, h n (t) represents the hidden state of the nth node at time t, and ζ and This represents the multilayer perceptron to be trained, where t represents the timestamp, t∈[0,T], σ represents the nonlinear function tanh, i and j represent different nodes, and N i Let a represent the neighborhood of node i, and let softmax and LeakyReLU represent the activation functions. · W, W h h represents the parameter obtained from traffic data prediction. i h j This represents the values of the i-th and j-th nodes after the time series data is converted into a vector and decomposed. □ represents the concatenation of matrices.
[0064] Furthermore, the final output P1 = [h1(T), h2(T), ..., h] of the encoder can be obtained using the two methods described above. n [(T)], where n represents a node and T represents a preset time period.
[0065] Step S104: Use the decoder to decode the encoded vector to obtain the initial traffic data prediction result for the time period to be predicted. The decoder is built based on a recurrent neural network.
[0066] Specifically, after the encoder encodes the time series data to obtain an encoded vector, the encoded vector is input to the decoder for decoding and prediction to obtain the initial traffic data prediction result. In this embodiment, the decoder is constructed based on a recurrent neural network (GRU).
[0067] Specifically, the decoder built based on a recurrent neural network is represented as:
[0068] r d =σ(υ) r ·[P d-1 W d ]);
[0069] z d =σ(υ) z ·[P d-1 W d ]);
[0070]
[0071]
[0072] Q = σ(W o ·P d );
[0073] where r d , z d , P d are intermediate variables, σ denotes a nonlinear function tanh, υ r , υ z , W o denotes parameters obtained by traffic data prediction, W d denotes the hidden state output by the encoder at time d, Q denotes the output of the decoder, i.e., the initial traffic data prediction result, h d-1 denotes the state at time d-1 in the loop process.
[0074] The initial traffic data prediction result Q is obtained by decoding and predicting the encoding vector of the output of the encoder using the above decoder.
[0075] Step S105: correcting the initial traffic data prediction result using a corrector to obtain a final traffic data prediction result, the corrector being constructed based on a graph neural stochastic differential equation.
[0076] Specifically, after obtaining the initial traffic data prediction result, in order to better simulate the unestimable randomness in traffic prediction, the graph neural stochastic differential equation is used to correct the initial traffic data prediction result, thereby improving the prediction effect.
[0077] Further, the corrector constructed based on the graph neural stochastic differential equation is represented as:
[0078]
[0079] D = ∫μ(Q, D(Q))dQ + ρ(Q, D(Q))·dw(Q);
[0080] wherein, denotes the final traffic data prediction result, Q denotes the initial traffic data prediction result, D denotes the graph neural stochastic differential equation, μ denotes a graph-based model, ρ denotes a multilayer perceptron, and w denotes a random process subject to a normal distribution. In the graph neural stochastic differential equation, Q is the independent variable, and μ(Q, D(Q)), ρ(Q, D(Q)) respectively denote an equation about Q.
[0081] It should be understood that the correction in the embodiment is for the initial traffic data prediction result of a single timestamp, and the purpose is to simulate the randomness in the spatial domain.
[0082] Further, asFigure 2 The traffic data prediction model is pre-trained, and specifically includes:
[0083] Step S201: Obtain time series data samples with a graph structure, and divide the time series data samples into a training set and a validation set.
[0084] Step S202: Divide the time series data samples of the training set into input data and expected data according to time periods.
[0085] Specifically, after obtaining the time series data samples with a graph structure, the data in the time series data samples is first divided according to timestamps, and the entire time series data sample is divided into M samples in a sliding window manner, for example, two hours are used as boundaries, each sample is used for training or validation once, and the M samples are divided into a training set and a validation set in a ratio of 8:2. For a single sample, the previous hour of data is used as input data, and the next hour is used as expected data.
[0086] Step S203: Input the input data to the traffic data prediction model to be trained, which includes an encoder, a decoder, and a corrector.
[0087] Step S204: The input data is encoded using the encoder, and the encoded result is decoded using the decoder to obtain preliminary prediction data.
[0088] Step S205: The preliminary prediction data is corrected using the corrector to obtain final prediction data.
[0089] Step S206: Based on the pre-constructed loss function, the final prediction data, and the expected data, the encoder, the decoder, and the corrector are iteratively trained.
[0090] Specifically, the loss function is represented as:
[0091]
[0092] wherein MSELOSS represents the loss function value, M represents a time period corresponding to the expected data, d represents a time point in the time period, P represents the expected data, and P represents the final prediction data.
[0093] Step S207: The iteratively trained traffic data prediction model is verified using the time series data samples in the validation set, and the traffic data prediction model with the smallest loss function value is retained.
[0094] Specifically, in the training process, the trained model is verified by using the verification set, until the model training ends, the traffic data prediction model corresponding to the minimum loss function value at the time of verification is selected as the final trained traffic data prediction model and saved.
[0095] The traffic data prediction method of the embodiment of the application trains a traffic data prediction model by using time series data samples with a graph structure, the data in the graph structure including regular time stamps or irregular time stamps, that is, the traffic data prediction model has been trained by using irregular sampling data in the training stage, so that the traffic data prediction model can be applied to the prediction of irregular sampling data, which comprehensively considers the time correlation and spatial correlation of traffic data, is a prediction method combining time and space, is more in line with actual application scenarios, and further improves the prediction accuracy by correcting the prediction results output by the decoder through the corrector constructed based on the graph neural random differential equation to reduce the error between the prediction results and the true results.
[0096] Figure 3 is a functional module schematic diagram of the traffic data prediction device of the embodiment of the application. As shown in Figure 3 the traffic data prediction device 20 includes an acquisition module 21, an input module 22, an encoding module 23, a decoding module 24 and a correction module 25.
[0097] The acquisition module 21 is used to acquire historical traffic data in a preset time period and convert the historical traffic data into time series data;
[0098] The input module 22 is used to input the time series data into a pre-trained traffic data prediction model, the traffic data prediction model including an encoder, a decoder and a corrector, the traffic data prediction model being trained by using time series data samples with a graph structure, the data in the graph structure including regular time stamps or irregular time stamps;
[0099] The encoding module 23 is used to encode the time series data by using the encoder to obtain an encoding vector, the encoder being constructed based on a neural differential equation controlled by a natural interpolation equation or a graph attention mechanism equation;
[0100] The decoding module 24 is used to decode the encoding vector by using the decoder to obtain an initial traffic data prediction result of a to-be-predicted time period, the decoder being constructed based on a recurrent neural network;
[0101] The correction module 25 is used to correct the initial traffic data prediction result by using the corrector to obtain a final traffic data prediction result, the corrector being constructed based on a graph neural random differential equation.
[0102] Optionally, the encoder constructed based on the graph neural differential equation controlled by the natural interpolation equation is represented as:
[0103]
[0104] h n (t+1)=h n (t)+r(t+1);
[0105] wherein h n (t) represents the hidden state of the nth node at time t, ζ represents a multi-layer perceptron to be trained, represents a pre-constructed control equation, t represents a time stamp, t∈[0,T], σ represents a nonlinear function tanh, i, j represent different nodes respectively, N i represents the neighborhood of node i, softmax and LeakyReLU represent activation functions, a · , W, W h represent parameters obtained by predicting traffic data, h i , h j represent the values corresponding to the i, j nodes after the time series data is converted into a vector and decomposed, and represents the splicing of matrices.
[0106] Optionally, the encoder constructed by the neural differential equation controlled by the graph attention mechanism equation is represented as:
[0107]
[0108] h n (t+1)=h n (t)+r(t+1);
[0109] wherein h n (t) represents the hidden state of the nth node at time t, ζ and represent a multi-layer perceptron to be trained, t represents a time stamp, t∈[0,T], σ represents a nonlinear function tanh, i, j represent different nodes respectively, N i represents the neighborhood of node i, softmax and LeakyReLU represent activation functions, a · , W, W h represent parameters obtained by predicting traffic data, h i , h j represent the values corresponding to the i, j nodes after the time series data is converted into a vector and decomposed, and represents the splicing of matrices.
[0110] Optionally, the decoder constructed based on the recurrent neural network is represented as:
[0111] r d =σ(υ r ·[P d-1 ,Wd ]);
[0112] z d =σ(υ z ·[P d-1 ,W d ]);
[0113]
[0114]
[0115] Q=σ(W o ·P d );
[0116] where r d , z d , P d are intermediate variables, σ represents a nonlinear function tanh, υ r , υ z , W o represent parameters obtained by traffic data prediction, W d represent the hidden state output by the encoder at time d, Q represents the output of the decoder, that is, the initial traffic data prediction result, h d-1 represents the state at time d-1 in the loop process.
[0117] Optionally, the corrector constructed based on the graph neural stochastic differential equation is represented as:
[0118]
[0119] D=∫μ(Q,D(Q))dQ+ρ(Q,D(Q))·dw(Q);
[0120] where, represents the final traffic data prediction result, Q represents the initial traffic data prediction result, D represents the graph neural stochastic differential equation, μ represents the graph-based model, ρ represents the multilayer perceptron, and w represents a random process subject to a normal distribution.
[0121] Optionally, the traffic data prediction device 20 further includes a training module for pre-training the traffic data prediction model. The training module's operation for training the traffic data prediction model specifically includes: acquiring time-series data samples with a graph structure and dividing the time-series data samples into a training set and a validation set; dividing the time-series data samples in the training set into input data and expected data according to time periods; inputting the input data into the traffic data prediction model to be trained, which includes an encoder, a decoder, and a corrector; encoding the input data using the encoder and then decoding the encoded result using the decoder to obtain preliminary prediction data; correcting the preliminary prediction data using the corrector to obtain final prediction data; iteratively training the encoder, decoder, and corrector based on a pre-constructed loss function, the final prediction data, and the expected data; and validating the iteratively trained traffic data prediction model using time-series data samples in the validation set, and retaining the traffic data prediction model with the smallest loss function value.
[0122] Alternatively, the loss function can be expressed as:
[0123]
[0124] Where MSELOSS represents the loss function value, M represents the time period corresponding to the expected data, d represents a moment in the time period, and P represents the expected data. This represents the final predicted data.
[0125] For further details regarding the implementation techniques of each module in the traffic data prediction device of the above embodiments, please refer to the description in the traffic data prediction method of the above embodiments, which will not be repeated here.
[0126] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For apparatus embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0127] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. Figure 4 As shown, the computer device 30 includes a processor 31 and a memory 32 coupled to the processor 31. The memory 32 stores program instructions. When the program instructions are executed by the processor 31, the processor 31 performs the traffic data prediction method steps described in any of the above embodiments.
[0128] The processor 31 can also be called a CPU (Central Processing Unit). The processor 31 can be an integrated circuit chip having a processing capability of signals. The processor 31 can also be a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application-Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0129] Referring to Figure 5 , Figure 5 A structural diagram of a storage medium of an embodiment of the present application. The storage medium of the embodiment of the present application stores program instructions 41 capable of implementing the traffic data prediction method described above, wherein the program instructions 41 can be stored in the storage medium in the form of a software product, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the method described in various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a magnetic disk or an optical disk, and various media capable of storing program codes, or a computer, a server, a mobile phone, a tablet computer, etc.
[0130] In several embodiments provided in the present application, it should be understood that the disclosed computer device, apparatus and method can be implemented in other manners. For example, the described apparatus embodiments are merely schematic. For example, the division of the units is only a logical function division. There can be another division manner for the actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, devices or units, and can be electrical, mechanical or in other forms.
[0131] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit. The above is only an implementation manner of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent flow transformation, or direct or indirect application in other related technical fields by using the content of the present application specification and drawings, are all included in the patent protection scope of the present application.
Claims
1. A traffic data prediction method characterized by, The method comprises: acquiring historical traffic data in a preset time period and converting the historical traffic data into time series data; inputting the time series data into a pre-trained traffic data prediction model, the traffic data prediction model comprising an encoder, a decoder and a corrector, the traffic data prediction model being trained using time series data samples with a graph structure, data in the graph structure comprising regular time stamps or irregular time stamps; encoding the time series data using the encoder to obtain an encoding vector, the encoder being constructed based on a neural differential equation controlled by a natural interpolation equation or a graph attention mechanism equation; decoding the encoding vector using the decoder to obtain an initial traffic data prediction result for a to-be-predicted time period, the decoder being constructed based on a recurrent neural network; correcting the initial traffic data prediction result using the corrector to obtain a final traffic data prediction result, the corrector being constructed based on a graph neural random differential equation; wherein: the decoder constructed based on the recurrent neural network is represented as: r d = σ(v r · [P d-1 , W d ]) ; z d = σ(υ z · [P d-1 , W d ]) ; Q = σ(W o • P d ); wherein r d , z d , P d are intermediate variables, σ represents a nonlinear function tanh, υ r , υ z , W o represents a parameter obtained by traffic data prediction, W d represents a hidden state output by the encoder at time d, Q represents an output of the decoder, that is, an initial traffic data prediction result, h d-1 represents a state at time d-1 in a loop process the corrector constructed based on the graph neural random differential equation is represented as: D = ∫ μ (Q, D (Q) ) dQ + ρ (Q, D (Q) ) · dw (Q) ; wherein, denotes the final traffic data prediction result, Q denotes the initial traffic data prediction result, D denotes the graph neural stochastic differential equation, μ denotes the graph-based model, ρ denotes the multi-layer perceptron, and w denotes a stochastic process subject to a normal distribution.
2. The traffic data prediction method according to claim 1, characterized in that, the encoder constructed based on the graph neural differential equation controlled by the natural interpolation equation is represented as: h n (t+1) = h n (t) + r(t+1); where h n (t) represents the hidden state of the nth node at time t, ζ represents the multilayer perceptron to be trained, represents the pre-constructed control equation, t represents the timestamp, t ∈ [0, T], σ represents the nonlinear function tanh, i and j represent different nodes, N i represents the neighborhood of node i, softmax and LeakyReLU represent activation functions, a, W, W h represents the parameters obtained by predicting traffic data, h i , h j represents the value corresponding to the i, jth node after the time series data is converted into a vector and decomposed, and represents the splicing of matrices. 3.The traffic data prediction method of claim 1, wherein, the encoder constructed based on the neural differential equation controlled by the graph attention mechanism equation is represented as: h n (t+1) = h n (t) + r(t+1); where h n (t) represents the hidden state of the nth node at time t, ζ and represents a multi-layer perceptron that needs to be trained, t represents a timestamp, t∈[0,T], σ represents a nonlinear function tanh, i, j represent different nodes respectively, N i represents the neighborhood of node i, softmax and LeakyReLU represent activation functions, W, W h represent parameters obtained by predicting traffic data, h i , h j represent the values corresponding to the ith and jth nodes after the time series data is converted into a vector and decomposed, and □ represents the splicing of matrices. 4.The traffic data prediction method of claim 1, wherein, the corrector constructed based on the graph neural random differential equation is represented as: D = ∫ μ (Q, D (Q) ) dQ + ρ (Q, D (Q) ) · dw (Q) ; wherein, denotes the final traffic data prediction result, Q denotes the initial traffic data prediction result, D denotes the graph neural stochastic differential equation, μ denotes the graph-based model, ρ denotes the multi-layer perceptron, and w denotes a stochastic process subject to a normal distribution. 5.The traffic data prediction method of claim 1, wherein, The method further comprises pre-training the traffic data prediction model, specifically comprising: acquiring time series data samples with the graph structure and dividing the time series data samples into a training set and a validation set; dividing the time series data samples of the training set into input data and expected data according to time periods; inputting the input data into a traffic data prediction model to be trained, the traffic data prediction model comprising the encoder, the decoder and the corrector; encoding the input data using the encoder and decoding the encoding result using the decoder to obtain preliminary prediction data; correcting the preliminary prediction data using the corrector to obtain final prediction data; iteratively training the encoder, the decoder and the corrector based on a pre-constructed loss function, the final prediction data and the expected data; verifying the traffic data prediction model after iterative training using time series data samples in the validation set and retaining the traffic data prediction model with the minimum loss function value. 6.The traffic data prediction method of claim 5, wherein, The loss function is represented as: Wherein, MSELOSS represents the loss function value, M represents the time period corresponding to the expected data, d represents a time point in the time period, P represents the expected data, represents the final predicted data.
7. A traffic data prediction device using the traffic data prediction method according to claim 1, characterized by The device comprises: an acquisition module configured to acquire historical traffic data in a preset time period and convert the historical traffic data into time series data; An input module is configured to input the time series data into a pre-trained traffic data prediction model, the traffic data prediction model comprising an encoder, a decoder and a corrector, the traffic data prediction model being trained by using time series data samples with a graph structure, the data in the graph structure comprising regular time stamps or irregular time stamps; An encoding module is configured to encode the time series data by using the encoder to obtain an encoding vector, the encoder being constructed based on a neural differential equation controlled by a natural interpolation equation or a graph attention mechanism equation; A decoding module is configured to decode the encoding vector by using the decoder to obtain an initial traffic data prediction result of a to-be-predicted time period, the decoder being constructed based on a recurrent neural network; A correction module is configured to correct the initial traffic data prediction result by using the corrector to obtain a final traffic data prediction result, the corrector being constructed based on a graph neural random differential equation.
8. A computer device, comprising: The computer device comprises a processor and a memory coupled to the processor, the memory storing program instructions, the program instructions being executed by the processor to cause the processor to perform the steps of the traffic data prediction method according to any one of claims 1-6.
9. A storage medium, characterized by The memory stores program instructions capable of implementing the traffic data prediction method according to any one of claims 1-6.
Citation Information
Patent Citations
Traffic flow prediction method based on neural network
CN111292525A
Traffic prediction method based on enhanced space-time diagram neural network
CN112241814A
Traffic space-time sequence multi-step prediction method and system and storage medium
CN112508173A