Air quality index prediction method based on SARIMA-LSTM combined model
By combining SARIMA and LSTM models and introducing time-varying weighting method, the limitations of traditional AQI prediction methods in processing complex data are solved, and AQI prediction with higher accuracy and reliability is achieved.
Patent Information
- Application Number
- CN202411838484.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-25
AI Technical Summary
The traditional air quality index (AQI) prediction method has limitations in dealing with nonlinear relationships, complex pattern recognition and long-time series data, resulting in low prediction accuracy and poor adaptability.
The air quality index prediction method based on the SARIMA-LSTM combination model is adopted, and AQI prediction is carried out by obtaining the historical data of air quality, SARIMA model and LSTM model are established, and the two are combined based on the time-varying weight method.
It significantly improves the accuracy and reliability of AQI predictions, can capture seasonal and trend components in time series data more accurately, handle complex time dependencies, and maintain real-time performance when processing large-scale datasets.
Smart Images

Figure CN119884813A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of air quality forecasting and relates to an air quality index prediction method based on a SARIMA-LSTM combined model. Background Art
[0002] Accurate prediction of the air quality index (AQI) is of great significance for taking timely emergency measures and improving public health awareness. Traditional air quality index prediction methods mainly rely on meteorological data, historical pollution records, and environmental science theoretical models. However, these methods have limitations in dealing with nonlinear relationships, complex pattern recognition, and long time series data, resulting in low prediction accuracy and poor adaptability.
[0003] In recent years, machine learning technology has been widely used in various fields due to its powerful data processing and pattern recognition capabilities. In particular, algorithms such as long short-term memory networks (LSTM) and convolutional neural networks (CNN) in deep learning have shown excellent performance for time series analysis and complex data set learning tasks. In addition, the combination of multiple algorithms to form a composite model has also been proven to further improve the accuracy and stability of predictions.
[0004] In view of this, the present invention aims to propose an air quality index prediction method based on the SARIMA-LSTM combined model, in order to achieve more accurate AQI prediction. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide an air quality index prediction method based on the SARIMA-LSTM combined model, in order to achieve accurate prediction of AQI.
[0006] In order to achieve the above object, the present invention provides the following technical solutions:
[0007] A method for predicting air quality index based on SARIMA-LSTM combined model, the method comprising the following steps:
[0008] Obtain historical air quality data, including AQI data, pollutant concentration data, and meteorological factor data;
[0009] Draw the AQI time series diagram and decompose the AQI sequence trend, establish the SARIMA model, and predict the AQI;
[0010] Preprocess the AQI data, pollutant concentration data, and meteorological factor data, establish an LSTM model, and predict the AQI;
[0011] A SARIMA-LSTM combined model is established based on the time-varying weight method to predict AQI.
[0012] Further, the SARIMA model is established, specifically comprising the following steps:
[0013] Draw an AQI time series diagram, analyze its long-term and seasonal trends, and determine the cycle length S;
[0014] Use the ADF test to determine whether the sequence is stable. If it is not stable, use the difference operation to make the sequence stable and determine the number of differences d;
[0015] Decompose the AQI sequence into trends, analyze the seasonality of the sequence, perform seasonal differences, and determine the number of seasonal differences D;
[0016] Through the ACF graph of the autocorrelation function and the PACF graph of the partial autocorrelation function, the values of p, q, P, and Q are determined, where p represents the order of the autoregressive term, q represents the order of the moving average term, P represents the order of the seasonal autoregressive term, and Q represents the order of the seasonal moving average term;
[0017] Use grid search to determine different combinations of p, q, P, Q, and use R 2 , AIC and BIC evaluation indicators are used to evaluate the performance of the model, and the best parameter combination is selected to establish the SARIMA model.
[0018] Furthermore, the data preprocessing specifically includes the following steps:
[0019] Perform data cleaning on the historical air quality data and check each column in the data set; determine whether there are missing values by calculating the ratio of the number of non-null values in each column to the total number; select an appropriate strategy to handle missing values according to the specific situation; if the weak data set is large and the ratio of missing values is not high, delete the rows containing missing values; use the mean, median or mode statistic to fill the missing values; or use interpolation methods or prediction methods based on other features to fill the missing values;
[0020] To handle outliers in the data, calculate the Z-score of each feature and select the absolute value of the Z-score greater than 3 as the threshold, indicating that the point is an outlier. Remove the outlier or use a reasonable value to replace the outlier.
[0021] Then normalization is performed to scale the value of each feature to the interval [0,1];
[0022] The preprocessed data is divided into a training set and a test set with a split ratio of 4:1, that is, 20% of the data is used for testing.
[0023] Further, the establishment of the LSTM model specifically includes the following steps:
[0024] Set the number of input layers to 1 and the number of neurons to 12, which are 6 pollutants and 6 meteorological factors respectively; set the number of neurons in the hidden layer to 128; set the number of output layers to 1 and the number of neurons to 1, which is AQI;
[0025] The activation function uses Tanh, the loss function uses MSE, the optimizer uses Adam, and the Dropout parameter is set between 0.2 and 0.5.
[0026] Further, the SARIMA-LSTM combined model is established based on the time-varying weight method, specifically including the following steps:
[0027] The prediction performance of each model is evaluated regularly, and the root mean square error (RMSE) is used as the evaluation index to calculate the weight. The calculation formula is:
[0028]
[0029]
[0030] Among them, RMSE i represents the root mean square error of the i-th model, n represents the number of samples, y t represents the actual value of AQI at time t, y ti represents the predicted value of AQI of the ith model at time t, S i represents the performance score of the i-th model, ∈ is a small constant, ω i represents the weight of the i-th model;
[0031] Use EMA to smooth the weights, the calculation formula is:
[0032] ω′ ti =αω (t-1)i +(1-α)ω ti
[0033] Among them, ω′ ti represents the weight of the i-th model at time t after using EMA smoothing update, α is the smoothing coefficient, ω (t-1)i represents the weight of the i-th model at time t-1, ω ti represents the weight of the i-th model at time t;
[0034] Assume that the predicted values of the two models at time t are and The weights are ω′ t1 and ω′ t2 , then the predicted value of the combined model at time t is
[0035] Furthermore, the normalization process specifically includes the following steps:
[0036] Use minimum-maximum normalization to scale the value of each feature to the [0,1] interval. The calculation formula is:
[0037]
[0038] Among them, x is the original eigenvalue, min(x) is the minimum eigenvalue, max(x) is the maximum eigenvalue, and x' is the normalized eigenvalue.
[0039] The beneficial effects of the present invention are:
[0040] (1) The designed method combines the advantages of the SARIMA model and the LSTM model. The SARIMA model is used to capture the seasonal and trend components in the time series data, and the LSTM model is used to capture the complex time dependency, which significantly improves the accuracy of AQI prediction.
[0041] (2) The designed method introduces an adaptive weight adjustment mechanism to dynamically adjust the contribution of the SARIMA and LSTM models, making the prediction results more accurate and reliable;
[0042] (3) The designed method adopts an effective missing value detection and processing mechanism in the data preprocessing stage to ensure the quality of the data; by checking the missing values in the data and performing corresponding processing, the robustness of the model to data quality is improved;
[0043] (4) The designed method can still maintain high real-time performance when processing large-scale data sets and can quickly respond to dynamic changes in air quality, making it suitable for real-time prediction application scenarios.
[0044] Other advantages, objectives and features of the present invention will be described in the following description to some extent, and to some extent, will be obvious to those skilled in the art based on the following examination and study, or can be taught from the practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below in conjunction with the accompanying drawings, wherein:
[0046] Figure 1 A flowchart of a method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments only illustrate the basic concept of the present invention in a schematic manner, and the following embodiments and features in the embodiments can be combined with each other without conflict.
[0048] Among them, the drawings are only used for illustrative explanations, and they only represent schematic diagrams rather than actual pictures, and should not be understood as limitations on the present invention. In order to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of actual products. For those skilled in the art, it is understandable that some well-known structures and their descriptions in the drawings may be omitted.
[0049] The same or similar numbers in the drawings of the embodiments of the present invention correspond to the same or similar parts; in the description of the present invention, it should be understood that if the terms "upper", "lower", "left", "right", "front", "rear", etc. indicate the orientation or position relationship, they are based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the terms describing the position relationship in the drawings are only used for illustrative purposes and cannot be understood as limiting the present invention. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to specific circumstances.
[0050] The embodiment of the present invention obtains historical air quality data, including AQI data, pollutants (PM 2.5 、PM 10 , NO2, O3, SO2, CO) concentration data, meteorological factors (maximum temperature, minimum temperature, average air pressure, relative humidity, precipitation, average wind speed) data; establish a SARIMA model to predict AQI; establish an LSTM model to predict AQI; establish a SARIMA-LSTM combined model based on the time-varying weight method to obtain a more accurate AQI prediction value.
[0051] Figure 1 A flowchart of a method provided by an embodiment of the present invention.
[0052] Furthermore, the present invention provides an air quality index prediction method based on the SARIMA-LSTM combined model, and the method specifically comprises the following steps:
[0053] Step S1, obtain historical air quality data, including AQI data, pollutant concentration data, and meteorological factor data. In particular, among the many factors that affect AQI, six pollutants (PM 2.5 、PM 10 , NO2, O3, SO2, CO) and 6 meteorological factors (maximum temperature, minimum temperature, average air pressure, relative humidity, precipitation, average wind speed) have the greatest influence on AQI. Therefore, the embodiment of the present invention only selects to obtain data of these 12 factors.
[0054] Step S2, draw the AQI time series diagram and perform trend decomposition on the AQI sequence, establish the SARIMA model, and predict the AQI. Draw the AQI time series diagram, analyze its long-term trend and seasonal trend, determine the cycle length S, for example, for data of 12 months a year, S can take the value of 12; use the ADF test to determine whether the sequence is stationary. If it is not stationary, it is necessary to use the difference operation to make the sequence stationary, and determine the number of differences d; decompose the AQI sequence, analyze the seasonality of the sequence and perform seasonal differences to determine the number of seasonal differences D; determine the values of p, q, P, and Q through the autocorrelation function (ACF) graph and the partial autocorrelation function (PACF) graph, where p represents the order of the autoregressive term, q represents the order of the moving average term, P represents the order of the seasonal autoregressive term, and Q represents the order of the seasonal moving average term; use the grid search method to determine different combinations of p, q, P, and Q, and use R 2 , AIC, BIC and other evaluation indicators are used to evaluate the performance of the model, and the best parameter combination is selected to establish the SARIMA model.
[0055] Step S3, preprocess the AQI data, pollutant concentration data, and meteorological factor data, establish an LSTM model, and predict the AQI. Clean the historical air quality data, check each column in the data set to determine whether there are missing values; you can determine whether there are missing values by calculating the ratio of the number of non-null values in each column to the total number; select an appropriate strategy to handle missing values according to the specific situation; if the data set is large and the proportion of missing values is not high, you can directly delete the rows containing missing values; you can use statistics such as mean, median or mode to fill in missing values; you can also use interpolation methods or prediction methods based on other features to fill in missing values;
[0056] To handle outliers in the data, calculate the Z-score for each feature and select the absolute value of the Z-score greater than 3 as the threshold, indicating that the point is an outlier. You can directly delete the outlier or use a reasonable value (mean, median) to replace the outlier. The Z-score is a statistic used to measure the difference between an observation and the mean of the sample to which it belongs, in units of standard deviation. The calculation formula for the Z-score is:
[0057]
[0058] Where X is the observed value, μ is the mean of the sample, σ is the standard deviation of the sample, and Z is the calculated Z-score value.
[0059] Normalizing the air quality historical data and scaling the value of each feature to the interval [0, 1];
[0060] Use minimum-maximum normalization to scale the value of each feature to the [0,1] interval. The calculation formula is:
[0061]
[0062] Among them, x is the original eigenvalue, min(x) is the minimum eigenvalue, max(x) is the maximum eigenvalue, and x' is the normalized eigenvalue;
[0063] The preprocessed data is divided into a training set and a test set, with a division ratio of 4:1, that is, 20% of the data is used for testing.
[0064] Step S4, based on the time-varying weight method, a SARIMA-LSTM combined model is established to predict AQI. The prediction performance of each model is evaluated regularly, using the root mean square error (RMSE) as the evaluation metric; RMSE emphasizes larger errors because it squares the errors. This means that larger prediction errors will be amplified, which will have a greater impact on the overall performance of the model. This sensitivity makes RMSE an effective tool for detecting whether the model has serious deviations; the weight calculation formula is:
[0065]
[0066] Among them, RMSE i represents the root mean square error of the i-th model, n represents the number of samples, y t represents the actual value of AQI at time t, y ti represents the predicted value of AQI of the ith model at time t, S i represents the performance score of the i-th model, ∈ is a small constant, ω i represents the weight of the i-th model;
[0067] Use EMA to smooth weights. EMA can smooth weight changes, reduce drastic changes in weights caused by short-term fluctuations, and is conducive to the long-term stable operation of the model. The weight calculation formula is:
[0068] ω′ ti =αω (t-1)i +(1-α)ωti
[0069] Among them, ω′ ti represents the weight of the i-th model at time t after using EMA smoothing update, α is the smoothing coefficient, ω (t-1)i represents the weight of the i-th model at time t-1, ω ti represents the weight of the i-th model at time t;
[0070] Assume that the predicted values of the two models at time t are and The weights are ω′ t1 and ω′ t2 , then the predicted value of the combined model at time t is For example, the actual value of AQI on a certain day is 153, the predicted value of AQI on that day by the SARIMA model is 138, and the predicted value of AQI on that day by the LSTM model is 137. According to the weight calculation formula, if the value of α is 0.9, the weight of the SARIMA model is 0.51, and the weight of the LSTM model is 0.49; that is, the predicted value of the combined model on that day is
[0071] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution, which should be included in the scope of the claims of the present invention.
Claims
1. An air quality index prediction method based on the SARIMA-LSTM combined model, characterized by: The method comprises the following steps: Obtain historical air quality data, including AQI data, pollutant concentration data, and meteorological factor data; Draw the AQI time series diagram and decompose the AQI sequence trend, establish the SARIMA model, and predict the AQI; Preprocess the AQI data, pollutant concentration data, and meteorological factor data, establish an LSTM model, and predict the AQI; A SARIMA-LSTM combined model is established based on the time-varying weight method to predict AQI.
2. The air quality index prediction method based on the SARIMA-LSTM combined model according to claim 1, characterized in that: The SARIMA model is established, and specifically comprises the following steps: Draw an AQI time series diagram, analyze its long-term and seasonal trends, and determine the cycle length S; Use the ADF test to determine whether the sequence is stable. If it is not stable, use the difference operation to make the sequence stable and determine the number of differences d; Decompose the AQI sequence into trends, analyze the seasonality of the sequence, perform seasonal differences, and determine the number of seasonal differences D; Through the ACF graph of the autocorrelation function and the PACF graph of the partial autocorrelation function, the values of p, q, P, and Q are determined, where p represents the order of the autoregressive term, q represents the order of the moving average term, P represents the order of the seasonal autoregressive term, and Q represents the order of the seasonal moving average term; Use grid search to determine different combinations of p, q, P, Q, and use R 2 , AIC and BIC evaluation indicators are used to evaluate the performance of the model, and the best parameter combination is selected to establish the SARIMA model.
3. The air quality index prediction method based on the SARIMA-LSTM combined model according to claim 1, characterized in that: The data preprocessing specifically includes the following steps: Perform data cleaning on the historical air quality data and check each column in the data set; determine whether there are missing values by calculating the ratio of the number of non-null values in each column to the total number; select an appropriate strategy to handle missing values according to the specific situation; if the weak data set is large and the ratio of missing values is not high, delete the rows containing missing values; use the mean, median or mode statistic to fill the missing values; or use interpolation methods or prediction methods based on other features to fill the missing values; To handle outliers in the data, calculate the Z-score of each feature and select the absolute value of the Z-score greater than 3 as the threshold, indicating that the point is an outlier. Remove the outlier or use a reasonable value to replace the outlier. Then normalization is performed to scale the value of each feature to the interval [0,1]; The preprocessed data is divided into a training set and a test set with a split ratio of 4:1, that is, 20% of the data is used for testing.
4. The air quality index prediction method based on the SARIMA-LSTM combined model according to claim 1, characterized in that: The LSTM model is established, specifically comprising the following steps: Set the number of input layers to 1 and the number of neurons to 12, which are 6 pollutants and 6 meteorological factors respectively; set the number of neurons in the hidden layer to 128; set the number of output layers to 1 and the number of neurons to 1, which is AQI; The activation function uses Tanh, the loss function uses MSE, the optimizer uses Adam, and the Dropout parameter is set between 0.2 and 0.
5.
5. The air quality index prediction method based on the SARIMA-LSTM combined model according to claim 1, characterized in that: The SARIMA-LSTM combined model is established based on the time-varying weight method, specifically comprising the following steps: The prediction performance of each model is evaluated regularly, and the root mean square error (RMSE) is used as the evaluation index to calculate the weight. The calculation formula is: Among them, RMSE i represents the root mean square error of the i-th model, n represents the number of samples, y t represents the actual value of AQI at time t, y ti represents the predicted value of AQI of the ith model at time t, S i represents the performance score of the i-th model, ∈ is a small constant, ω i represents the weight of the i-th model; Use EMA to smooth the weights, and the calculation formula is: oh' ti =oh (t-1)i +(1-a)ω ti Among them, ω′ ti represents the weight of the i-th model at time t after using EMA smoothing update, α is the smoothing coefficient, ω (t-1)i represents the weight of the i-th model at time t-1, ω ti represents the weight of the i-th model at time t; Assume that the predicted values of the two models at time t are and The weights are ω′ t1 and ω′ t2 , then the predicted value of the combined model at time t is 6. The air quality index prediction method based on the SARIMA-LSTM combined model according to claim 3, characterized in that: The normalization process specifically includes the following steps: Use minimum-maximum normalization to scale the value of each feature to the [0,1] interval. The calculation formula is: Among them, x is the original eigenvalue, min(x) is the minimum eigenvalue, max(x) is the maximum eigenvalue, and x' is the normalized eigenvalue.
Citation Information
Cited By
Intelligent billiard judgment system based on image recognition
CN120107871A
Billiard intelligent judging system based on image recognition
CN120107871B
Atmospheric pollution concentration prediction method and system, electronic equipment and storage medium
CN120893613A