A model for forecasting air quality

By combining machine learning models and the Prophet algorithm, air quality prediction is optimized, solving the problems of large computational load, long time, and low stability in existing technologies. This achieves efficient and accurate air quality prediction, especially accurate prediction in small-scale and sudden situations.

CN116151469BActive Publication Date: 2026-05-29BEIJING MINGHE ENVIRONMENTAL ENERGY TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING MINGHE ENVIRONMENTAL ENERGY TECH CO LTD
Filing Date
2023-03-09
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing air quality forecasting methods suffer from problems such as huge computational load, excessive time, low stability, and low universality. Furthermore, the collection of comprehensive and accurate data on atmospheric pollutant emission sources is difficult, leading to inaccurate forecast results, especially in small-scale, high-resolution, and sudden situations.

Method used

This study employs a machine learning model combined with the Prophet algorithm. By defining input features and building a machine learning model, it trains the model using historical pollutant and meteorological data to predict future air quality. The machine learning models include random forest and gradient boosting forest models. The results are integrated with the Prophet algorithm to optimize short-term prediction accuracy.

Benefits of technology

It improves the accuracy of air quality forecasts and the ability to predict sudden events, reduces computational load and time costs, and enhances the stability and general applicability of the model.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The application discloses a model for forecasting air quality, and belongs to the technical field of environmental air quality, and the specific method is as follows: input features are determined according to the characteristics of pollutants and the length of time to be predicted; a machine learning prediction model for various pollutants in the future N hours is established by using measured data of pollutants and weather in the past several years; the machine learning model is deployed to a server, measured data of pollutants and weather in the recent period of time are obtained from a database according to the input features, and the measured data are input into the machine learning model to obtain predicted values of the pollutants in the future N hours; and the Prophet algorithm is used to calculate the predicted values of the pollutants from the N+1th hour to the set end time. Through the model, the air quality is predicted, and the disadvantages of an abnormally huge calculation amount, a long time, low stability and low universality of a numerical model are solved; and the statistical model is also solved for the shortcomings of poor prediction accuracy and poor prediction on sudden or irregular phenomena.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of ambient air quality technology, specifically, it relates to a model for forecasting air quality. Background Technology

[0002] Air quality models are mathematical tools that use meteorological principles and mathematical methods to simulate air quality on a large scale, both horizontally and vertically, based on human scientific understanding of atmospheric physical and chemical processes. They reproduce the processes of pollutant transport, reaction, and removal in the atmosphere. They are important technical methods for analyzing the spatiotemporal evolution of air pollution, its underlying mechanisms and causes, establishing a quantitative relationship between "pollutant emission reduction" and "air quality improvement," and promoting the transition of my country's environmental planning and management towards quantitative and refined approaches.

[0003] Currently, there are two main methods for air quality forecasting: one is the more traditional method, which can be collectively referred to as numerical simulation. The core of numerical methods is based on atmospheric dynamics and atmospheric environmental chemistry, using mathematical methods to simulate the physical and chemical processes affecting the diffusion and reaction of air pollutants. Based on input meteorological data and pollution source information, it simulates primary pollutants directly emitted into the atmosphere and secondary pollutants formed due to complex chemical reactions. However, numerical models involve an exceptionally large amount of computation, requiring a very long time even for supercomputers. Furthermore, extensive application has demonstrated that numerical models are more advantageous on large spatial scales and long timescales; the massive computational cost required for small-scale, high-resolution models is their biggest disadvantage. Moreover, collecting comprehensive and accurate data on air pollutant emission sources is difficult. In the chaotic system of the atmosphere, even small data deviations can lead to huge differences in results. The enormous computational demands severely limit the universality of this method. The other, more popular method in recent years, is based on statistics, establishing a relationship between pollutant concentrations and meteorological fields to predict air quality over a future period.

[0004] The two approaches mentioned above require a large amount of historical air quality data as the basis for model training to improve prediction accuracy. During the training process, the computational load of the numerical model may be huge and the time required is also long. At the same time, the accuracy of air quality prediction and the prediction performance for sudden or unconventional events in the above approaches need to be further improved.

[0005] Technical solution

[0006] To solve the above problems, the present invention adopts the following technical solution.

[0007] A model for predicting air quality is shown below:

[0008] Step 1: Determine the input features of the machine learning model: Based on the characteristics of different pollutants and the required prediction time period, determine which time period concentration values ​​need to be included in the input features, and determine whether the input features need to include meteorological data based on the relationship with meteorological conditions. In addition, the input features of all machine learning models should include time data such as month, date, hour, and weekday.

[0009] Step 2: Establish Machine Learning Models: Divide the hourly measured data of pollutants and meteorological data from the past four years into training and validation sets. For each pollutant, establish a machine learning model based on the input features determined in Step 1. The number of models for each pollutant is the same as the number of hours to be predicted. For example, to predict PM2.5 in the next 8 hours... 2.5 For concentration, eight models need to be established, each model is used to predict the concentration at a specific time. The input features of each model are determined in the manner of step one.

[0010] Step 3, Machine Learning Prediction: Deploy the machine learning model obtained in Step 2 to the server, determine the corresponding input features based on the type of pollutant and the prediction time length, obtain data from the database according to the input features, process the data and input it into the machine learning model to obtain the predicted pollutant concentration values ​​for the next N hours.

[0011] Step 4: Time series forecasting: Use the Prophet algorithm to calculate the predicted values ​​of various pollutants for the next few days;

[0012] Step 5: Algorithm Integration: Combine the prediction results from machine learning with those from Prophet. Use the machine learning prediction results for the next N hours, and start using the Prophet prediction results from the N+1th hour onwards.

[0013] Preferably, before establishing the machine learning model in step two, the hourly measured data of pollutants and meteorology from 1:00 AM on January 1, 2018 to 11:59 PM on December 31, 2021 are divided into a training set and a validation set in a ratio of 8:2. The training set is used to establish the machine learning model, and the validation set is used to verify the accuracy of the model.

[0014] Furthermore, in step three, before the data is input into the machine learning model, missing values ​​need to be filled in. The specific processing steps are as follows:

[0015] For the measured values ​​of pollutants, when querying the database, all measured values ​​of the past 60 hours are obtained at once and formed into a table. If the first and last rows of the table are missing, they are filled with the average value of the column containing the missing values. If there are missing values ​​in the middle, they can be filled by interpolation.

[0016] If meteorological data is missing, fill it with 0 directly;

[0017] Time data can be specified at runtime, so there is no possibility of missing data.

[0018] Furthermore, the machine learning models include random forest models and gradient boosting forest models.

[0019] Furthermore, the model's air quality prediction range includes PM2.5. 2.5 PM 10 CO and O3. Detailed Implementation

[0020] Example 1:

[0021] A model for predicting air quality is shown below:

[0022] Step 1: Determine the input features of the machine learning model: based on PM 2.5 Based on the characteristics and the length of time to be predicted, and combined with parameter tuning experiments, the input features required for the model to predict different times are obtained (let the time point to be predicted be hour 0, for example, to predict data 1 hour later, then 1 hour later is hour 0, and the current time is hour -1):

[0023] Model 1 (predicting PM 1 hour later) 2.5 Input characteristics: Time data such as month, day, hour, and day of the week for the 0th hour; meteorological data such as temperature, wind speed, wind direction angle, atmospheric pressure, and humidity for the -1st hour; PM data for the -24h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, -3h, -2h, and -1h hours. 2.5 Measured value;

[0024] Model 2 (predicting PM 2 hours later) 2.5 Input characteristics: Time data such as month, day, hour, and day of the week for the 0th hour; meteorological data such as temperature, wind speed, wind direction angle, atmospheric pressure, and humidity for the -2nd hour; PM data for the -24h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, -3h, and -2h hours. 2.5 Measured value;

[0025] Model 3 (predicting PM 3 hours later) 2.5 Input features: Time data for the 0th hour (month, day, hour, weekday, etc.), and PM values ​​for the -60h, -48h, -36h, -24h, -23h, -20h, -17h, -14h, -11h, -8h, -5h, -3h, and -2h hours. 2.5 Measured value;

[0026] Model 4 (predicting PM 4 hours later) 2.5 Input features: Time data for the 0th hour (month, day, hour, weekday, etc.), and PM values ​​for the -60h, -48h, -36h, -24h, -23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, and -3h hours. 2.5 Measured value;

[0027] Model 5 (predicting PM 5 hours later) 2.5 Input features: Time data for the 0th hour (month, day, hour, weekday, etc.), and PM values ​​for the -60h, -48h, -36h, -24h, -23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -10h, -9h, -8h, -7h, -6h, and -5h hours. 2.5 Measured value;

[0028] Model 6 (Predicting PM 6 hours later) 2.5 Input features: Time data for the 0th hour (month, day, hour, weekday, etc.), and PM values ​​for the -60h, -48h, -36h, -24h, -23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -10h, -9h, -8h, -7h, -6h, -5h, and -4h hours. 2.5 Measured value;

[0029] Model 7 (predicting PM 7 hours later) 2.5 Input features: Time data for the 0th hour (month, day, hour, weekday, etc.), and PM values ​​for the -60h, -48h, -36h, -24h, -23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -10h, -9h, -8h, -7h, -6h, and -5h hours. 2.5 Measured value;

[0030] Model 8 (predicting PM 8 hours later) 2.5 Input features: Time data for the 0th hour (month, day, hour, weekday, etc.), and PM values ​​for the -60h, -48h, -36h, -24h, -23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -10h, -9h, -8h, -7h, and -6h hours.2.5 Measured value;

[0031] Step 2: Establish Machine Learning Models: Divide the hourly measured data of pollutants and meteorological data from 1:00 AM on January 1, 2018 to 11:59 PM on December 31, 2021 into training and validation sets at an 8:2 ratio. Obtain the corresponding input features and target values ​​(PM2.5) for models 1-8 from the training and validation sets respectively. 2.5 (Concentration), establish machine learning models, and the parameters and evaluation metrics of models 1-8 are as follows:

[0032] Model 1: A random forest model containing 300 decision trees, each with a maximum depth of 10, and R0 on the training set. 2 The R value on the validation set is 0.978. 2 It is 0.957;

[0033] Model 2: A gradient boosting forest model containing 200 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value on the validation set is 0.958. 2 It is 0.921;

[0034] Model 3: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value on the validation set is 0.962. 2 It is 0.906;

[0035] Model 4: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value on the validation set is 0.946. 2 It is 0.868;

[0036] Model 5: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 8, achieving R0 on the training set. 2 The value is 0.990, and the R value on the validation set is... 2 It is 0.853;

[0037] Model 6: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 8, achieving R0 on the training set. 2 The value is 0.990, and the R value on the validation set is... 2 It is 0.855;

[0038] Model 7: A random forest model containing 200 decision trees, each with a maximum depth of 15, achieving R² on the training set. 2 The R value on the validation set is 0.954. 2 It is 0.821;

[0039] Model 8: A random forest model containing 300 decision trees, each with a maximum depth of 5, achieving R0 on the training set. 2 The R value on the validation set is 0.906. 2 It is 0.802;

[0040] Step 3: Machine Learning Prediction: Deploy the machine learning model obtained in Step 2 to the server, retrieve the input feature data corresponding to models 1-8 from the database, process the data (replace missing values), and input it into the machine learning model to obtain the PM forecast for the next 8 hours. 2.5 Predicted value.

[0041] When calculating subsequent models, it may be necessary to use the prediction results of Model 1 and Model 2 as input features, specifically as follows: PM in the -2nd hour from the input features of Model 3. 2.5 The measured values ​​were obtained from the calculation results of Model 1; the PM values ​​for the -3rd hour were included in the input features of Model 4. 2.5 The measured values ​​were obtained from the calculation results of Model 1; the PM values ​​at -5h and -4h in the input features of Model 6 were... 2.5 The measured values ​​were obtained from the calculation results of Model 1 and Model 2, respectively; the PM values ​​at -6h and -5h in the input features of Model 7. 2.5 The measured values ​​were obtained from the calculation results of Model 1 and Model 2, respectively; the PM values ​​at -7h and -6h in the input features of Model 8. 2.5 The measured values ​​were obtained from the calculation results of Model 1 and Model 2, respectively.

[0042] Step 4: Time Series Forecasting: Use the Prophet algorithm to calculate PM2.5 levels for the next few days. 2.5 Predicted value;

[0043] Step 5, Algorithm Integration: Combine the prediction results from machine learning with those from Prophet. Use the machine learning prediction results for the next 8 hours, and start using the Prophet prediction results from the 9th hour onwards.

[0044] This model uses the Prophet algorithm for long-term predictions and machine learning algorithms to optimize accuracy for the next 8 hours. It solves the disadvantages of numerical models, such as excessive computational load, long time, low stability, and low generalizability. It also addresses the shortcomings of statistical models in improving prediction accuracy and predicting sudden or unconventional phenomena.

[0045] Example 2:

[0046] A model for predicting air quality is shown below:

[0047] Step 1: Determine the input features of the machine learning model: based on PM 10 Based on the characteristics and the length of time to be predicted, and combined with parameter tuning experiments, the input features required for the model to predict different times are obtained (let the time point to be predicted be hour 0, for example, to predict data 1 hour later, then 1 hour later is hour 0, and the current time is hour -1):

[0048] Model 1 (predicting PM 1 hour later) 10 Input characteristics: Time data such as month, day, hour, and day of the week for the 0th hour; meteorological data such as temperature, wind speed, wind direction angle, atmospheric pressure, and humidity for the -1st hour; PM data for the -24h and -1h hours. 10 Measured value;

[0049] Model 2 (predicting PM 2 hours later) 10 Input characteristics: Time data such as month, day, hour, and day of the week for the 0th hour; meteorological data such as temperature, wind speed, wind direction angle, atmospheric pressure, and humidity for the -2nd hour; PM data for the -24h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, -3h, -2h, and -1h hours. 10 Measured value;

[0050] Model 3 (predicting PM 3 hours later) 10 Input features: Time data for the 0th hour (month, day, hour, weekday, etc.), and PM values ​​for the -60h, -48h, -36h, -24h, -23h, -20h, -17h, -14h, -11h, -8h, -5h, -3h, and -2h hours. 10 Measured value;

[0051] Model 4 (predicting PM 4 hours later) 10 Input features: Time data for the 0th hour (month, day, hour, weekday, etc.), and PM values ​​for the -60h, -48h, -36h, -24h, -23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, and -3h hours. 10 Measured value;

[0052] Model 5 (predicting PM 5 hours later) 10Input features: Time data for the 0th hour (month, day, hour, weekday, etc.), and PM values ​​for the -60h, -48h, -36h, -24h, -23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, and -3h hours. 10 Measured value;

[0053] Step 2: Establish Machine Learning Models: Divide the hourly measured data of pollutants and meteorological data from 1:00 AM on January 1, 2018 to 11:59 PM on December 31, 2021 into training and validation sets at an 8:2 ratio. Obtain the corresponding input features and target values ​​(PM2.5) for models 1-5 from the training and validation sets respectively. 10 (Concentration), establish machine learning models, and the parameters and evaluation metrics of models 1-5 are as follows:

[0054] Model 1: A gradient boosting forest model containing 200 decision trees, each with a maximum depth of 7, and R0 on the training set. 2 The R value on the validation set is 0.976. 2 It is 0.938;

[0055] Model 2: A gradient boosting forest model containing 200 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value on the validation set is 0.965. 2 It is 0.928;

[0056] Model 3: A gradient boosting forest model containing 200 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value on the validation set is 0.916. 2 It is 0.868;

[0057] Model 4: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 6, achieving R0 on the training set. 2 The R value is 0.938 on the validation set. 2 It is 0.833;

[0058] Model 5: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 6, achieving R0 on the training set. 2 The R value is 0.938 on the validation set. 2 It is 0.833;

[0059] Model 4 and Model 5 are the same model, therefore R 2 The results were the same, but after deployment, the data input for Model 5 lagged behind Model 4 by one hour.

[0060] Step 3: Machine Learning Prediction: Deploy the machine learning model obtained in Step 2 to the server, retrieve the input feature data corresponding to models 1-5 from the database, process the data (replace missing values), and input it into the machine learning model to obtain the PM forecast for the next 5 hours. 10 Predicted value.

[0061] When calculating subsequent models, it may be necessary to use the prediction results of Model 1 and Model 2 as input features, specifically as follows: PM for the -1st hour in the input features of Model 2. 10 The measured values ​​were obtained from the calculation results of Model 1; the PM values ​​for the -2nd hour were included in the input features of Model 3. 10 The measured values ​​were obtained from the calculation results of Model 1; the PM values ​​for the -3rd hour were included in the input features of Model 4. 10 The measured values ​​were obtained from the calculation results of Model 1; the PM values ​​for the -4th and -3rd hours were included in the input features of Model 5. 10 The measured values ​​were obtained from the calculation results of Model 1 and Model 2, respectively.

[0062] Step 4: Time Series Forecasting: Use the Prophet algorithm to calculate PM2.5 levels for the next few days. 10 Predicted value;

[0063] Step 5: Algorithm Integration: The machine learning predictions are combined with the Prophet predictions. The machine learning predictions are used for the next 5 hours, while the PM predictions for the 6th, 8th, and 7th hours are used for the next three hours. 10 Predictive data, using PM 2.5 The prediction result is multiplied by a factor of 1.5 to obtain the PM value from Prophet starting from the 9th hour. 10 Prediction results.

[0064] The model uses the Prophet algorithm for long-term predictions, while employing machine learning algorithms to optimize accuracy for the next 5 hours. For the 6th, 7th, and 8th hours, it uses PM (Prophet Prophet) algorithms. 2.5 The predicted results are multiplied by a factor of 1.5 to prevent PM2.5 from being affected. 2.5 With PM 10 The generation of data inversion solves the disadvantages of numerical models, such as excessively large computational load, excessive time, low stability, and low generalizability; it also solves the shortcomings of statistical models in improving prediction accuracy and predicting sudden or unconventional phenomena.

[0065] Example 3:

[0066] A model for predicting air quality is shown below:

[0067] Step 1: Determine the input features of the machine learning model: Based on the characteristics of CO and the length of time to be predicted, and combined with parameter tuning experiments, obtain the input features required for the model to predict different times (let the time point to be predicted be hour 0, for example, if you want to predict data 1 hour later, then 1 hour later is hour 0, and the current time is hour -1):

[0068] Input features of Model 1 (predicting CO 1 hour later): time data such as month, day, hour, and weekday for hour 0, and measured CO values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, -3h, -2h, and -1h;

[0069] Input features for Model 2 (predicting CO 2 hours later): time data such as month, day, hour, and weekday for hour 0; and measured CO values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, -3h, and -2h.

[0070] The input features of Model 3 (predicting CO 3 hours later) are: time data such as month, day, hour, and weekday for hour 0, and measured CO values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, and -3h.

[0071] The input features of Model 4 (predicting CO 4 hours later) are: time data such as month, day, hour, and weekday for hour 0, and measured CO values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, and -4h.

[0072] The input features of Model 5 (predicting CO 5 hours later) are: time data such as month, day, hour, and weekday for hour 0, and measured CO values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, and -5h.

[0073] Step 2: Establish Machine Learning Models: Divide the hourly measured data of pollutants and meteorological data from 1:00 AM on January 1, 2018 to 11:59 PM on December 31, 2021 into training and validation sets at an 8:2 ratio. Obtain the corresponding input features and target values ​​(CO concentration) for models 1-5 from the training and validation sets respectively, and establish machine learning models. The parameters and evaluation metrics for models 1-5 are as follows:

[0074] Model 1: A random forest model containing 300 decision trees, each with a maximum depth of 8, achieving R² on the training set. 2 The R value on the validation set is 0.916. 2 It is 0.881;

[0075] Model 2: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 8, achieving R0 on the training set. 2 The R value on the validation set is 0.978. 2 It is 0.773;

[0076] Model 3: A gradient boosting forest model containing 100 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value on the validation set is 0.772. 2 It is 0.680;

[0077] Model 4: A gradient boosting forest model containing 100 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value on the validation set is 0.716. 2 It is 0.631;

[0078] Model 5: A gradient boosting forest model containing 100 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value on the validation set is 0.683. 2 It is 0.570;

[0079] Step 3, Machine Learning Prediction: Deploy the machine learning model obtained in Step 2 to the server, retrieve the input feature data corresponding to models 1-5 from the database, process the data (replace missing values) and input it into the machine learning model to obtain the CO prediction value for the next 5 hours.

[0080] Step 4, Time Series Forecasting: Use the Prophet algorithm to calculate the predicted CO values ​​for the next few days;

[0081] Step 5: Algorithm Integration: Combine the prediction results from machine learning with those from Prophet. Use the machine learning prediction results for the next 5 hours, and start using the Prophet prediction results from the 6th hour onwards.

[0082] This model uses the Prophet algorithm for long-term predictions and machine learning algorithms to optimize accuracy for the next 5 hours. It solves the disadvantages of numerical models, such as excessive computational load, long time, low stability, and low generalizability. It also addresses the shortcomings of statistical models in improving prediction accuracy and predicting sudden or unconventional phenomena.

[0083] Example 4:

[0084] A model for predicting air quality is shown below:

[0085] Step 1: Determine the input features of the machine learning model: Based on the characteristics of O3 and the length of time to be predicted, and combined with parameter tuning experiments, obtain the input features required for the model to predict different times (let the time point to be predicted be hour 0, for example, if you want to predict data 1 hour later, then 1 hour later is hour 0, and the current time is hour -1):

[0086] Input features of Model 1 (predicting O3 after 1 hour): time data such as month, day, hour, and weekday for hour 0, and measured O3 values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, -3h, -2h, and -1h.

[0087] Input features of Model 2 (predicting O3 2 hours later): time data such as month, day, hour, and weekday for hour 0, and measured O3 values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, -3h, and -2h.

[0088] Input features of Model 3 (predicting O3 after 3 hours): time data such as month, day, hour, and weekday for hour 0, and measured O3 values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, -4h, and -3h.

[0089] Input features of Model 4 (predicting O3 4 hours later): time data such as month, day, hour, and weekday at hour 0, and measured O3 values ​​at hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, -5h, and -4h.

[0090] Input features of Model 5 (predicting O3 after 5 hours): time data such as month, day, hour, and weekday at hour 0, and measured O3 values ​​at hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, -6h, and -5h.

[0091] The input features of Model 6 (predicting O3 after 6 hours) are: time data such as month, day, hour, and weekday for hour 0, and measured O3 values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, -7h, and -6h.

[0092] Input features for Model 7 (predicting O3 7 hours later): time data such as month, day, hour, and weekday for hour 0, and measured O3 values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, -8h, and -7h.

[0093] Input features for Model 8 (predicting O3 after 8 hours): time data such as month, day, hour, and weekday for hour 0; and measured O3 values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, -9h, and -8h.

[0094] Input features for Model 9 (predicting O3 9 hours later): time data such as month, day, hour, and weekday for hour 0; and measured O3 values ​​for hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, and -9h.

[0095] Input features of Model 10 (predicting O3 after 10 hours): time data such as month, day, hour, and weekday at hour 0, and measured O3 values ​​at hours -30h, -29h, -28h, -27h, -26h, -25h, -24h, 23h, -22h, -21h, -20h, -19h, -18h, -17h, -16h, -15h, -14h, -13h, -12h, -11h, -10h, and -9h;

[0096] Step 2: Establish Machine Learning Models: Divide the hourly measured data of pollutants and meteorological conditions from 1:00 AM on January 1, 2018 to 11:59 PM on December 31, 2021 into training and validation sets at an 8:2 ratio. Obtain the corresponding input features and target values ​​(O3 concentration) for models 1-10 from both the training and validation sets, and establish machine learning models. The parameters and evaluation metrics for models 1-10 are as follows:

[0097] Model 1: A random forest model containing 300 decision trees, each with a maximum depth of 8, achieving R² on the training set. 2 The R value on the validation set is 0.967. 2It is 0.961;

[0098] Model 2: A random forest model containing 300 decision trees, each with a maximum depth of 8, achieving R² on the training set. 2 The R value on the validation set is 0.917. 2 It is 0.895;

[0099] Model 3: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value on the validation set is 0.916. 2 It is 0.872;

[0100] Model 4: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value is 0.895 on the validation set. 2 It is 0.838;

[0101] Model 5: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, achieving R0 on the training set. 2 The R value is 0.877 on the validation set. 2 It is 0.809;

[0102] Model 6: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value is 0.865 on the validation set. 2 It is 0.799;

[0103] Model 7: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, achieving R0 on the training set. 2 The R value on the validation set is 0.852. 2 It is 0.789;

[0104] Model 8: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, achieving R0 on the training set. 2 The R value on the validation set is 0.844. 2 It is 0.776;

[0105] Model 9: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, and R0 on the training set. 2 The R value is 0.835 on the validation set. 2 It is 0.765;

[0106] Model 10: A gradient boosting forest model containing 300 decision trees, each with a maximum depth of 5, achieving R0 on the training set.2 The R value is 0.835 on the validation set. 2 It is 0.765;

[0107] Model 9 and Model 10 are the same model, therefore R 2 The results were the same, but after deployment, the data input to Model 10 lagged behind Model 9 by one hour.

[0108] Step 3, Machine Learning Prediction: Deploy the machine learning model obtained in Step 2 to the server, retrieve the input feature data corresponding to Models 1-10 from the database, process the data (replace missing values) and input it into the machine learning model to obtain the O3 prediction value for the next 10 hours; in addition, when Model 10 is calculated, the measured O3 value of the -9th hour in its input features is obtained from the calculation result of Model 1.

[0109] Step 4: Time series forecasting: Use the Prophet algorithm to calculate the predicted O3 values ​​for the next few days;

[0110] Step 5: Algorithm Integration: Combine the prediction results from machine learning with those from Prophet. Use the machine learning prediction results for the next 10 hours, and start using the Prophet prediction results from the 11th hour onwards.

[0111] This model uses the Prophet algorithm for long-term predictions and machine learning algorithms to optimize accuracy for the next 10 hours. It addresses the disadvantages of numerical models, such as excessive computational load, long time duration, low stability, and low generalizability. It also overcomes the shortcomings of statistical models in improving prediction accuracy and predicting sudden or unconventional phenomena.

Claims

1. A method for forecasting air quality, characterized in that, The details are as follows: Step 1: Determine the input features of the machine learning model: Based on the characteristics of different pollutants and the required prediction time period, determine which time period concentration values ​​need to be included in the input features, and determine whether the input features need to include meteorological data based on the relationship with meteorological conditions. In addition, the input features of all machine learning models should include month, date, hour, and weekday data. Step 2: Establish machine learning models: Divide the hourly measured data of pollutants and meteorology over the past four years into training and validation sets. For each pollutant, establish a machine learning model based on the input features determined in Step 1. The number of models for each pollutant is the same as the number of hours to be predicted. To predict the PM2.5 concentration in the next 8 hours, 8 models need to be established. Each model is used to predict the concentration at a specific time. The input features of each model are determined in the manner of Step 1. Step 3, Machine Learning Prediction: Deploy the machine learning model obtained in Step 2 to the server, determine the corresponding input features based on the type of pollutant and the prediction time length, obtain data from the database according to the input features, process the data and input it into the machine learning model to obtain the predicted pollutant concentration values ​​for the next N hours. Step 4: Time series forecasting: Use the Prophet algorithm to calculate the predicted values ​​of various pollutants for the next few days; Step 5: Algorithm Integration: Combine the prediction results from machine learning with those from Prophet. Use the machine learning prediction results for the next N hours, and start using the Prophet prediction results from the N+1th hour onwards.

2. The method for forecasting air quality according to claim 1, characterized in that: Before establishing the machine learning model in step two, the hourly measured data of pollutants and meteorology from 1:00 AM on January 1, 2018 to 11:59 PM on December 31, 2021 are divided into a training set and a validation set in a ratio of 8:

2. The training set is used to establish the machine learning model, and the validation set is used to verify the accuracy of the model.

3. The method for forecasting air quality according to claim 2, characterized in that: In step three, before the data is input into the machine learning model, missing values ​​need to be filled. The specific processing steps are as follows: For the measured values ​​of pollutants, all measured values ​​of the past 60 hours are obtained from the database at once and a table is formed. If there are missing values ​​in the first and last rows of the table, they are filled with the average value of the column where the missing values ​​are located. If there are missing values ​​in the middle, they are filled with interpolation. If meteorological data is missing, fill it with 0 directly; Time data is specified at runtime, so there are no missing data.

4. The method for forecasting air quality according to claim 3, characterized in that: The machine learning models include random forest and gradient boosting forest models.

5. The method for forecasting air quality according to claim 4, characterized in that: The model's air quality prediction range includes PM2.

5. 2.5 PM 10 CO and O3.