Method and system for predicting CO2 emission and haze grade of urban traffic network based on LSTM (Long Short Term Memory)
Through the prediction method based on LSTM, traffic data is used to predict CO2 emissions and haze levels, the problem of poor prediction results in the existing technology is solved, and high-precision and automated traffic data prediction is achieved, which is suitable for urban traffic management needs.
Patent Information
- Application Number
- CN202510149002.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-11
- Publication Date
- 2025-05-13
AI Technical Summary
The prior art is difficult to effectively predict CO2 emissions and haze levels in urban transportation networks, and traditional monitoring methods are slow to respond and costly.
Using an LSTM-based prediction method, by collecting road monitoring data and vehicle feature data, screening feature variables using principal component analysis and correlation coefficient method, LSTM traffic emission prediction model is constructed, and hyperparameters are configured for training through the Adam gradient descent algorithm.
It realizes high-precision prediction of CO2 emissions and haze levels in the urban transportation road network, breaks away from the subjective factors of the traditional prediction model, can automatically learn key characteristics, adapt to urban management needs, and provide more flexible transportation strategy choices.
Smart Images

Figure CN119988918A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of air pollutant prediction, and in particular to a method and system for predicting CO2 emissions and haze levels of an urban traffic network based on LSTM. Background Art
[0002] In recent years, the continuous growth of car ownership has led to serious over-limit of urban traffic pollutant emissions. The resulting carbon oxides, nitrogen oxides, haze and other pollutants harm the atmospheric environment and affect human health. As people's awareness of environmental protection continues to improve, the issue of urban traffic pollutant emissions has received more widespread attention.
[0003] Urban traffic is a huge data system. At present, although a large number of traffic monitors are installed on urban roads, the response speed of these atmospheric pollutant detectors is relatively slow and cannot fully capture the complexity and diversity of urban traffic. Even with more advanced monitoring technology, the cost of monitoring is too large. However, with the continuous development of artificial intelligence, the derived deep learning (DL) can learn abstract data features through an indirect model composed of multiple processing layers: by combining the underlying features and outputting relatively abstract upper-level features, the distributed characteristics of the data are discovered. In recent years, deep learning algorithms have been widely used in the research of urban intelligent transportation systems. Therefore, the present invention chooses to predict the emission of major traffic pollutants based on the Long Short-Term Memory (LSTM) network, aiming to more effectively solve the problem of traffic network data prediction. Summary of the invention
[0004] In view of some or all of the problems in the prior art, the present invention provides a method for predicting CO2 emissions and haze levels in urban traffic network based on LSTM, which comprises the following steps:
[0005] Collect road monitoring data and vehicle characteristic data as input data;
[0006] Performing feature analysis on the input data using principal component analysis and correlation coefficient method, and selecting feature variables related to CO2 emissions and haze levels as input feature variables;
[0007] Normalizing the data set of the input feature variables to obtain a normalized feature variable data set;
[0008] Dividing the normalized feature variable data set into a training set and a test set;
[0009] Constructing an LSTM traffic emission prediction model, wherein the LSTM traffic emission prediction model includes a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer, and a regression output layer;
[0010] Using the Adam gradient descent algorithm to configure the hyperparameters of the LSTM traffic emission prediction model, the hyperparameters including the initial learning rate, batch size, number of iterations, and gradient threshold; and
[0011] The normalized feature variable data set is input into the LSTM traffic emission prediction model with set hyperparameters for training, so as to obtain a prediction model for CO2 emissions and haze levels of urban traffic road networks, and the prediction model for CO2 emissions and haze levels is evaluated using evaluation indicators.
[0012] Furthermore, the input data is subjected to feature analysis using principal component analysis and correlation coefficient method, and feature variables related to CO2 emissions and haze levels are screened out as input feature variables, including:
[0013] Mapping the input data to a low-dimensional space using principal component analysis to filter feature variable data; and
[0014] Calculate the Pearson correlation coefficient of the characteristic variable data, and select the characteristic variable data related to CO2 emissions and haze levels as input characteristic variable data;
[0015] The Pearson correlation coefficient rho(a,b) is,
[0016]
[0017] Among them, X a , X b are the ath and bth feature variable data respectively, are the average values of the ath and bth characteristic variable data respectively, and N is the number of characteristic variable data;
[0018] The input feature variables include car year, car model, engine size, number of engine cylinders, transmission type, fuel type, and comprehensive fuel consumption.
[0019] Furthermore, the normalization formula is:
[0020]
[0021] Among them, X i is the input feature variable data, X min and X max are the maximum and minimum values of the input feature variable data, respectively, and yi is the normalized feature variable data;
[0022] After normalization, a normalized feature variable data set is obtained, and the normalized feature variable data set is scaled to the range of [0, 1].
[0023] Furthermore, dividing the normalized feature variable data set into a training set and a test set includes:
[0024] The normalized feature variable data set is divided into a training set and a test set in a ratio of 8:2.
[0025] Furthermore, an LSTM traffic emission prediction model is constructed, wherein the LSTM traffic emission prediction model includes a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer and a regression output layer.
[0026] The input size of the sequence input layer is (batch_size, time_steps, features), where batch_size is the number of data samples for each training, time_steps is the length of the time series, i.e. the number of time steps of the LSTM input, and features is the number of input features;
[0027] For the LSTM layer, the input and state updates at the tth time step are as follows:
[0028] Input gate: i t =σ(W i ·[h t-1 ,x t ]+b i )
[0029] Forget gate: f t =σ(W f ·[h t-1 ,x t ]+b f )
[0030] Memory unit update: C t =f t ⊙C t-1 +i t ⊙tanh(W C ·[h t-1 ,x t ]+b C )
[0031] Output gate: o t =σ(W o ·[h t-1 ,x t ]+b o )
[0032] Hidden state: h t =ot ⊙tanh(C t )
[0033] Among them, σ is the Sigmoid function, tanh is the hyperbolic tangent function, W i ,W f ,W C ,W o is the weight matrix, b i ,b f ,b C ,b o is the bias term, h t-1 is the hidden state at the t-1th time step, x t is the input of the tth time step, ⊙ is the Hadamard product;
[0034] The neuron h i Input to the Dropout layer, the output of the Dropout layer is,
[0035]
[0036] Where, p is the discard rate;
[0037] The output h of the Dropout layer i ′ is input to the ReLU layer, and the ReLU layer selects the ReLU activation function, f(x) = max(0,x), where x is the output h of the Dropout layer i ′;
[0038] The output y of the fully connected layer is,
[0039] y=W fc ·h+b fc
[0040] Among them, W fc is the weight matrix, b fc is the bias term, h is the output vector of the ReLU layer;
[0041] The output y of the fully connected layer is input into the regression output layer, and the output of the regression output layer is the final prediction value of the LSTM traffic emission prediction model.
[0042] Furthermore, the Adam gradient descent algorithm is used to configure the hyperparameters of the LSTM traffic emission prediction model, and the hyperparameters include the initial learning rate, batch size, number of iterations, and gradient threshold:
[0043] Set the lag length of the LSTM traffic emission prediction model to 24;
[0044] The Adam gradient descent algorithm is:
[0045] mt =β1m t-1 +(1-β1)g t
[0046] v t =β2v t-1 +(1-β2)g t 2
[0047]
[0048] Among them, g t is the current gradient, m t ,v t are the momentum estimate of the gradient and the weighted average of the square gradient, β1 and β2 are the exponential decay rates of the momentum estimate and the square gradient estimate, η is the learning rate, and ε is a constant to prevent division by zero;
[0049] The batch size is 30, the number of iterations is 1200, the initial learning rate is 0.01, and the gradient threshold is set to 6; the learning rate reduction cycle is set to 800, and the learning rate reduction factor is set to 0.15.
[0050] Furthermore, the evaluation indicators include root mean square error, mean absolute error, coefficient of determination, and mean absolute percentage error;
[0051] The root mean square error is,
[0052]
[0053] Among them, x i is the actual value, y i is the predicted value, n is the number of samples;
[0054] The mean absolute error is,
[0055]
[0056] Among them, x i is the actual value, y i is the predicted value, n is the number of samples;
[0057] The coefficient of determination is,
[0058]
[0059] Among them, y i is the actual value, is the predicted value, is the average value of the actual value, and n is the number of samples;
[0060] The mean absolute percentage error is,
[0061]
[0062] Among them, y i is the actual value, is the predicted value, and n is the number of samples.
[0063] The present invention also provides a system for the LSTM-based urban traffic network CO2 emission and haze level prediction method, which includes the following modules:
[0064] A data collection module is configured to collect road monitoring data and vehicle characteristic data as input data;
[0065] A characteristic variable screening module is configured to perform characteristic analysis on the input data using principal component analysis and correlation coefficient method, and screen out characteristic variables related to CO2 emissions and haze levels as input characteristic variables;
[0066] A data preprocessing module is configured to perform normalization processing on the data set of the input feature variables to obtain a normalized feature variable data set;
[0067] A data set division module is configured to divide the normalized feature variable data set into a training set and a test set;
[0068] An LSTM model building module is configured to build an LSTM traffic emission prediction model, wherein the LSTM traffic emission prediction model includes a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer, and a regression output layer;
[0069] A hyperparameter configuration module, configured to use the Adam gradient descent algorithm to configure the hyperparameters of the LSTM traffic emission prediction model, wherein the hyperparameters include an initial learning rate, a batch size, a number of iterations, and a gradient threshold; and
[0070] The emission prediction and evaluation module is configured to input the normalized feature variable data set into the LSTM traffic emission prediction model with set hyperparameters for training, obtain a prediction model for CO2 emissions and haze levels of urban traffic road networks, and use evaluation indicators to evaluate the prediction model for CO2 emissions and haze levels.
[0071] The present invention also provides a computer system, comprising:
[0072] a processor configured to execute machine-readable instructions;
[0073] A graphics card with an artificial intelligence chip, which is configured to train the LSTM-based urban traffic network CO2 emission and haze level prediction method; and
[0074] The memory is configured to store machine-readable instructions, which, when executed by the processor and / or the graphics card, perform the steps of the LSTM-based urban traffic network CO2 emission and haze level prediction method.
[0075] The present invention also provides a computer-readable storage medium having machine-readable instructions stored thereon, and when the machine-readable instructions are executed by a processor, the steps of the LSTM-based urban traffic network CO2 emission and haze level prediction method are executed.
[0076] The technical solution provided by the present invention has the following advantages:
[0077] 1. The LSTM-based urban traffic network CO2 emission and haze level prediction method proposed in the present invention gets rid of the influence of subjective factors in the traditional experience-based prediction model. The LSTM model with strong temporal characteristics can automatically learn key features and avoid the limitations of artificial experience.
[0078] 2. The LSTM-based urban traffic network CO2 emission and haze level prediction method proposed in the present invention combines the high-precision characteristics of the LSTM model in time series prediction. Different from the previous characteristics that a single node cannot meet the global constraints, this method realizes the overall optimization of the entire traffic network and can better meet the global needs of urban management.
[0079] 3. The LSTM-based urban traffic network CO2 emission and haze level prediction method proposed in the present invention can provide more options for traffic strategy formulation by flexibly adjusting the prediction target to meet different urban management needs, such as minimizing total emissions and optimizing emission distribution.
[0080] 4. The LSTM-based urban traffic network CO2 emission and haze level prediction method proposed in the present invention can continuously absorb new traffic data, dynamically adjust the prediction model, maintain a high degree of adaptability to actual conditions, and provide an advanced, reliable and efficient solution and strong technical support for urban traffic management and environmental protection. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] To further illustrate the above and other advantages and features of various embodiments of the present invention, a more specific description of various embodiments of the present invention will be presented with reference to the accompanying drawings. It will be understood that these drawings only depict typical embodiments of the present invention and are therefore not to be considered as limiting the scope thereof. In the accompanying drawings, for clarity, identical or corresponding parts will be represented by identical or similar reference numerals.
[0082] Figure 1 A schematic diagram of a process of predicting CO2 emissions and haze levels in an urban traffic network based on LSTM according to an embodiment of the present invention is shown;
[0083] Figure 2 A schematic diagram of a Pearson correlation coefficient matrix of characteristic variables of an embodiment of the present invention is shown;
[0084] Figure 3 A schematic diagram of the structure of an LSTM traffic emission prediction model according to an embodiment of the present invention is shown;
[0085] Figure 4 A schematic diagram of the block structure of an LSTM traffic emission prediction model according to an embodiment of the present invention is shown;
[0086] Figure 5 A schematic diagram showing the comparison of CO2 emission prediction results of an urban traffic network based on LSTM according to an embodiment of the present invention is shown;
[0087] Figure 6 A schematic diagram showing comparison of prediction results of urban traffic network haze level based on LSTM according to an embodiment of the present invention is shown; and
[0088] Figure 7 A schematic diagram of a system for predicting CO2 emissions and haze levels in an urban traffic network based on LSTM according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0089] In the following description, the present invention is described with reference to various embodiments. However, those skilled in the art will recognize that various embodiments may be implemented without one or more specific details or with other replacement and / or additional methods or components. In other cases, well-known structures or operations are not shown or described in detail to avoid obscuring the inventive point of the present invention. Similarly, for the purpose of explanation, specific numbers and configurations are set forth to provide a comprehensive understanding of embodiments of the present invention. However, the present invention is not limited to these specific details.
[0090] In this specification, reference to "one embodiment" or "the embodiment" means that a particular feature, structure, or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present invention. The phrase "in one embodiment" appearing in various places in this specification does not necessarily all refer to the same embodiment.
[0091] It should be noted that the embodiments of the present invention describe the method steps in a specific order, but this is only for the purpose of illustrating the specific embodiment, rather than limiting the order of the steps. On the contrary, in different embodiments of the present invention, the order of the steps can be adjusted according to actual needs.
[0092] In the present invention, each module of the system according to the present invention can be implemented using software, hardware, firmware or a combination thereof. When the module is implemented using software, the function of the module can be implemented by a computer program flow, for example, the module can be implemented by a code segment (such as a code segment of a language such as C, C++, etc.) stored in a storage device (such as a hard disk, a memory, etc.), wherein the corresponding function of the module can be implemented when the code segment is executed by a processor. When the module is implemented using hardware, the function of the module can be implemented by setting a corresponding hardware structure, for example, the function of the module can be implemented by hardware programming a programmable device such as a field programmable gate array (FPGA), or the function of the module can be implemented by designing an application-specific integrated circuit (ASIC) including electronic devices such as a plurality of transistors, resistors and capacitors. When the module is implemented using firmware, the function of the module can be written into a read-only memory such as an EPROM or EEPROM of the device in the form of a program code, and the corresponding function of the module can be implemented when the program code is executed by a processor. In addition, certain functions of the module may need to be implemented by separate hardware or by collaboration with the hardware, for example, the detection function is implemented by corresponding sensors (such as proximity sensors, acceleration sensors, gyroscopes, etc.), the signal transmission function is implemented by corresponding communication devices (such as Bluetooth devices, infrared communication devices, baseband communication devices, Wi-Fi communication devices, etc.), the output function is implemented by corresponding output devices (such as displays, speakers, etc.), and so on.
[0093] Figure 1 The following is a flow chart showing a method for predicting CO2 emissions and haze levels in urban traffic networks based on LSTM according to an embodiment of the present invention. Figure 1 , the LSTM-based urban traffic network CO2 emission and haze level prediction method proposed by the present invention is described. In one embodiment of the present invention, the LSTM-based urban traffic network CO2 emission and haze level prediction method can be executed by a computer. Figure 1 As shown in FIG. 1 , the LSTM-based urban traffic network CO2 emission and haze level prediction method includes the following steps:
[0094] First, road monitoring data and vehicle characteristic data are collected as input data. Vehicle characteristic data include car year, car manufacturer, car model, engine size, number of engine cylinders, transmission type, and fuel type. Road monitoring data include urban fuel consumption (L / 100km), highway fuel consumption (L / 100km), comprehensive fuel consumption (mpg), traffic pollutant CO2 emission monitoring data (g / km), and haze emission assessment level. The data is fuel consumption rating monitoring data from 2015 to 2019, and a total of 5,431 vehicles are recorded.
[0095] Next, the input data is subjected to feature analysis using principal component analysis and correlation coefficient method, and feature variables related to CO2 emissions and haze levels are screened out as input feature variables. This step includes mapping the input data to a low-dimensional space using principal component analysis, screening feature variable data; and calculating the Pearson correlation coefficient of the feature variable data, screening feature variable data related to CO2 emissions and haze levels as input feature variable data.
[0096] Since the data is accompanied by vacant values and abnormal values, data cleaning is required to ensure data quality, detect and correct errors, missing values, redundancy and other problems in the data. In the present invention, first of all, the data information under each characteristic variable in the statistical data set needs to be counted. Secondly, according to the variables such as the total amount of data, average value, maximum value, minimum value under each characteristic variable, it is judged whether the data is within a reasonable range. For the null values in the data, convert them to 0. Delete the characteristic variables with a large number of missing values, too large data dispersion, etc., and retain the characteristic variable data with high data quality and predictive value.
[0097] Data transformation is performed for fuel type, vehicle category, and transmission type. There are five fuel types in total, which are recorded in the data as D, E, N, X, and Z. Among them, D represents fuel with a specific treatment or source, E refers to fuel containing ethanol, N refers to ordinary diesel or other unmarked fuels, X refers to specially treated fuels, such as biodiesel or other alternative fuels, and Z refers to high-efficiency or low-emission fuels. D, E, N, X, and Z are transformed into 1, 2, 3, 4, and 5 respectively.
[0098] There are 15 types of vehicles, including compact cars, full-size cars, mid-size cars, micro-compact cars, minivans, small pickups, standard pickups, special purpose vehicles, SUVs, SUVs, mid-size station wagons, small station wagons, subcompact cars, two-seater cars, and buses. In order to distinguish the impact of different models on automobile pollutant emissions, the above 15 models are transformed and numbered 1-15 as new features.
[0099] Automobile transmission is used to coordinate the engine speed with the actual driving speed of the wheels to maximize the performance of the engine. Therefore, the transmission will also affect pollutant emissions and should also be included in the feature considerations. Automobile transmission types mainly include models A4, A5, A6, A7, A8, A9, A10, AM5, AM6, AM7, AM8, AM9, AS4, AS5, AS6, AS7, AS8, AS9, AS10, AV, AV6, AV7, AV8, AV10, M5, M6, M7, a total of 27 types. Number 1-27 in the above order as a new data feature.
[0100] The Pearson correlation coefficient indicates the degree of “linear” correlation between data, and its value is between [0,1]. The specific data correlation strength analysis is shown in Table 1.
[0101] Table 1 Pearson correlation coefficient and variable correlation strength analysis table
[0102] Pearson correlation coefficient Correlation strength [0.8,1.0] Very strong correlation [0.6,0.8] Strong correlation [0.4,0.6] Moderately related [0.2,0.4] Weak correlation [0.0,0.2] Very weak or no correlation
[0103] The Pearson correlation coefficient rho(a,b) is,
[0104]
[0105] Among them, X a , X b are the ath and bth feature variable data respectively, are the average values of the a-th and b-th characteristic variable data respectively, and N is the number of characteristic variable data.
[0106] According to the scores between the characteristic variables, the scores of urban fuel consumption per 100 kilometers and highway fuel consumption per 100 kilometers are closer to 1, which proves that they have a greater correlation with the characteristics of other dimensions and have a smaller impact on the main components, so they are not selected as input characteristic variables. Figure 2 FIG. 4 is a schematic diagram of a Pearson correlation coefficient matrix of characteristic variables of an embodiment of the present invention. Figure 2 As shown in the figure, the scores of car production year, car model, engine size, number of engine cylinders, transmission type, fuel type and comprehensive fuel consumption are more uniform, and the dimensions are basically weakly correlated or extremely weakly correlated, indicating that these characteristic variables can bring new information to the model prediction and have the greatest impact on the principal components. Therefore, the selected input characteristic variables include car year, car model, engine size, number of engine cylinders, transmission type, fuel type and comprehensive fuel consumption.
[0107] Next, the data set of the input feature variables is normalized to obtain a normalized feature variable data set. The standard normalization formula is as follows:
[0108]
[0109] Y min and Y max Respectively represent the minimum and maximum values of the interval that needs to be normalized. min and X max Represent the minimum and maximum values of the input feature variable data. i All are normalized to Y min To Y maxIn order to unify the sample data of each parameter.
[0110] This method normalizes all selected input feature variable data to [0, 1], and takes Y according to the required requirements. max is 1, take Y min is 0, the standardized calculation formula actually used is,
[0111]
[0112] Among them, X i is the input feature variable data, X min and X max are the maximum and minimum values of the input feature variable data, respectively, and yi is the normalized feature variable data. After normalization, a normalized feature variable data set is obtained, and the normalized feature variable data set is scaled to the range of [0,1].
[0113] The purpose of normalization is to scale the input feature data to a uniform scale, which can eliminate the impact of dimension and balance the weights of each feature. The input features after standardization are in the same range, so that the learning model will not give too much weight to some feature values because they are particularly large during training, while improving the stability of training. After normalization, the features basically show weak or very weak correlation, which can reduce the redundant information between features and maximize the new information provided by each feature to the model. At the same time, it can help the model avoid underfitting or overfitting problems caused by unbalanced feature weights.
[0114] Next, the normalized feature variable data set is divided into a training set and a test set. In one embodiment of the present invention, the normalized feature variable data set is divided into a training set and a test set in a ratio of 8:2. Taking the Canadian 2015-2019 fuel consumption rating monitoring data set as an example, there are 5431 data for predicting CO2 and haze levels. The first 4431 data are taken as the training set, the last 1000 data are taken as the test set, and the last 348 data in the training set are taken as the validation set.
[0115] Next, an LSTM traffic emission prediction model is constructed, which includes a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer and a regression output layer. Figure 3 A schematic diagram of the structure of an LSTM traffic emission prediction model according to an embodiment of the present invention is shown. Figure 4 A schematic diagram of the block structure of an LSTM traffic emission prediction model according to an embodiment of the present invention is shown.
[0116] The state activation function selects tanh. The number of input features of the data set is 7, so the size of the sequence input layer is set to the number of features of the input data. The number of hidden neurons in the LSTM layer is set to 128 by default, and the state activation function selects tanh, with a range of [-1,1]; the gate activation function selects the Sigmoid function, with a range of [0,1]. The Dropout layer sets a drop coefficient of 0.01, that is, 1% of neurons are randomly dropped each time an update is made to prevent overfitting. The size of the fully connected layer is set to the number of output responses, which is 1. Finally, the regression output layer is selected to complete the construction of the traffic pollutant emission regression model.
[0117] The input size of the sequence input layer is (batch_size, time_steps, features), where batch_size is the number of data samples for each training, time_steps is the length of the time series, i.e. the number of time steps of the LSTM input, and features is the number of input features;
[0118] For the LSTM layer, the input and state updates at the tth time step are as follows:
[0119] Input gate: i t =σ(W i ·[h t-1 ,x t ]+b i )
[0120] Forget gate: f t =σ(W f ·[h t-1 ,x t ]+b f )
[0121] Memory unit update: C t =f t ⊙C t-1 +i t ⊙tanh(W C ·[h t-1 ,x t ]+b C )
[0122] Output gate: o t =σ(W o ·[h t-1 ,x t ]+b o )
[0123] Hidden state: h t =o t ⊙tanh(C t )
[0124] Among them, σ is the Sigmoid function, tanh is the hyperbolic tangent function, W i ,W f ,W C ,W o is the weight matrix, b i ,b f ,b C ,b o is the bias term, h t-1 is the hidden state at the t-1th time step, x t is the input of the tth time step, and ⊙ is the Hadamard product.
[0125] The neuron h i Input to the Dropout layer, the output of the Dropout layer is,
[0126]
[0127] Where, p is the discard rate;
[0128] The output h of the Dropout layer i ′ is input to the ReLU layer, and the ReLU layer selects the ReLU activation function, f(x) = max(0,x), where x is the output h′ of the Dropout layer i The ReLU activation function keeps all input values greater than 0 unchanged and sets input values less than or equal to 0 to zero.
[0129] The output y of the fully connected layer is,
[0130] y=W fc ·h+b fc
[0131] Among them, W fc is the weight matrix, b fc is the bias term, h is the output vector of the ReLU layer;
[0132] The output y of the fully connected layer is input into the regression output layer, and the output of the regression output layer is the final prediction value of the LSTM traffic emission prediction model.
[0133] Next, the Adam gradient descent algorithm is used to configure the hyperparameters of the LSTM traffic emission prediction model, including the initial learning rate, batch size, number of iterations, and gradient threshold.
[0134] Based on the time series characteristics of the data set, the lag length of the LSTM traffic emission prediction model is set to 24 in this method. The lag length of the LSTM traffic emission prediction model is set to 24, which means that the number of time steps of the model input is 24, that is, each input is the data of the previous 24 time points, which is used to predict the target value of the next time point. This setting can use the data of the past period of time to capture the time series characteristics. In terms of hyperparameter configuration, the Adam gradient descent algorithm is selected, which can adaptively adjust the learning rate and is suitable for the training of large-scale data sets.
[0135] The Adam gradient descent algorithm is:
[0136] m t =β1m t-1 +(1-β1)g t
[0137] v t =β2v t-1 +(1-β2)g t 2
[0138]
[0139] Among them, g t is the current gradient, m t ,v t are the momentum estimate of the gradient and the weighted average of the squared gradient, β1 and β2 are the exponential decay rates of the momentum estimate and the squared gradient estimate (usually set to 0.9 and 0.999), η is the learning rate, and ε is a constant to prevent division by zero (usually set to 10 -8 );
[0140] The batch size is set to 30, the number of iterations is 1200, the initial learning rate is 0.01, and the gradient threshold is set to 6. The learning rate reduction cycle is set to 800, and the learning rate reduction factor is set to 0.15, that is, after the 800th training iteration, the learning rate is reduced to 0.01 times 0.15. The batch size is set to 30, and the gradient calculation is performed on the data of 30 samples each time the model parameters are iterated; the number of iterations is 1200, that is, the model performs 1200 complete iterations on the training set to fully learn the data features and adjust the model parameters; the initial learning rate is 0.01, which means that the step size is 0.01 each time the parameters are updated. If the learning rate is too large, the model may not converge; if the learning rate is too small, the training time may become too long; the gradient threshold is set to 6 to prevent the gradient explosion problem. The learning rate reduction cycle is set to 800, that is, in the first 800 iterations of training, the initial learning rate is kept at 0.01; the learning rate reduction factor is 0.15, that is, after the 800th training iteration, the learning rate is reduced to 0.01 times 0.15. Learning rate decay helps to adjust parameters more carefully in the later stage of model training and prevent the model from falling into a local optimal solution.
[0141] Finally, the normalized feature variable data set is input into the LSTM traffic emission prediction model with set hyperparameters for training to obtain a prediction model for CO2 emissions and haze levels of urban traffic road networks, and the evaluation index is used to evaluate the prediction model for CO2 emissions and haze levels.
[0142] By comparing the predicted values with the actual values, the selected evaluation indicators are used to verify the effectiveness and accuracy of the model to ensure that it has good generalization ability in practical applications. The evaluation indicators include root mean square error, mean absolute error, determination coefficient, and mean absolute percentage error. The root mean square error (RMSE) is used to measure the deviation between the model's predicted value and the true value, the mean absolute error (MAE) represents the average absolute deviation between the predicted value and the true value, and the determination coefficient R 2 Used to measure how well the model fits the data, the Mean Absolute Percentage Error (MAPE) reflects the relative error between the model's predicted value and the true value, expressed as a percentage, the smaller the better.
[0143] The root mean square error is,
[0144]
[0145] Among them, x i is the actual value, y i is the predicted value, and n is the number of samples.
[0146] The root mean square error is used to evaluate the accuracy of the model. The smaller the root mean square error, the more accurate the model regression prediction. However, due to the characteristic that its square term will amplify the error, the root mean square error is very sensitive to outliers in the data set. When there are some extreme actual values or values that are far from the predicted values, the results reflected by the root mean square error are not necessarily accurate.
[0147] The mean absolute error is,
[0148]
[0149] Among them, x i is the actual value, y i is the predicted value, and n is the number of samples.
[0150] Compared with the root mean square error, the mean absolute error has a smaller penalty for the difference between the predicted value and the actual value, thus producing a complementary effect to the root mean square error.
[0151] R-Squared coefficient of determination 2 )for,
[0152]
[0153] Among them, y i is the actual value, is the predicted value, is the average value of the actual value, and n is the number of samples. 2 It is used to indicate the degree of fit of the regression model to the data set, that is, the similarity between the predicted value and the true value. 2 As an evaluation indicator, it is mainly used to evaluate the effect of model prediction and explanation of dependent variable changes. 2 The value of is between 0 and 1. The closer it is to 1, the better the fitting effect of the regression model; otherwise, it means that the model regression effect is poor. If R2 is negative or greater than 1, it means that the prediction effect of the model is poor. However, the above situation is not an absolute error, and it still needs to be analyzed according to the specific situation.
[0154] The mean absolute percentage error is,
[0155]
[0156] Among them, y i is the actual value, is the predicted value, and n is the number of samples.
[0157] The mean absolute percentage error is mainly used to evaluate the prediction accuracy of the model. MAPE takes into account the error ratio between the predicted value and the actual value, which can more intuitively reflect the quality of the prediction. Similar to the root mean square error, if a predicted value is much higher than the actual value, MAPE will give a higher percentage value, but a very small number of incorrect predictions may not fully reflect the quality of the model.
[0158] Since the range of haze level is [0,8], the prediction of the true value is 0. Therefore, the evaluation index MAPE is not applicable to it. The evaluation results of the urban traffic network CO2 emission and haze level prediction model based on LSTM in the present invention are shown in Table 2. From the RMSE, MAE, R 2 From the perspective of the four indicators of R, MAPE, the CO2 emission model performs well, with a small prediction error, and the model can fit the data well. 2 The high RMSE and low MAPE values indicate that the model has strong predictive ability. In contrast, the RMSE and MAE of the haze level model are high, which means that the model has poor predictive ability for the changes in haze level data and may need to increase the amount of data to improve its predictive performance.
[0159] Table 2. LSTM-based prediction method for urban traffic network CO2 emissions and haze levels
[0160]
[0161] Figure 5 and Figure 6 In the figure, the horizontal axis is "prediction sample", which indicates the number of each sample in the test set. Each number represents a sample, that is, the CO2 emission or haze level corresponding to a data point. The vertical axis is "prediction result", and its value indicates the CO2 concentration (in g / km) and the haze level (the level is divided from 0 (representing the best air quality) to 8 (representing the worst air quality)).
[0162] Figure 5 The figure shows the comparison between the prediction results of CO2 emissions by the LSTM traffic emission prediction model on the test set and the actual results. The red curve represents the actual value, and the blue curve represents the model's prediction value. It can be seen from the figure that in most cases, the model's prediction value is well consistent with the actual value, especially in areas where the CO2 concentration is relatively stable.
[0163] Figure 6The figure shows the comparison between the prediction results and actual results of the LSTM traffic emission prediction model on the test set for the haze level. The red curve represents the actual value, and the blue curve represents the predicted value. As can be seen from the figure, the prediction effect of the haze level model is not ideal, and the actual value and the predicted value are not consistent, especially in areas where the haze level fluctuates violently. The model has difficulty in accurately capturing these mutations, which may be related to the large volatility of the haze level and the complexity of the data features. In order to improve the prediction performance, it may be necessary to increase the input features, increase the amount of data, or introduce other methods suitable for processing volatile data.
[0164] The LSTM-based urban traffic network CO2 emission and haze level prediction method proposed in the present invention gets rid of the influence of subjective factors in traditional experience-based prediction models. The LSTM model with strong temporal characteristics can automatically learn key features and avoid the limitations of manual experience. Combining the high-precision characteristics of the LSTM model in time series prediction, unlike the previous characteristics that a single node cannot meet the global constraints, this method realizes the overall optimization of the entire traffic network and can better meet the global needs of urban management. By flexibly adjusting the prediction target, it can provide more options for traffic strategy formulation for different urban management needs, such as minimizing total emissions and optimizing emission distribution. It can continuously absorb new traffic data, dynamically adjust the prediction model, and maintain a high degree of adaptability to actual conditions, providing an advanced, reliable and efficient solution and strong technical support for urban traffic management and environmental protection.
[0165] In one embodiment of the present invention, the present invention also provides a system for predicting CO2 emissions and haze levels in urban traffic networks based on LSTM. Figure 7 The following is a schematic diagram of a system for predicting CO2 emissions and haze levels in an urban traffic network based on LSTM according to an embodiment of the present invention. Figure 7 As shown, the system includes the following modules:
[0166] A data collection module is configured to collect road monitoring data and vehicle characteristic data as input data;
[0167] A characteristic variable screening module is configured to perform characteristic analysis on the input data using principal component analysis and correlation coefficient method, and screen out characteristic variables related to CO2 emissions and haze levels as input characteristic variables;
[0168] A data preprocessing module is configured to perform normalization processing on the data set of the input feature variables to obtain a normalized feature variable data set;
[0169] A data set division module is configured to divide the normalized feature variable data set into a training set and a test set;
[0170] An LSTM model building module is configured to build an LSTM traffic emission prediction model, wherein the LSTM traffic emission prediction model includes a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer, and a regression output layer;
[0171] A hyperparameter configuration module, configured to use the Adam gradient descent algorithm to configure the hyperparameters of the LSTM traffic emission prediction model, wherein the hyperparameters include an initial learning rate, a batch size, a number of iterations, and a gradient threshold; and
[0172] The emission prediction and evaluation module is configured to input the normalized feature variable data set into the LSTM traffic emission prediction model with set hyperparameters for training, obtain a prediction model for CO2 emissions and haze levels of urban traffic road networks, and use evaluation indicators to evaluate the prediction model for CO2 emissions and haze levels.
[0173] In one embodiment of the present invention, the present invention also provides a computer system, which includes a processor, a graphics card with an artificial intelligence chip and a memory, the memory is configured to store machine-readable instructions, the graphics card is configured to train the LSTM-based urban traffic road network CO2 emission and haze level prediction method, and the processor is configured to execute machine-readable instructions. The processor and / or graphics card implement the following processing steps when executing machine-readable instructions: collecting road monitoring data and vehicle feature data as input data; using principal component analysis and correlation coefficient method to perform feature analysis on the input data, and screening out feature variables related to CO2 emissions and haze levels as input feature variables; normalizing the data set of the input feature variables to obtain a normalized feature variable data set; dividing the normalized feature variable data set into a training set and a test set; constructing an LSTM traffic emission prediction model, the LSTM traffic emission prediction model including a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer and a regression output layer; using the Adam gradient descent algorithm to configure the hyperparameters of the LSTM traffic emission prediction model, the hyperparameters including an initial learning rate, a batch size, the number of iterations and a gradient threshold; and inputting the normalized feature variable data set into the LSTM traffic emission prediction model with the hyperparameters set for training, to obtain a prediction model for CO2 emissions and haze levels of urban traffic road networks, and using evaluation indicators to evaluate the prediction model for CO2 emissions and haze levels.
[0174] The graphics card may preferably have a GPU computing power higher than 5.0. Since the amount of data to be trained is large, providing a graphics card configuration can significantly increase the training speed.
[0175] The memory includes: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store machine-readable instructions.
[0176] It can be understood that in addition to the memory and processor mentioned above, the above-mentioned computer system also includes other software and hardware components not listed in this specification. The specific components can be determined according to the model of specific data processing equipment in different application scenarios, and this specification will not list them one by one in detail.
[0177] In one embodiment of the present invention, the present invention also provides a computer-readable storage medium having machine-readable instructions stored thereon, wherein the machine-readable instructions implement the following processing steps when executed by a processor: collecting road monitoring data and vehicle characteristic data as input data; performing characteristic analysis on the input data using principal component analysis and correlation coefficient method, screening out characteristic variables related to CO2 emissions and haze levels as input characteristic variables; normalizing the data set of the input characteristic variables to obtain a normalized characteristic variable data set; dividing the normalized characteristic variable data set into a training set and a test set; constructing an LSTM cross A traffic emission prediction model is provided, wherein the LSTM traffic emission prediction model includes a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer and a regression output layer; the hyperparameters of the LSTM traffic emission prediction model are configured using an Adam gradient descent algorithm, and the hyperparameters include an initial learning rate, a batch size, a number of iterations and a gradient threshold; and the normalized feature variable data set is input into the LSTM traffic emission prediction model with the hyperparameters set for training to obtain a prediction model for CO2 emissions and haze levels of urban traffic road networks, and the prediction model for CO2 emissions and haze levels is evaluated using evaluation indicators.
[0178] Although various embodiments of the present invention are described above, it should be understood that they are presented as examples only and not as limitations. It is obvious to those skilled in the relevant art that various combinations, modifications and changes can be made thereto without departing from the spirit and scope of the present invention. Therefore, the breadth and scope of the present invention disclosed herein should not be limited by the exemplary embodiments disclosed above, but should be defined according to the technical solutions of the present invention and their equivalents.
Claims
1. A method for predicting CO2 emissions and haze levels in urban traffic network based on LSTM, characterized in that: The steps include: Collect road monitoring data and vehicle characteristic data as input data; Performing feature analysis on the input data using principal component analysis and correlation coefficient method, and selecting feature variables related to CO2 emissions and haze levels as input feature variables; Normalizing the data set of the input feature variables to obtain a normalized feature variable data set; Dividing the normalized feature variable data set into a training set and a test set; Constructing an LSTM traffic emission prediction model, wherein the LSTM traffic emission prediction model includes a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer, and a regression output layer; Using the Adam gradient descent algorithm to configure the hyperparameters of the LSTM traffic emission prediction model, the hyperparameters including the initial learning rate, batch size, number of iterations, and gradient threshold; and The normalized feature variable data set is input into the LSTM traffic emission prediction model with set hyperparameters for training, so as to obtain a prediction model for CO2 emissions and haze levels of urban traffic road networks, and the prediction model for CO2 emissions and haze levels is evaluated using evaluation indicators.
2. The method for predicting CO2 emissions and haze levels of urban traffic network based on LSTM according to claim 1 is characterized in that: The input data were analyzed using principal component analysis and correlation coefficient method, and characteristic variables related to CO2 emissions and haze levels were selected as input characteristic variables, including: Mapping the input data to a low-dimensional space using principal component analysis to filter feature variable data; and Calculate the Pearson correlation coefficient of the characteristic variable data, and select the characteristic variable data related to CO2 emissions and haze levels as input characteristic variable data; The Pearson correlation coefficient rho(a,b) is, Among them, X a , X b are the ath and bth feature variable data respectively, are the average values of the ath and bth characteristic variable data respectively, and N is the number of characteristic variable data; The input feature variables include car year, car model, engine size, number of engine cylinders, transmission type, fuel type, and comprehensive fuel consumption.
3. The method for predicting CO2 emissions and haze levels of urban traffic network based on LSTM according to claim 1 is characterized in that: The normalized formula is: Among them, X i is the input feature variable data, X min and X max are the maximum and minimum values of the input feature variable data, y i is the normalized characteristic variable data; After normalization, a normalized feature variable data set is obtained, and the normalized feature variable data set is scaled to the range of [0, 1].
4. The method for predicting CO2 emissions and haze levels of urban traffic network based on LSTM according to claim 1 is characterized in that: Dividing the normalized feature variable data set into a training set and a test set includes: The normalized feature variable data set is divided into a training set and a test set in a ratio of 8:
2.
5. The method for predicting CO2 emissions and haze levels of urban traffic network based on LSTM according to claim 1 is characterized in that: Construct an LSTM traffic emission prediction model, which includes a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer, and a regression output layer. The input size of the sequence input layer is (batch_size, time_steps, features), where batch_size is the number of data samples for each training, time_steps is the length of the time series, i.e. the number of time steps of the LSTM input, and features is the number of input features; For the LSTM layer, the input and state updates at the tth time step are as follows: Input gate: i t =σ(W i ·[h t-1 ,x t ]+b i ) Forget gate: f t =σ(W f ·[h t-1 ,x t ]+b f ) Memory unit update: C t =f t ⊙C t-1 +i t ⊙tanh(W C ·[h t-1 ,x t ]+b C ) Output gate: o t =σ(W o ·[h t-1 ,x t ]+b o ) Hidden state: h t =o t ⊙tanh(C t ) Among them, σ is the Sigmoid function, tanh is the hyperbolic tangent function, W i ,W f ,W C ,W o is the weight matrix, b i ,b f ,b C ,b o is the bias term, h t-1 is the hidden state at the t-1th time step, x t is the input of the tth time step, ⊙ is the Hadamard product; The neuron h i Input to the Dropout layer, the output of the Dropout layer is, Where, p is the discard rate; The output h of the Dropout layer i ′ is input to the ReLU layer, and the ReLU layer selects the ReLU activation function, f(x) = max(0,x), where x is the output h of the Dropout layer i ′; The output y of the fully connected layer is, y=W fc ·h+b fc Among them, W fc is the weight matrix, b fc is the bias term, h is the output vector of the ReLU layer; The output y of the fully connected layer is input into the regression output layer, and the output of the regression output layer is the final prediction value of the LSTM traffic emission prediction model.
6. The method for predicting CO2 emissions and haze levels of urban traffic network based on LSTM according to claim 1 is characterized in that: The hyperparameters of the LSTM traffic emission prediction model are configured using the Adam gradient descent algorithm. The hyperparameters include the initial learning rate, batch size, number of iterations, and gradient threshold: Set the lag length of the LSTM traffic emission prediction model to 24; The Adam gradient descent algorithm is: m t =β1m t-1 +(1-β1)g t v t =β2v t-1 +(1-β2)g t 2 Among them, g t is the current gradient, m t ,v t are the momentum estimate of the gradient and the weighted average of the square gradient, β1 and β2 are the exponential decay rates of the momentum estimate and the square gradient estimate, η is the learning rate, and ε is a constant to prevent division by zero; The batch size is 30, the number of iterations is 1200, the initial learning rate is 0.01, and the gradient threshold is set to 6; the learning rate reduction cycle is set to 800, and the learning rate reduction factor is set to 0.
15.
7. The method for predicting CO2 emissions and haze levels of urban traffic network based on LSTM according to claim 1 is characterized in that: Evaluation metrics include root mean square error, mean absolute error, coefficient of determination, and mean absolute percentage error; The root mean square error is, Among them, x i is the actual value, y i is the predicted value, n is the number of samples; The mean absolute error is, Among them, x i is the actual value, y i is the predicted value, n is the number of samples; The coefficient of determination is, Among them, y i is the actual value, is the predicted value, is the average value of the actual value, and n is the number of samples; The mean absolute percentage error is, Among them, y i is the actual value, is the predicted value, and n is the number of samples.
8. A system for the LSTM-based urban traffic network CO2 emission and haze level prediction method according to any one of claims 1 to 7, characterized in that: Includes the following modules: A data collection module is configured to collect road monitoring data and vehicle characteristic data as input data; A characteristic variable screening module is configured to perform characteristic analysis on the input data using principal component analysis and correlation coefficient method, and screen out characteristic variables related to CO2 emissions and haze levels as input characteristic variables; A data preprocessing module is configured to perform normalization processing on the data set of the input feature variables to obtain a normalized feature variable data set; A data set division module is configured to divide the normalized feature variable data set into a training set and a test set; An LSTM model building module is configured to build an LSTM traffic emission prediction model, wherein the LSTM traffic emission prediction model includes a sequence input layer, an LSTM layer, a Dropout layer, a ReLU layer, a fully connected layer, and a regression output layer; A hyperparameter configuration module, configured to use the Adam gradient descent algorithm to configure the hyperparameters of the LSTM traffic emission prediction model, wherein the hyperparameters include an initial learning rate, a batch size, a number of iterations, and a gradient threshold; and The emission prediction and evaluation module is configured to input the normalized feature variable data set into the LSTM traffic emission prediction model with set hyperparameters for training, obtain a prediction model for CO2 emissions and haze levels of urban traffic road networks, and use evaluation indicators to evaluate the prediction model for CO2 emissions and haze levels.
9. A computer system, characterized in that: include: a processor configured to execute machine-readable instructions; A graphics card with an artificial intelligence chip configured to train an LSTM-based urban traffic network CO2 emission and haze level prediction method; as well as A memory configured to store machine-readable instructions, wherein the machine-readable instructions, when executed by a processor and / or a graphics card, perform the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Machine-readable instructions are stored thereon, and when the machine-readable instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are performed.