Traffic flow prediction method, device, electronic device and storage medium
By constructing a traffic flow prediction model stacked by different types of basic models and meta models, the problem of traffic flow prediction lag in the prior art is solved, and the accuracy of the prediction results is improved.
Patent Information
- Application Number
- CN202411207287.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-08-30
AI Technical Summary
The prior art has lag in predicting road traffic flow, resulting in low accuracy in predicting overall urban traffic flow.
By constructing a traffic flow prediction model formed by at least three different types of base models and at least one metamodel stack, each base model independently processes the input traffic characteristic data and fuses the prediction data of multiple base models through the metamodel to improve the accuracy of the prediction results.
This method can fully reflect the impact of different types of characteristic data on traffic flow, improve the accuracy of traffic flow prediction, and solve the lag problem in using trained neural network prediction.
Smart Images

Figure CN118824014B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application belong to the technical field of traffic engineering and intelligent planning, and in particular, relate to a traffic flow prediction method, device, electronic device and storage medium. Background Art
[0002] The prediction of road traffic flow is of great significance for the effective management of road traffic. Usually, the prediction of traffic flow in the future period is mainly based on the actual current traffic data of the road. For example, the traffic flow in the next period or time can be estimated based on the current traffic flow of the road. If the trained neural network is used to predict the road traffic flow, there is often a lag. This lag in predicting road traffic flow will lead to a low accuracy in the overall traffic flow prediction of urban traffic. Summary of the invention
[0003] In view of this, embodiments of the present application provide a traffic flow prediction method, device, electronic device and storage medium to improve the accuracy of traffic flow prediction results.
[0004] A first aspect of an embodiment of the present application provides a traffic flow prediction method, comprising:
[0005] Acquire traffic characteristic data of a historical period, wherein the traffic characteristic data includes time characteristic data and at least one non-time characteristic data within the historical period;
[0006] The traffic characteristic data is processed using a trained traffic flow prediction model; wherein the traffic flow prediction model is composed of at least three different types of base models and at least one meta-model stacked together, the input data of at least one meta-model is the prediction data output by at least three base models, the input data of at least three base models is the traffic characteristic data, and the feature types of the traffic characteristic data respectively input into at least three base models are not completely the same;
[0007] A traffic flow prediction result output by the traffic flow prediction model is received, wherein the traffic flow prediction result includes prediction data output by at least one meta-model.
[0008] A second aspect of an embodiment of the present application provides a traffic flow prediction device, comprising:
[0009] An acquisition module, used to acquire traffic characteristic data of a historical period, wherein the traffic characteristic data includes time characteristic data and at least one non-time characteristic data within the historical period;
[0010] A processing module, used for processing the traffic feature data using a trained traffic flow prediction model; wherein the traffic flow prediction model is composed of at least three different types of base models and at least one meta-model stacked together, the input data of at least one meta-model is the prediction data output by at least three base models, the input data of at least three base models is the traffic feature data, and the feature types of the traffic feature data respectively input into at least three base models are not completely the same;
[0011] The receiving module is used to receive the traffic flow prediction result output by the traffic flow prediction model, wherein the traffic flow prediction result includes prediction data output by at least one meta-model.
[0012] A third aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the traffic flow prediction method as described in the first aspect above is implemented.
[0013] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the traffic flow prediction method as described in the first aspect above is implemented.
[0014] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on a computer, the computer executes the traffic flow prediction method described in the first aspect.
[0015] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0016] In the embodiment of the present application, by constructing a traffic flow prediction model formed by stacking at least three different types of base models and at least one meta-model, each base model can independently process the input traffic feature data and obtain corresponding prediction data when performing traffic flow prediction. On this basis, the prediction data output by multiple base models are fused through the meta-model, so that the final output traffic flow prediction result can fully reflect the impact of different types of feature data on traffic flow, for example, it can reflect the impact of time feature data and non-time feature data on traffic flow. The embodiment of the present application can also solve the problem of lag in predicting road traffic flow using trained neural networks by setting corresponding types of base models, thereby improving the accuracy of traffic flow prediction results. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 It is a schematic diagram of a training process of a traffic flow prediction model provided in an embodiment of the present application;
[0019] Figure 2 is a schematic diagram of a traffic flow prediction model provided in an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of another traffic flow prediction model provided in an embodiment of the present application;
[0021] Figure 4 is a schematic diagram of a traffic flow prediction method provided in an embodiment of the present application;
[0022] Figure 5 is a schematic diagram of a traffic flow prediction process provided by an embodiment of the present application;
[0023] Figure 6 is a schematic diagram of a traffic flow prediction device provided in an embodiment of the present application;
[0024] Figure 7 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In the following description, specific details such as specific system structures, technologies, etc. are proposed for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from hindering the description of the present application.
[0026] Traffic flow prediction is a typical time series prediction problem. The traffic flow prediction model obtained by training a neural network is used to predict road traffic flow, and the prediction results often have a certain lag.
[0027] For example, suppose that a neural network is trained to establish a To predict The model of traffic flow at each moment, the number of prediction steps of the model n =3. When using the above model to predict traffic flow, if Starting from time , the data series has a downward trend, and the model will The traffic flow is predicted to decrease at all times, that is, the prediction result lags behind by 3 steps. When calculating the flow rate at a certain moment, the input data used is the time window In this time window, the flow rate has no trend at all, so the model cannot accurately predict the downward trend. The data at time is observed, that is, the input data of the model becomes The model can “realize” that the trend has changed. At this time, the model gives The prediction results at the moment have a downward trend. That is, the model prediction lag time is exactly the number of prediction steps n In addition, the jagged fluctuations of traffic flow and the hysteresis further cause the model's predicted values and true values to be staggered, resulting in low accuracy of the prediction results.
[0028] On the other hand, if the traffic flow prediction uses a single time feature as the input data of the model, for example, the prediction model in the above example uses a time window To predict The traffic flow at the time, the input data of the model is the time window The corresponding traffic data, that is, the input data of the model, only contains time features. However, the actual traffic flow on the road is affected by many factors. For example, traffic flow on weekdays may show obvious morning and evening peaks due to commuting reasons, traffic flow during restricted and non-restricted periods on urban roads may also be different, and the timing scheme of traffic lights at road intersections will also affect the traffic flow in each time window, and so on. These factors will directly affect the periodicity and trend of traffic flow. Therefore, the neural network model that only uses a single time feature for traffic flow prediction is difficult to take into account the various characteristics of road traffic flow, which further leads to low accuracy of the prediction results.
[0029] In response to the above problems, the embodiment of the present application is based on the theory of feature design and model integration. Multiple different types of traffic prediction models are integrated together through model integration to jointly participate in the prediction of traffic flow, which can effectively improve the accuracy of traffic flow prediction.
[0030] In an embodiment of the present application, at least three base models and one meta-model can be obtained by training at least three different types of models, and at least three base models and one meta-model can be combined into a traffic flow prediction model by a single-layer stacking method. In this way, when using a traffic flow prediction model based on a single-layer stacking method to predict traffic flow, each base model can be used to predict the traffic flow at a certain moment, and a prediction data can be obtained respectively. Then, the prediction data of each base model is fused using the meta-model, and finally the traffic flow prediction result at that moment is obtained.
[0031] Exemplarily, at least three base models can be trained based on a differential autoregressive model, a deep learning model, and a tree model, respectively.
[0032] Among them, the difference autoregression model has a significant advantage in alleviating the lag of the prediction results. However, this type of model belongs to a univariate autoregression model, which mainly uses time features for prediction and cannot effectively use other features that affect traffic flow. Therefore, the prediction results cannot reflect the impact of other non-time features on traffic flow. For example, since traffic flow is affected by multiple factors such as signal timing, commuting factors, and traffic restriction policies, it is necessary to embed the above-mentioned domain knowledge or expert experience into feature engineering and apply it to the prediction model so that the prediction results can better reflect the impact of these non-time features on traffic flow. If only the difference autoregression model is used to predict traffic flow, these features cannot be effectively used, but this problem can be solved by the tree model. The tree model can embed multiple features into feature engineering, for example, by processing road network features, commuting features, signal timing features and other non-time features, to obtain corresponding prediction results, thereby reflecting the impact of non-time features on traffic flow in the prediction results. On the other hand, traffic flow has a strong front-to-back dependency in time series, and the various features vary greatly in time series. Both the differential autoregression model and the tree model cannot effectively learn the front-to-back dependency and deep features of traffic time series. Deep learning models can be used to solve this problem.
[0033] Therefore, the embodiment of the present application can use the differential autoregression model, the deep learning model and the tree model training to obtain the corresponding base model. In this way, when using each base model for prediction, the advantages of various types of models can be integrated, and the characteristics of different types of models can be fully utilized to process the relevant time feature data and non-time feature data, so that the prediction results can fully reflect the impact of different features on traffic flow. On this basis, the prediction results of different types of models are integrated through the meta-model, and more accurate prediction results can be obtained compared to using a single model for traffic flow prediction.
[0034] In an embodiment of the present application, the traffic characteristic data used for traffic flow prediction may include multiple types of characteristic data. For example, time characteristic data and non-time characteristic data. Among them, the time characteristic data may include historical period characteristic data, same-day trend characteristic data, etc. The historical period characteristic data may refer to the traffic flow data that changes with the time window on any day before the current date. K represents the current date, and the historical period characteristic data may refer to the traffic flow time characteristics of K-1, K-2, K-3, ..., Kn. The same-day trend characteristic data may refer to the traffic flow data in different time windows of the current date. For example, t represents the current moment, and the same-day trend characteristic data may refer to the traffic flow time characteristics in time windows such as t-1, t-2, t-3, ..., tm of the current date K.
[0035] Non-time characteristic data may refer to other characteristic data except time characteristic data. For example, non-time characteristic data may include any one or more of road network characteristic data, commuting characteristic data, signal timing characteristic data, and / or other characteristic data.
[0036] The road network characteristic data may be characteristic data reflecting the actual road conditions of the current road. For example, the road network characteristic data may include data reflecting the road grade, road speed limit or lane channelization conditions (such as straight, left turn, right turn or U-turn, etc.) of the current road.
[0037] Commuter characteristic data can be characteristic data that reflects the commuting status of travelers. These characteristic data can reflect whether the historical period or the period for which traffic flow forecasting is to be conducted belongs to a certain working day or statutory holiday, whether the historical period or the forecast period is the morning and evening travel peak period, etc. In addition, whether the vehicles observed in the historical period are commuter vehicles can also be quantified into commuter characteristic data to play a role in traffic forecasting.
[0038] The signal timing characteristic data may include characteristic data related to the traffic lights on the current road. For example, the signal timing characteristic data may include characteristic data that quantifies information such as whether the current road is controlled by traffic lights, the time cycle of the traffic lights, and the green light signal ratio. The signal timing characteristic data may reflect the changes in the various traffic lights on the current road and the impact of the changes in the traffic lights on the traffic flow.
[0039] Other characteristic data may include characteristic data other than time characteristic data and the non-time characteristic data described above. For example, other characteristic data may be characteristic data reflecting information such as weather conditions and whether a major event has occurred. These characteristic data may be used for traffic flow prediction.
[0040] In a possible implementation of an embodiment of the present application, the identification and processing of the above-mentioned various non-time feature data, such as how to define the morning and evening travel peak periods, how to determine commuter vehicles, and how to analyze signal timing plans, can all be achieved through expert experience and other knowledge. Exemplarily, the expert experience in this field can be used to pre-define or analyze various non-time features so that non-time features that can be used for traffic flow prediction can be accurately identified. In this way, after collecting various types of features, non-time features can be identified by matching the knowledge defined based on expert experience and converted into corresponding non-time feature data.
[0041] In an embodiment of the present application, the traffic characteristic data collected during the historical period can be respectively input into each base model for traffic flow prediction, and each base model can independently process the input traffic characteristic data and output corresponding prediction data. Among them, the feature types of the traffic characteristic data input into each base model may not be completely the same. Exemplarily, the data input into each base model may be feature data of some types or all feature data.
[0042] In a possible implementation of an embodiment of the present application, the number of base models in the traffic flow prediction model may be at least three, such as a first base model, a second base model, and a third base model. Each base model may be trained based on a different type of model, for example, the first base model may be trained based on a differential autoregressive model, the second base model may be trained based on a deep learning model, and the third base model may be trained based on a tree model. The traffic feature data input into different base models may be the same or different.
[0043] In the embodiment of the present application, the traffic characteristic data input into the first base model and the second base model may only include time characteristic data; the traffic characteristic data input into the third base model may include time characteristic data and at least one non-time characteristic data. For example, the traffic characteristic data as the input data of the third base model may include time characteristic data and any one or more of road network characteristic data, commuting characteristic data and / or signal timing characteristic data in the non-time characteristic data.
[0044] Each base model can independently process the input data and output corresponding prediction data. For example, the first base model and the second base model can process the input time feature data respectively and output the first prediction data and the second prediction data; the third base model can process the time feature data and the non-time feature data at the same time and output the third prediction data.
[0045] The prediction data output by each base model can be used as the input data of the meta-model, and the meta-model performs fusion processing to obtain the final traffic flow prediction result. For example, the first prediction data, the second prediction data, and the third prediction data output by the first base model, the second base model, and the third base model in the above example can be input into the meta-model, and the meta-model can perform fusion processing on the above first prediction data, the second prediction data, and the third prediction data to output the final traffic flow prediction result.
[0046] The embodiment of the present application can obtain multiple independent prediction results by using multiple different types of base models to process traffic feature data respectively, and each prediction result can better reflect the characteristics of the corresponding base model. On this basis, the embodiment of the present application uses a meta-model to process the prediction results output by each base model, which can integrate the advantages of multiple different types of base models and improve the accuracy of traffic flow prediction.
[0047] In a possible implementation of the embodiment of the present application, multiple base models and multiple metamodels can also be combined in a multi-layer stacking manner to obtain a traffic flow prediction model. Compared with the traffic flow prediction model formed by a single-layer stacking, which has only one layer (or one) metamodel, the multi-layer stacked traffic flow prediction model can include multiple layers of metamodels, and each layer of metamodel can include one or more metamodels. The prediction data output by each base model can be used as the input data of the first layer metamodel, and the first layer metamodel can fuse the prediction data output by each base model and output the prediction data. The prediction data output by the first layer metamodel can be used as the input data of the second layer metamodel. In this way, the prediction data output by each layer of metamodel will be used as the input data of the next layer of metamodel. After receiving the prediction data output by the previous layer of metamodel, the last layer of metamodel can perform the final fusion processing on these prediction data and output the final prediction result, which is the traffic flow prediction result of the traffic prediction model. Compared with a single-layer stack, by forming a deeper model stack, a more complex model can be used to process various feature data, allowing multiple iterations between the base model and the meta-model, further improving the accuracy and stability of traffic flow prediction.
[0048] The following is a detailed introduction to the training process and actual application process of the traffic flow prediction model in the aforementioned example.
[0049] like Figure 1 FIG. 1 is a schematic diagram of a training process of a traffic flow prediction model provided by an embodiment of the present application. In the model training stage, that is, the stage of training to obtain a traffic flow prediction model, the training of a base model and a meta-model may be specifically included.
[0050] In the embodiment of the present application, the number of base models in the traffic flow prediction model may include multiple base models, and the multiple base models may be obtained by training based on different types of models. For example, the number of base models may be at least three or more, and when the number of base models is three, the three base models may be obtained by training based on different types of models. For example, Figure 1 There are three base models in , namely the first base model, the second base model and the third base model.
[0051] like Figure 1 As shown, the training data used to train the base model can be traffic feature sample data and its corresponding traffic flow labels. Among them, the traffic feature sample data can be traffic feature data as sample data, such as time feature data and non-time feature data, and the non-time feature data can include any one or more of road network feature data, commuting feature data and / or signal timing feature data. The traffic flow label can be the true value of the traffic flow at a future moment in the time window where the traffic feature sample data is located. For example, the traffic feature data collected in a certain historical period and its corresponding true value of traffic flow can be the actual traffic flow value at a future moment in the historical period. The correspondence between the above historical period and the future moment can be determined according to the prediction steps of the model. For example, if the prediction step number n =3, the time window of the traffic characteristic sample data is the historical period The relevant data in the future time can be referred to as The actual traffic flow value at the moment.
[0052] In the embodiment of the present application, a large amount of traffic characteristic data and its corresponding actual traffic flow values in the historical period can be collected as training data for training various base models. Considering that different types of base models have different requirements for processing traffic characteristic data, for example, the differential autoregressive model only supports processing of a single variable to predict traffic flow; the prediction process of the tree model supports processing of multiple variables, so it is possible to create a variety of different types of traffic characteristic data sets as training sets, so that a variety of different types of base models can be trained through the same training set.
[0053] In a possible implementation of an embodiment of the present application, first, models that can be used for traffic flow prediction can be constructed based on a variety of different types of models, and then these constructed models can be trained using training data to obtain a base model that can be used as a component of the traffic flow prediction model of the embodiment of the present application. The above-mentioned various types of models may include differential autoregression models, deep learning models, and tree models. Among them, the differential autoregression model is mainly used to alleviate the lag problem of traffic flow prediction; the deep learning model is mainly used to learn the front-end dependency and deep features of the traffic flow time series; the tree model is mainly used for feature embedding, that is, embedding road network features, commuting features, signal timing features and other features into feature engineering, and applying them to the traffic prediction model.
[0054] For example, Figure 1 As shown, firstly, three models for traffic flow prediction can be constructed based on the differential autoregression model, the deep learning model, and the tree model. Then, the above models can be trained using training data to obtain the first base model, the second base model, and the third base model.
[0055] In a possible implementation of the embodiment of the present application, when training the first model constructed based on the differential autoregressive model and the second model constructed based on the deep learning model, the training data may only include traffic feature sample data of the time feature type, that is, only the time feature sample data is used to train the above-mentioned first model and the second model to obtain the first base model and the second base model. When training the third model constructed based on the tree model, the training data may simultaneously include traffic feature sample data of the time feature type and other non-time feature types, that is, the time feature sample data and at least one non-time feature sample data are used to train the above-mentioned third model to obtain the third base model. The data output by each base model during the training process is the predicted traffic flow at the future moment. By comparing the predicted traffic flow output during the training process with the actual traffic flow true value in the training data, the error of the base model can be evaluated. When the error is large, the base model can be improved by continuous iteration, correction of model parameters and other processes until the error between the predicted traffic flow output at the end and the actual traffic flow true value in the training data is less than a certain value, at which time the training of the base model can be stopped.
[0056] The number of base models of a certain type in the traffic flow prediction model may include one or more. For example, the base model obtained by training based on the differential autoregressive model may include only one or more base models; the base model obtained by training based on the deep learning model and the tree model may also include only one or more base models.
[0057] In a possible implementation of an embodiment of the present application, the base model constructed and trained based on the differential autoregressive model may be a differential autoregressive moving average model ARIMA, the base model constructed and trained based on the deep learning model may be a long short-term memory neural network model LSTM, and the base model constructed and trained based on the tree model may be a random forest model.
[0058] The ARIMA model is a difference autoregressive moving average model involving parameters such as p, q, and d. Among them, p represents the order of the autoregressive term, q represents the order of the moving average term, and d represents the order of differences required for the time series to become a stationary series.
[0059] In the process of using the ARIMA model to build and train the first base model, the model structure can be defined first, the order (p, d, q) can be determined, and the ARIMA (p, d, q) model can be constructed. Through parameter estimation, the coefficients in the model, such as the coefficients of the autoregressive term and the coefficients of the moving average term, can be determined. Then, the constructed ARIMA (p, d, q) model can be trained using the training data to obtain the first base model. The above training process is to use the traffic feature sample data in the training data as the input data of the ARIMA (p, d, q) model to predict traffic flow, output the corresponding prediction data, and continuously iterate and optimize the ARIMA (p, d, q) model.
[0060] In the specific training process, the use of the ARIMA (p, d, q) model for traffic flow prediction requires checking the stationarity of the input data, i.e., the traffic feature sample data. Checking stationarity is part of data preprocessing, which means that it is necessary to check whether the time series (time feature sample data) as the traffic feature sample data is stationary. If the input time series is not stationary, it is necessary to perform a difference operation on the time series until the time series after the difference becomes stationary. The order d of the difference operation is the "integral" part in the ARIMA model. In addition, data preprocessing also includes determining the order of the model, that is, determining the order of the autoregressive term (p) and the moving average term (q) by analyzing the autocorrelation graph and the partial autocorrelation graph. These orders can reflect the degree of influence of the historical values and error terms in the model.
[0061] In a possible implementation of an embodiment of the present application, in the process of training the ARIMA (p, d, q) model, the optimal model can be selected by trying different (p, d, q) combinations. The optimal model may be a model in which the error between the output prediction data obtained through training iteration and the actual traffic flow true value meets the corresponding requirements. For different input data, the (p, d, q) combination under the optimal model may be different. Therefore, during the model training process, when the optimal model is obtained through training, the characteristics of the time series input at this time, such as the relevant characteristics of the autocorrelation graph and the partial autocorrelation graph, and the corresponding order can be recorded. In this way, when the first base model is actually applied to predict traffic flow, the optimal (p, d, q) combination can be determined based on the input time feature data, and the first base model with the optimal (p, d, q) combination can be used to predict traffic flow.
[0062] Traffic flow prediction is performed using the first base model built and trained based on the ARIMA (p, d, q) model. The input data can be the time characteristic data of the historical period. The traffic flow at future moments is predicted through single-step or multi-step prediction.
[0063] The LSTM model is a long short-term memory neural network model, which is essentially a specific form of recurrent neural network (RNN). The LSTM model can add three logical control units, namely input gate, output gate, and forget gate, to the basic structure of RNN, so that the recurrent neural network can effectively utilize long-distance temporal information.
[0064] In the process of using the LSTM model to build and train the second base model, the LSTM model can be first built by defining the network architecture and input format settings. Among them, defining the network architecture can refer to designing the network structure of the LSTM model, including the input layer, LSTM layer (which can contain multiple LSTM unit stacks), output layer, etc.; according to the complexity of the task and the characteristics of the data, determine the number of LSTM units, whether to use bidirectional LSTM, whether to add a Dropout layer, etc. Input format settings can refer to the need to appropriately reshape the format of the input data because the LSTM model requires the input data to have a specific three-dimensional shape (number of samples, time steps, and number of features). Through the above processing, an LSTM model that can predict traffic flow can be constructed.
[0065] Then, the training data can be used to train the constructed LSTM model to obtain the second base model. The above training process is to use the traffic feature sample data in the training data as the input data of the LSTM model to predict traffic flow, output the corresponding prediction data, and continuously iterate and optimize the LSTM model.
[0066] In the specific training process, using the LSTM model for traffic flow prediction requires preprocessing of the input data, namely the traffic feature sample data. For example, data cleaning, feature engineering, feature standardization / normalization, and sequence partitioning. Among them, data cleaning mainly deals with missing values and outliers in the traffic feature sample data; feature engineering refers to extracting time features from the traffic feature sample data, such as dividing the time series into appropriate time intervals (such as every hour, every day) as needed and encoding time features (such as periodic features); feature standardization / normalization refers to scaling the numerical features so that they fall into a smaller range, which helps to accelerate the training process and improve model performance; sequence partitioning refers to dividing the time series in the traffic feature sample data into two parts of data, the training set and the test set. Usually, the former part of the data is used as training data, and the latter part of the data is used as test data to evaluate the model.
[0067] In a possible implementation of the embodiment of the present application, during the training of the LSTM model, the loss function (such as the mean square error MSE loss function), optimizer (such as the Adam optimizer) and evaluation index (such as MAE or RMSE and other indicators) can be determined to complete the model compilation, and the traffic feature sample data is input into the constructed LSTM model for training, and the model parameters are updated through mechanisms such as back propagation and gradient descent to reduce the value of the loss function. When the value of the loss function meets the corresponding requirements, the training of the LSTM model can be terminated, and the LSTM model trained at this time is used as the second base model in the traffic flow prediction model.
[0068] Traffic flow prediction is performed using the second base model built and trained based on the LSTM model. The input data can be the time feature data of the historical period. The traffic flow at the future moment is predicted by single-step or multi-step prediction. For multi-step prediction, the second base model can adopt a recursive method and use the prediction value of the previous step as one of the inputs of the next step. The prediction value can be the traffic flow prediction data at the future moment output by processing the input time series.
[0069] The random forest model can be a model that can process multiple types of features by integrating multiple decision trees based on the idea of ensemble learning. For example, the third base model constructed and trained based on the random forest model can process multiple types of feature data including time features, road network features, commuting features, and signal timing features, so as to predict traffic flow at future times.
[0070] In the process of using the random forest model to build and train the third base model, a random forest model can be first built through two parts: random feature selection and building a decision tree forest. The above-mentioned random feature selection can mean that in the random forest, for the construction of each decision tree, a part of the features are randomly selected from all the features to find the best split point, which increases the diversity and generalization ability of the model; building a decision tree forest can mean extracting samples with replacement from the training set through a self-service sampling method (such as Bootstraping), and building a decision tree for each sample set. Each tree is trained independently, and the randomness of the features is considered during the construction process.
[0071] After constructing a random forest model that can be used for traffic flow prediction, the constructed random forest model can be trained using training data to obtain a third base model.
[0072] In the specific training process, using the random forest model for traffic flow prediction requires preprocessing of the input data, i.e., traffic feature sample data. For example, data cleaning, feature construction, and feature standardization / normalization. It should be noted that, unlike the training of the ARIMA (p, d, q) model and the LSTM model, which mainly uses the time feature data or time series in the traffic feature sample data, the training of the random forest model requires the use of the time feature data and non-time feature data in the traffic feature sample data.
[0073] The preprocessed traffic feature sample data can be divided into two parts: a training set and a test set. Usually, 70%-80% of the traffic feature sample data can be used as a training set to train the model, and the remaining data can be used as a test set to test the model performance.
[0074] When training a random forest model, each training subset can be input into all decision trees in the forest to obtain the prediction results of each decision tree. These prediction results can be the prediction data output by each decision tree in the random forest after processing the traffic feature sample data in the training subset, that is, the predicted value of traffic flow at the future moment. The prediction result of the entire random forest model can be obtained by taking the average of the prediction results of all decision trees, or by voting of multiple decision trees. The random forest model can be optimized by comparing and analyzing the true value of traffic flow at the future moment with the prediction results, and by iteration and other methods. The trained random forest model can be used as the third base model in the traffic flow prediction model.
[0075] On the other hand, in the process of training each base model, the meta-model in the traffic flow prediction model can be trained synchronously, and the training data required for training the meta-model can be the prediction data output by each base model. That is, the traffic feature sample data as training data can be input into a variety of different types of models for training to obtain the base model. In this process, each base model will output corresponding prediction data. For example, the first base model, the second base model, and the third base model mentioned above will all output prediction data, and these prediction data can be input into the constructed meta-model as the input data of the meta-model to train the meta-model.
[0076] like Figure 1 As shown, the output data of the first base model, the second base model and the third base model are prediction data X1, prediction data X2 and prediction data X3 respectively. By processing these prediction data into a feature set [X1, X2, X3], the feature set [X1, X2, X3] can be used as input data for training the meta-model.
[0077] In a possible implementation of the embodiment of the present application, the number of meta-models obtained through training may include only one or more. When the number of meta-models includes only one, the meta-model may be combined with multiple base models, such as the first base model, the second base model, and the third base model in the aforementioned example, to form a single-layer stacked traffic flow prediction model. Figure 2 , which is a schematic diagram of a traffic flow prediction model provided in an embodiment of the present application. Figure 2 The traffic flow prediction model shown is a prediction model formed in a single-layer stacking form, which includes three base models, namely Figure 2 In the base model 21, base model 22 and base model 23. When predicting traffic flow, each base model can output corresponding prediction data after processing the traffic feature data, such as Figure 2On this basis, the prediction data 211, the prediction data 221 and the prediction data 231 are fused through the meta-model 20 to obtain the final prediction result of the single-layer stacked traffic flow prediction model.
[0078] The traffic flow prediction model with a single-layer stacking structure has only one meta-model, and the output data of all base models will be directly used as the input data of this meta-model. In addition, under the single-layer stacking structure, the model structure is relatively simple, and there is no direct interaction between the base models. The prediction data output by each base model will be summarized into the meta-model at one time, which improves the efficiency of traffic flow prediction.
[0079] In the embodiment of the present application, when the number of meta-models includes multiple, the multiple meta-models can be combined with multiple base models to form a multi-layer stacked traffic flow prediction model. Figure 3 FIG. 1 is a schematic diagram of another traffic flow prediction model provided in an embodiment of the present application. Figure 3 The traffic flow prediction model shown is a prediction model formed in a multi-layer stacking form, which includes four base models, namely Figure 3 In the base model 31, base model 32, base model 33 and base model 34. When performing traffic flow prediction, each base model can output corresponding prediction data after processing the traffic feature data, such as Figure 3 The predicted data 311, predicted data 321, predicted data 331 and predicted data 341 in. Figure 3 There are four metamodels in total, which form a two-layer structure. The first layer of metamodels includes Figure 3 Metamodel 301, metamodel 302 and metamodel 303 in the above. These metamodels 301, 302 and 303 can respectively fuse the above-mentioned prediction data 311, prediction data 321, prediction data 331 and prediction data 341 to obtain prediction data 3011, prediction data 3021 and prediction data 3031 respectively. On this basis, Figure 3 The last metamodel 30 in the above example can be used to modify the previous metamodel, i.e. Figure 3 The prediction data output by metamodel 301, metamodel 302 and metamodel 303 are fused to obtain the final prediction result of the multi-layer stacked traffic flow prediction model.
[0080] In a possible implementation of the embodiment of the present application, the meta-model can be obtained by training based on multiple types of linear or nonlinear models. Specifically, a linear or nonlinear model that can be used for traffic flow prediction can be first constructed, and then in the process of training each base model, the prediction data output by the base model is input into the above linear or nonlinear model for synchronous training, so as to obtain the required meta-model.
[0081] As an example of the embodiment of the present application, the metamodel can be trained based on a random forest model, an LSTM model, a gradient boosting decision tree GBDT model, a distributed gradient boosting library XGBoost model, a gated recurrent unit GRU model, or a temporal convolutional network TCN model. The embodiment of the present application does not limit the type of metamodel. Figure 1 As shown, Figure 1 The meta-model in is the random forest model.
[0082] Similar to single-layer stacking, multi-layer stacking also improves the accuracy and stability of traffic flow prediction results through the complementarity between each base model and meta-model, thereby achieving performance that exceeds that of a single model. In addition, compared to single-layer stacking, a deeper model stack can be formed under the multi-layer stacking structure. This structure is more complex and allows multiple iterations between each base model and meta-model, thereby achieving a comprehensive analysis of related data or features. Moreover, as the model level increases, there can be more indirect interactions between each base model and meta-model. The meta-model of each level can be learned based on the comprehensive prediction results of the meta-model of the previous level. This helps the model capture deeper features and achieve better results in dealing with traffic flow prediction problems in complex scenarios.
[0083] As an example of an embodiment of the present application, assuming that three base models are obtained based on the training of traffic feature sample data, namely ARIMA model model1, random forest model model2 and LSTM model model3, then the traffic feature sample data is input into model1, model2 and model3 respectively for traffic flow prediction, and the training set prediction results volume1 output by model1, the training set prediction results volume2 output by model2 and the training set prediction results volume3 output by model3 can be obtained. Then, by using volume1, volume2 and volume3 as the input data of the meta-model, that is, the input features of the meta-model are 3 items, the meta-model training can be performed based on the prediction results of each base model, and finally the meta-model model4 can be obtained.
[0084] So far, the training of each base model and meta-model in the traffic flow prediction model of the embodiment of the present application has been completed, that is, the training of the traffic flow prediction model has been completed. The trained traffic flow prediction model can be used to perform traffic flow prediction later.
[0085] In the model application stage, the specific process of using the model for traffic flow prediction is different depending on the stacking form of the traffic flow prediction model obtained through training.
[0086] In a possible implementation of the embodiment of the present application, the following may be applied: Figure 2 The traffic flow prediction model in the form of a single-layer stack is used to predict traffic flow. In the prediction process, each base model is as follows Figure 2 The base models 21, 22 and 23 in the above formula can independently process the collected traffic characteristic data and output corresponding prediction data, that is, Figure 2 The predicted data 211, predicted data 221 and predicted data 231 in FIG. It should be noted that the traffic feature data may include time feature data and non-time feature data, and the trained traffic flow prediction model may include a base model only for processing time feature data, such as Figure 2 The base model 21 and the base model 22 can be constructed and trained based on the differential autoregression model and the deep learning model respectively. When predicting traffic flow, the traffic feature data input into the base model 21 and the base model 22 can only include time feature data. Figure 2 The base model 23 in the example can be constructed and trained based on a tree model. When predicting traffic flow, the traffic feature data input into the base model 23 can include both time feature data and non-time feature data. Each base model can output corresponding prediction data after processing the input traffic feature data, such as Figure 2 On this basis, the prediction data 211, the prediction data 221 and the prediction data 231 are fused through the meta-model 20 to obtain the final prediction result of the single-layer stacked traffic flow prediction model.
[0087] In another possible implementation of the embodiment of the present application, the following may be applied: Figure 3 The multi-layer stacked traffic flow prediction model shown in the figure is used to predict traffic flow. In the prediction process, each base model is as follows Figure 3 The base models 31, 32, 33 and 34 in the above formula can independently process the collected traffic characteristic data and output corresponding prediction data, that is, Figure 3 The predicted data 311, the predicted data 321, the predicted data 331 and the predicted data 341 in the embodiment. Figure 3 The base model 31 and the base model 32 can be constructed and trained based on the differential autoregression model and the deep learning model respectively. When predicting traffic flow, the traffic feature data input into the base model 31 and the base model 32 can only include time feature data. Figure 3 The base model 33 in the example may be constructed and trained based on a tree model. When predicting traffic flow, the traffic feature data input into the base model 33 may include both time feature data and non-time feature data. Figure 3 The base model 34 may be constructed and trained based on other types of models. When predicting traffic flow, the traffic feature data input into the base model 34 may include both time feature data and non-time feature data; or, it may include only time feature data or only one or more types of non-time feature data, depending on the type of the base model 34, which is not limited in the embodiments of the present application.
[0088] Figure 3 Each base model in can output corresponding prediction data after processing the input traffic characteristic data, such as Figure 3 The predicted data 311, predicted data 321, predicted data 331 and predicted data 341 in the above. On this basis, Figure 3 The first-layer metamodels, namely metamodel 301, metamodel 302 and metamodel 303, can fuse the above-mentioned prediction data 311, prediction data 321, prediction data 331 and prediction data 341 to obtain prediction data 3011, prediction data 3021 and prediction data 3031 respectively. Then, Figure 3 The last metamodel 30 in the above example can fuse the prediction data output by the previous metamodel, namely, prediction data 3011, prediction data 3021 and prediction data 3031, so as to obtain the final prediction result of the multi-layer stacked traffic flow prediction model. Figure 3 Each meta-model in the can be constructed and trained based on models of the same type or different types. The embodiments of the present application do not limit the specific type of each meta-model.
[0089] By training a traffic flow prediction model with a single-layer stacking structure or a multi-layer stacking structure, the model can be used to predict road traffic flow in the application stage. In a possible implementation of an embodiment of the present application, whether to use a single-layer stacking model or a multi-layer stacking model in the application stage can be determined based on the actual model training effect. For example, in the model training stage, sample data can be used to train a model with a single-layer stacking structure and a model with a multi-layer stacking structure at the same time. By comparing the errors of the two models obtained through training with a validation set, the model with a smaller error can be selected for subsequent predictions.
[0090] In a possible implementation of the embodiment of the present application, before using the trained traffic flow prediction model to predict traffic flow, it is also possible to determine which structure of the model to use based on influencing factors, for example, whether to use a single-layer stacked model or a multi-layer stacked model to predict traffic flow.
[0091] Exemplarily, the influencing factors may include one or more of city size, traffic data distribution, and traffic organization mode. City size can be used to evaluate the size of a city, such as a large city, a small or medium-sized city, a town, a village, etc. Traffic data distribution can be used to indicate the distribution pattern of the data currently obtained for traffic flow prediction, including scattered distribution or regular distribution, etc. Traffic organization mode can indicate whether the traffic structure of the current area is diversified, including a simple mode or a complex mode, etc.
[0092] In an embodiment of the present application, the size of a city can be predetermined by relevant information. For example, the current administrative division is determined based on the positioning information, and combined with the type of the administrative region, it is determined whether the current area belongs to a large city or a small or medium-sized city. Generally, when the city is large, such as a large city, the traffic volume is often large, the road structure will be more complex, and more traffic feature data will be collected when predicting traffic flow. In view of this situation, a prediction model with a multi-layer stacking structure can be preferentially used. For cities with a size of small and medium-sized cities or towns, a single-layer stacking structure model can be used for prediction.
[0093] The distribution of traffic data can be determined based on the collected traffic characteristic data. By analyzing the traffic characteristic data, it can be determined whether the traffic data distribution is scattered or regular. For example, rapid data processing can be used to determine whether the collected traffic data of various characteristics have a certain regularity. If the traffic data has regularity, the current traffic data distribution can be considered to be regularly distributed, otherwise it can be considered to be scattered. It is more difficult to process scattered traffic data, and it may take multiple iterations to obtain in-depth information that can be used to predict traffic processes. Therefore, when the traffic data distribution is scattered, a prediction model with a multi-layer stacking structure can be used to process it to obtain the final traffic flow prediction result. For regularly distributed traffic data, a single-layer stacking structure model can be used to predict traffic flow.
[0094] Traffic organization mode can be used to distinguish whether the road traffic structure is single. For example, if a certain area only has ordinary-level roads, it can be considered that the traffic organization mode of the area is relatively simple; if a certain area not only has ordinary-level roads, but also includes urban expressways, slow lanes, viaducts and other forms or levels of roads, it can be considered that the traffic organization mode of the area is diversified and complex. Based on the data of various types of traffic data collected under the complex traffic organization mode, more complex analysis and iteration processes are required. Therefore, a multi-layer stacked structure prediction model can be used for prediction to improve the accuracy of the final output traffic flow prediction results.
[0095] Therefore, in an embodiment of the present application, when any of the conditions that the city scale is a large city, the traffic data distribution is scattered, or the traffic organization mode is a complex mode is met, it can be determined that the traffic flow prediction model to be used is a multi-layer stacked model, that is, the traffic flow prediction model introduced above, which is composed of at least three base models and at least two layers of meta-models in the form of a multi-layer stack, is used to perform traffic flow prediction.
[0096] In a possible implementation of the embodiment of the present application, before various types of traffic feature data are respectively input into the corresponding base models for traffic flow prediction, it can be determined based on influencing factors whether the structure of the traffic flow prediction model to be used is a single-layer stacking structure or a multi-layer stacking result. If it is determined to adopt a prediction model with a single-layer stacking structure, the various types of traffic feature data obtained can be input into each base model of the single-layer stacking prediction model for processing, and the prediction results of each base model are aggregated through metamodel fusion to output the final traffic flow prediction result; if it is determined to adopt a prediction model with a multi-layer stacking structure, the various types of traffic feature data obtained can be input into each base model of the multi-layer stacking prediction model for processing, and through continuous iteration of multi-layer metamodels, the final traffic flow prediction result is output by the last layer of metamodel.
[0097] The embodiment of the present application constructs a traffic flow prediction model formed by stacking at least three different types of base models and at least one meta-model. When performing traffic flow prediction, each base model can independently process the input traffic feature data and obtain corresponding prediction data. On this basis, the prediction data output by multiple base models are fused through the meta-model, so that the final output traffic flow prediction result can fully reflect the impact of different types of feature data on traffic flow, for example, it can reflect the impact of time feature data and non-time feature data on traffic flow. The embodiment of the present application can also solve the problem of lag in using trained neural networks for traffic flow prediction by setting corresponding types of base models, thereby improving the accuracy of traffic flow prediction results.
[0098] In combination with the introduction of the above embodiments, refer to Figure 4 , shows a schematic diagram of a traffic flow prediction method provided by an embodiment of the present application, which may specifically include the following steps:
[0099] S401. Obtain traffic characteristic data of a historical period, wherein the traffic characteristic data includes time characteristic data and at least one type of non-time characteristic data within the historical period.
[0100] The embodiments of the present application can be applied to electronic devices, that is, the execution subject of the embodiments of the present application can be an electronic device, and the electronic device can predict the traffic flow of a road at a certain moment or time window in the future by executing the various steps of the embodiments of the present application. The above electronic device can be a mobile phone, a smart wearable device, a car machine or a car terminal, a server, etc. The embodiments of the present application do not limit the type of electronic device.
[0101] In an embodiment of the present application, the prediction of traffic flow can be obtained by processing the traffic characteristic data of the historical period by the electronic device. The above historical period can be a certain period in the past compared to the moment or time window to be predicted. Since what needs to be predicted is the traffic flow of the road in the future moment or time window, the current moment or a time window including the current moment also belongs to the historical period compared to the future moment or time window, that is, the traffic characteristic data currently collected also belongs to the traffic characteristic data of the historical period.
[0102] The traffic characteristic data in the embodiments of the present application may include time characteristic data and at least one non-time characteristic data. The at least one non-time characteristic data may be any one or more of road network characteristic data, commuting characteristic data and / or signal timing characteristic data. The traffic characteristic data of various characteristic types used for traffic flow prediction can be referred to the introduction in the aforementioned embodiments, which will not be repeated here.
[0103] The electronic device can obtain traffic characteristic data of the historical period through its own sensor device or through the connection established with other devices or platforms. The embodiment of the present application does not limit how the electronic device obtains the traffic characteristic data.
[0104] S402. Use the trained traffic flow prediction model to process the traffic feature data; wherein the traffic flow prediction model is composed of at least three different types of base models and at least one meta-model stacked together, the input data of at least one meta-model is the prediction data output by at least three base models, the input data of at least three base models is the traffic feature data, and the feature types of the traffic feature data input into at least three base models are not completely the same.
[0105] In combination with the introduction of the aforementioned embodiments, the electronic device of the embodiments of the present application may be configured with a trained traffic flow prediction model, and the traffic feature data acquired by the electronic device may be input into the traffic flow prediction model for processing, and the traffic flow prediction model may output the corresponding prediction results.
[0106] In an embodiment of the present application, the traffic flow prediction model configured in the electronic device may be composed of at least three different types of base models and at least one meta-model stacked together. The input data of at least one meta-model may be the prediction data output by at least three base models, and the input data of at least three base models may be the traffic feature data acquired by the electronic device. Furthermore, the feature types of the traffic feature data respectively input into at least three base models may not be completely the same.
[0107] Exemplarily, the three base models may include a first base model, a second base model, and a third base model, and the three base models may be constructed and trained based on three different types of models. When traffic feature data is acquired and traffic flow prediction is required, the electronic device may input data with different feature types in the traffic feature data into corresponding base models, and each base model independently processes the received feature data and outputs corresponding prediction data.
[0108] In a possible implementation of the embodiment of the present application, when the electronic device uses the trained traffic flow prediction model to process the traffic feature data, it can first determine the feature type of the traffic feature data to be processed by each base model. For example, determine the feature type that the first base model, the second base model, and the third base model in the above example are good at processing, and input the traffic feature data with the feature type into the corresponding base model for traffic flow prediction.
[0109] In an embodiment of the present application, in the trained traffic flow prediction model, there may be at least one base model whose input data only includes time feature data within a historical period, and there may be at least one base model whose input data includes both time feature data within a historical period and at least one non-time feature data.
[0110] Exemplarily, when the traffic flow prediction model includes the first base model, the second base model and the third base model, the first base model and the second base model may be base models mainly used to process time feature data, while the third base model may be a base model capable of processing both time feature data and non-time feature data. Therefore, the input data of the first base model and the second base model may be time feature data, and the input data of the third base model may include both time feature data and non-time feature data.
[0111] Each base model can independently process the input data and output corresponding prediction data. Then, the electronic device can input the prediction data obtained by processing the traffic characteristic data by each base model into at least one meta-model for fusion processing, thereby outputting the final traffic flow prediction result.
[0112] In a possible implementation of the embodiment of the present application, the at least three base models included in the traffic flow prediction model may be a first base model, a second base model, and a third base model. Among them, the first base model may be obtained by training based on a differential autoregression model, the second base model may be obtained by training based on a deep learning model, and the third base model may be obtained by training based on a tree model. For how to train each base model, please refer to the introduction in the aforementioned embodiments, which will not be repeated here.
[0113] Therefore, when predicting traffic flow, the electronic device can input the time feature data in the traffic feature data into the first base model and the second base model for processing respectively to obtain first prediction data and second prediction data; and input the time feature data and at least one non-time feature data in the traffic feature data into the third base model for processing to obtain third prediction data.
[0114] Of course, the traffic flow prediction model may also include base models constructed and trained based on other models. These base models can process one or more feature types of data in the traffic feature data according to their own characteristics and output corresponding prediction data. The embodiments of the present application are not limited to this.
[0115] In a possible implementation of the embodiment of the present application, the traffic flow prediction model may be composed of at least three base models and one meta-model in a single-layer stacked form. For example, the structure of the single-layer stacked traffic flow prediction model can be seen in Figure 2 When using a single-layer stacked traffic flow prediction model to predict traffic flow, the electronic device can determine the weights of the first base model, the second base model, and the third base model in this prediction based on at least one non-time feature data in the historical period, and then perform fusion processing on the prediction data output by each base model according to the weight. In this way, the traffic flow prediction result can be the prediction data output by the meta-model.
[0116] Exemplarily, the electronic device can adjust the weight of each base model in this prediction according to the amount of non-time feature data obtained. For example, when the amount of non-time feature data obtained is large, the weight of the base model used to simultaneously process time feature data and non-time feature data can be appropriately increased, such as increasing the weight of the third base model in the aforementioned example and relatively reducing the weight of the first base model and the second base model.
[0117] Alternatively, the electronic device can identify the acquired non-time feature data and determine the size of the role played by the currently acquired specific type of non-time feature data in traffic flow prediction. If these non-time feature data have a greater effect on traffic flow prediction, the weight of the third base model can be appropriately increased, and the weight of the first base model and / or the second base model can be relatively reduced. The size of the role played by the above-mentioned non-time feature data in traffic flow prediction can be pre-set according to the feature type of the non-time feature data. In addition, different types of non-time feature data can influence each other and be used together to determine the weight of each base model in this prediction. For example, the currently acquired non-time feature data includes road network feature data and commuting feature data. If it can be determined based on the road network feature data that the road for which the current traffic flow is to be predicted is a rural road, it can be determined that the commuting feature data has a lower effect on traffic flow prediction on rural roads. At this time, the electronic device can reduce the weight of the base model used to process the above-mentioned commuting feature data in this prediction.
[0118] In another possible implementation of the embodiment of the present application, the traffic flow prediction model may also be composed of at least three base models and at least two layers of meta-models in a multi-layer stacked form. In the multi-layer stacked traffic flow prediction model, the number of meta-models in each layer includes at least one. For example, the structure of the multi-layer stacked traffic flow prediction model can be seen in Figure 3 shown.
[0119] When using a multi-layer stacked traffic flow prediction model to predict traffic flow, the electronic device can input the prediction data output by each base model into the meta-model of the first layer to predict traffic flow. In the multi-layer stacked traffic flow prediction model, the prediction data output by the meta-model of each layer for traffic flow prediction will be used as the input data of the meta-model of the next layer, and the meta-model of the next layer will perform traffic flow prediction and output corresponding prediction data. In this way, after the fusion processing of the multi-layer meta-model, the electronic device can use the meta-model of the last layer in the traffic flow prediction model to fuse the prediction data output by the meta-model of the previous layer. At this time, the traffic flow prediction result can be the prediction data output by the meta-model of the last layer.
[0120] S403: Receive a traffic flow prediction result output by the traffic flow prediction model, wherein the traffic flow prediction result includes prediction data output by at least one meta-model.
[0121] In an embodiment of the present application, the electronic device can receive the traffic flow prediction result output by the traffic flow prediction model, and use the prediction result as the final prediction result.
[0122] In an embodiment of the present application, by constructing a traffic flow prediction model formed by stacking at least three different types of base models and at least one meta-model, the complementarity between different types of models can be utilized to improve the accuracy and stability of the model in predicting traffic flow.
[0123] To facilitate understanding, the traffic flow prediction method provided in the embodiment of the present application is introduced below with reference to a specific example.
[0124] like Figure 5 FIG. 1 is a schematic diagram of a traffic flow prediction process provided by an embodiment of the present application. Figure 5 The prediction process shown is the process of using the traffic flow prediction model introduced in the above embodiments to perform prediction. Figure 5 The traffic flow prediction model in is a single-layer stacked prediction model. Figure 5 Three base models and one meta-model are used, namely base model 51, base model 52, base model 53 and meta-model 50. The three base models are constructed and trained based on ARIMA model, LSTM model and random forest model respectively, and meta-model 50 is constructed and trained based on random forest model.
[0125] When making traffic flow predictions, you can first obtain traffic characteristic data for historical time periods, for example, obtain traffic characteristic data within a certain historical time period as input features. These traffic characteristic data may include time characteristic data and non-time characteristic data. In practical applications, the acquired traffic characteristic data may be standardized or normalized so that the model can learn better. The traffic characteristic data may be input into each base model for independent prediction. Among them, the feature data input into base model 51 and base model 52 may include only time characteristic data, and the feature data input into base model 53 may include both time characteristic data and non-time characteristic data. Base models 51, 52, and 53 may process the input features independently, and predict the traffic flow at a certain future moment according to the number of prediction steps set by the model. The traffic flow at a future moment predicted by base models 51, 52, and 53 may be respectively Figure 5 The traffic flow prediction values 511-531 in the figure can be constructed into a new feature set [511, 521, 531] as input data of the meta-model 50.
[0126] The meta-model 50 can perform fusion processing on the input feature set [511, 521, 531] and output a prediction result, which can be the final prediction result of the traffic flow prediction model, that is, the traffic flow at a future moment to be predicted.
[0127] It should be noted that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0128] Reference Figure 6 , shows a schematic diagram of a traffic flow prediction device provided in an embodiment of the present application, which may specifically include an acquisition module 601, a processing module 602 and a receiving module 603, wherein:
[0129] An acquisition module 601 is used to acquire traffic characteristic data of a historical period, wherein the traffic characteristic data includes time characteristic data and at least one non-time characteristic data within the historical period;
[0130] A processing module 602 is used to process the traffic feature data using a trained traffic flow prediction model; wherein the traffic flow prediction model is composed of at least three different types of base models and at least one meta-model stacked together, the input data of at least one meta-model is the prediction data output by at least three base models, the input data of at least three base models is the traffic feature data, and the feature types of the traffic feature data respectively input into at least three base models are not completely the same;
[0131] The receiving module 603 is used to receive the traffic flow prediction result output by the traffic flow prediction model, wherein the traffic flow prediction result includes prediction data output by at least one meta-model.
[0132] In a possible implementation of the embodiment of the present application, the processing module 602 may be specifically used to:
[0133] Respectively determining the feature type of the traffic feature data to be processed by each base model;
[0134] Inputting the traffic characteristic data with the characteristic type into the corresponding base model respectively to perform traffic flow prediction; wherein, the input data of at least one base model only includes the time characteristic data within the historical period, and the input data of at least one base model includes both the time characteristic data within the historical period and at least one non-time characteristic data;
[0135] The prediction data obtained by each base model processing the traffic characteristic data is input into at least one meta-model for fusion processing.
[0136] In a possible implementation of the embodiment of the present application, the processing module 602 may be specifically used to:
[0137] Inputting the time characteristic data in the traffic characteristic data into the first base model and the second base model for processing respectively to obtain the first prediction data and the second prediction data;
[0138] The time feature data and at least one non-time feature data in the traffic feature data are input into a third base model for processing to obtain third prediction data; wherein the first base model is trained based on a differential autoregression model, the second base model is trained based on a deep learning model, and the third base model is trained based on a tree model.
[0139] In a possible implementation of the embodiment of the present application, the traffic flow prediction model may be composed of at least three base models and one meta-model in a single-layer stacked form, and the processing module 602 may also be used to:
[0140] Determine the weights of the first base model, the second base model, and the third base model in this prediction respectively according to at least one of the non-time feature data in the historical period;
[0141] The prediction data output by each base model is fused according to the weight, and the traffic flow prediction result is the prediction data output by the meta-model.
[0142] In another possible implementation of the embodiment of the present application, the traffic flow prediction model may be composed of at least three base models and at least two layers of meta models in a multi-layer stacked form, and the number of meta models in each layer of the multi-layer stacked traffic flow prediction model may include at least one, and the processing module 602 may also be used to:
[0143] Input the prediction data output by each base model into the metamodel of the first layer to perform traffic flow prediction; wherein the prediction data output by the metamodel of each layer for traffic flow prediction will be used as input data of the metamodel of the next layer, and the metamodel of the next layer will perform traffic flow prediction and output prediction data;
[0144] The metamodel of the last layer is used to perform fusion processing on the prediction data output by the metamodel of the previous layer, and the traffic flow prediction result is the prediction data output by the metamodel of the last layer.
[0145] In an embodiment of the present application, the predicted data obtained when using the training data to train each of the base models will be used as input data for training at least one of the meta-models; when using the traffic feature data to predict traffic flow, the order of data flow between at least three of the base models and at least one of the meta-models is the same as the order of using the training data to train at least three of the base models and at least one of the meta-models; the training data includes traffic feature sample data and traffic flow labels corresponding to the traffic feature sample data, the traffic flow label is the true value of the traffic flow at a future moment in the time window where the traffic feature sample data is located, and the true traffic flow value is used to evaluate the errors of the base models and the meta-models when training at least three of the base models and at least one of the meta-models.
[0146] In an embodiment of the present application, the at least one non-time characteristic data may be any one or more of road network characteristic data, commuting characteristic data and / or signal timing characteristic data.
[0147] An embodiment of the present application provides a traffic flow prediction device, which may be the electronic device in the aforementioned embodiments or a functional module in the electronic device that can interact with the traffic flow prediction model. By using this device, each step in the aforementioned method embodiments can be implemented.
[0148] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment part.
[0149] Reference Figure 7 , shows a schematic diagram of an electronic device provided by an embodiment of the present application. Figure 7 As shown, the electronic device 700 in the embodiment of the present application includes: a processor 710, a memory 720, and a computer program 721 stored in the memory 720 and executable on the processor 710. When the processor 710 executes the computer program 721, the steps in each embodiment of the above-mentioned traffic flow prediction method are implemented, such as Figure 4 Alternatively, when the processor 710 executes the computer program 721, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 6 Functions of modules 601 to 603 are shown.
[0150] Exemplarily, the computer program 721 may be divided into one or more modules / units, which are stored in the memory 720 and executed by the processor 710 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which may be used to describe the execution process of the computer program 721 in the electronic device 700. For example, the computer program 721 may be divided into an acquisition module, a processing module, and a receiving module, and the specific functions of each module are as follows:
[0151] An acquisition module, used to acquire traffic characteristic data of a historical period, wherein the traffic characteristic data includes time characteristic data and at least one non-time characteristic data within the historical period;
[0152] A processing module, used for processing the traffic feature data using a trained traffic flow prediction model; wherein the traffic flow prediction model is composed of at least three different types of base models and at least one meta-model stacked together, the input data of at least one meta-model is the prediction data output by at least three base models, the input data of at least three base models is the traffic feature data, and the feature types of the traffic feature data respectively input into at least three base models are not completely the same;
[0153] The receiving module is used to receive the traffic flow prediction result output by the traffic flow prediction model, wherein the traffic flow prediction result includes prediction data output by at least one meta-model.
[0154] The electronic device 700 may be an electronic device capable of implementing the steps in the above-mentioned method embodiments. The electronic device 700 may be a computing device such as a mobile phone, a smart wearable device, a vehicle computer or a vehicle-mounted terminal, a desktop computer, a cloud server, etc. The electronic device 700 may include, but is not limited to, a processor 710 and a memory 720. Those skilled in the art will understand that Figure 7 It is only an example of the electronic device 700 and does not constitute a limitation of the electronic device 700. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 700 may also include input and output devices, network access devices, buses, etc.
[0155] The processor 710 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0156] The memory 720 may be an internal storage unit of the electronic device 700, such as a hard disk or memory of the electronic device 700. The memory 720 may also be an external storage device of the electronic device 700, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 700. Further, the memory 720 may also include both an internal storage unit of the electronic device 700 and an external storage device. The memory 720 is used to store the computer program 721 and other programs and data required by the electronic device 700. The memory 720 may also be used to temporarily store data that has been output or is to be output.
[0157] An embodiment of the present application also discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the traffic flow prediction method as described in the above embodiments is implemented.
[0158] The embodiment of the present application further discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the traffic flow prediction method as described in the above-mentioned embodiments is implemented.
[0159] The embodiments of the present application further disclose a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the traffic flow prediction method described in the aforementioned embodiments.
[0160] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application is described in detail with reference to the above-mentioned embodiments, a person skilled in the art should understand that the technical solutions described in the above-mentioned embodiments can still be modified, or some of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A traffic flow prediction method, characterized in that: include: Acquire traffic characteristic data of a historical period, wherein the traffic characteristic data includes time characteristic data and at least one non-time characteristic data within the historical period; The traffic characteristic data is processed using a trained traffic flow prediction model; wherein the traffic flow prediction model is composed of at least three different types of base models and at least one meta-model stacked together, the input data of at least one meta-model is the prediction data output by at least three base models, the input data of at least three base models is the traffic characteristic data, and the feature types of the traffic characteristic data respectively input into at least three base models are not completely the same; Receiving a traffic flow prediction result output by the traffic flow prediction model, wherein the traffic flow prediction result includes prediction data output by at least one meta-model; Among them, the structure of the traffic flow prediction model is determined according to the influencing factors, and the structure includes a single-layer stack or a multi-layer stack. The influencing factors include one or more of the city scale, traffic data distribution, and traffic organization mode; when any one of the conditions that the city scale is a large city, the traffic data distribution is scattered, or the traffic organization mode is a complex mode is met, the traffic flow prediction model to be used is a multi-layer stacked model.
2. The method according to claim 1, characterized in that The method of using the trained traffic flow prediction model to process the traffic characteristic data includes: Respectively determining the feature type of the traffic feature data to be processed by each base model; Inputting the traffic characteristic data with the characteristic type into the corresponding base model respectively to perform traffic flow prediction; wherein, the input data of at least one base model only includes the time characteristic data within the historical period, and the input data of at least one base model includes both the time characteristic data within the historical period and at least one non-time characteristic data; The prediction data obtained by each base model processing the traffic characteristic data is input into at least one meta-model for fusion processing.
3. The method according to claim 2, characterized in that The step of inputting the traffic characteristic data having the characteristic type into the corresponding base model to perform traffic flow prediction comprises: Inputting the time characteristic data in the traffic characteristic data into the first base model and the second base model for processing respectively to obtain the first prediction data and the second prediction data; The time feature data and at least one non-time feature data in the traffic feature data are input into a third base model for processing to obtain third prediction data; wherein the first base model is trained based on a differential autoregression model, the second base model is trained based on a deep learning model, and the third base model is trained based on a tree model.
4. The method according to claim 3, characterized in that The traffic flow prediction model is composed of at least three base models and one meta-model in a single-layer stacked form, and the prediction data obtained by processing the traffic feature data by each base model is input into at least one meta-model for fusion processing, including: Determine the weights of the first base model, the second base model, and the third base model in this prediction respectively according to at least one of the non-time feature data in the historical period; The prediction data output by each base model is fused according to the weight, and the traffic flow prediction result is the prediction data output by the meta-model.
5. The method according to claim 3, characterized in that: The traffic flow prediction model is composed of at least three base models and at least two layers of meta models in a multi-layer stacked form, wherein the number of meta models in each layer of the multi-layer stacked traffic flow prediction model includes at least one, and the prediction data obtained by processing the traffic feature data by each base model is input into at least one meta model for fusion processing, including: Input the prediction data output by each base model into the metamodel of the first layer to perform traffic flow prediction; wherein the prediction data output by the metamodel of each layer for traffic flow prediction will be used as input data of the metamodel of the next layer, and the metamodel of the next layer will perform traffic flow prediction and output prediction data; The metamodel of the last layer is used to perform fusion processing on the prediction data output by the metamodel of the previous layer, and the traffic flow prediction result is the prediction data output by the metamodel of the last layer.
6. The method according to any one of claims 1 to 5, characterized in that: The predicted data obtained when using the training data to train each of the base models will be used as input data for training at least one of the meta-models; when using the traffic feature data to predict traffic flow, the order of data flow between at least three of the base models and at least one of the meta-models is the same as the order of using the training data to train at least three of the base models and at least one of the meta-models; the training data includes traffic feature sample data and traffic flow labels corresponding to the traffic feature sample data, the traffic flow label is the true value of the traffic flow at a future moment in the time window where the traffic feature sample data is located, and the true traffic flow value is used to evaluate the errors of the base models and the meta-models when training at least three of the base models and at least one of the meta-models.
7. The method according to any one of claims 1 to 5, characterized in that: The at least one non-time characteristic data is any one or more of road network characteristic data, commuting characteristic data and / or signal timing characteristic data.
8. A traffic flow prediction device, characterized in that: include: An acquisition module, used to acquire traffic characteristic data of a historical period, wherein the traffic characteristic data includes time characteristic data and at least one non-time characteristic data within the historical period; A processing module, used for processing the traffic feature data using a trained traffic flow prediction model; wherein the traffic flow prediction model is composed of at least three different types of base models and at least one meta-model stacked together, the input data of at least one meta-model is the prediction data output by at least three base models, the input data of at least three base models is the traffic feature data, and the feature types of the traffic feature data respectively input into at least three base models are not completely the same; A receiving module, configured to receive a traffic flow prediction result output by the traffic flow prediction model, wherein the traffic flow prediction result includes prediction data output by at least one meta-model; Among them, the structure of the traffic flow prediction model is determined according to the influencing factors, and the structure includes a single-layer stack or a multi-layer stack. The influencing factors include one or more of the city scale, traffic data distribution, and traffic organization mode; when any one of the conditions that the city scale is a large city, the traffic data distribution is scattered, or the traffic organization mode is a complex mode is met, the traffic flow prediction model to be used is a multi-layer stacked model.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the traffic flow prediction method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the traffic flow prediction method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Short-time traffic flow control method based on deep learning and spatio-temporal data fusion
CN110827543A
Interpretable traffic flow prediction stacking method
CN117542191A