Air quality time sequence prediction method based on agent interaction and multi-dimensional feature fusion
Through the method of integrating agent interaction and multi-dimensional features, a neural network timing prediction model is constructed, which solves the problem that traditional models cannot capture the long-term dependence of air quality timing data, and achieves the efficiency and accuracy of air quality timing prediction, and manages urban environments Provides a reliable theoretical basis.
Patent Information
- Application Number
- CN202411250932.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional models cannot meet the needs of real-time monitoring and precise governance of air quality, and cannot effectively capture the long-term dependence and causality in the timing data of air quality, resulting in insufficient prediction accuracy.
Using a method based on the fusion of agent interaction and multi-dimensional feature, a neural network timing prediction model is constructed by obtaining multi-dimensional feature and air quality data, and using Gaussian convolution and self-attention encoder to capture timing dependencies, providing data collection, processing, An integrated service for model training and user query.
The accuracy and efficiency of air quality timing prediction have been improved, and the complex relationship between air quality and urban basic characteristics can be effectively captured, providing a reliable model theoretical basis for urban environmental governance.
Smart Images

Figure CN119129831A_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to the technical field of ambient air quality monitoring, and in particular to an air quality time series prediction method based on intelligent agent interaction and multi-dimensional feature fusion. [Background technology]
[0002] Air pollution is closely related to health problems such as respiratory and cardiovascular diseases. Predicting changes in air quality can provide a reference for governments and related organizations to issue warnings, take preventive measures, and optimize responses to pollution events. Therefore, the accuracy of air quality time series forecasts has a far-reaching impact on public health, environmental policies, and economic activities.
[0003] With the rapid development of big data and artificial intelligence technologies, deep learning models are able to process large-scale time series data containing complex nonlinear relationships and dependencies, which are often difficult to capture with traditional statistical models. In terms of air quality time series prediction, deep learning models can integrate a wide range of variables from meteorological data to traffic data to improve the accuracy and detail of predictions. Therefore, the application of deep learning for air quality prediction can effectively expand the capabilities of predictive analysis and provide a more solid foundation for the environmental health and safety regulatory decision-making process.
[0004] In terms of time series prediction, conventional methods include traditional statistical models (such as ARIMA) and traditional machine learning models (such as Xgboost), as well as deep learning models that are often used for time series prediction (such as recurrent neural networks (RNNs)). The above models cannot effectively capture long-term dependencies in time series. The transformer-related models based on the attention mechanism can effectively capture the complex time series dependencies under the joint action of features and labels due to their unique model architecture and the huge number of parameters supported by large data sets, and are more robust than the above traditional methods. However, the traditional transformer model can only be used to process sequence-to-sequence conversion, and its architecture does not meet the causality of time series data due to the interactivity of different tokens in the self-attention layer, and cannot achieve high-precision time series prediction of air quality.
[0005] In terms of intelligent application, the traditional human-led mode of processing data, model training and fine-tuning models is relatively inefficient and cannot meet the urgent needs of today's society for real-time monitoring and precise governance of air quality. In view of this, it is necessary to provide an air quality time series prediction method based on intelligent agent interaction and multi-dimensional feature fusion to overcome the above defects. [Summary of the invention]
[0006] The purpose of this invention is to provide an air quality time series prediction method based on intelligent agent interaction and multi-dimensional feature fusion, aiming to solve the problem that traditional models cannot meet the urgent needs of today's society for real-time monitoring and precise management of air quality, thereby providing an integrated service including data collection and processing, model training, user questions, query data and return results.
[0007] In order to achieve the above object, the present invention provides an air quality time series prediction method based on agent interaction and multi-dimensional feature fusion, comprising:
[0008] Step S10: acquiring multidimensional features of each grid within a specific time range and a specific area, and performing data fusion processing on the multidimensional features to generate multivariate feature data of the specific grid at a specific time point; wherein the multidimensional features include static features and dynamic features;
[0009] Step S20: obtaining air quality data of each grid within a specific time range and a specific area at a preset time, and performing data processing on the air quality data to obtain a valid label of the specific grid at a specific time point;
[0010] Step S30: constructing a neural network-based time series prediction model in a large model agent, and inputting the multivariate feature data and the valid labels into the time series prediction model for prediction training;
[0011] Step S40: receiving an air quality prediction instruction of a target grid at a predetermined future time sent by a user, and then querying to obtain multi-dimensional feature data and historical air quality data of the target grid;
[0012] Step S50: input the multi-dimensional feature data and historical air quality data of the target grid into the trained time series prediction model to obtain the air quality data of the target grid at a predetermined future time.
[0013] In a preferred embodiment, the step S10 includes:
[0014] Step S11: Fill in the missing values in the features of all grids within the specific time range and the specific area by linear interpolation;
[0015] Step S12: removing noise data from data of different monitoring stations at the same time and the same grid;
[0016] Step S13: Save the label of each pollutant and the maximum and minimum values of the data of each feature at all grids and all time stamps, and map all data of the corresponding feature to a standardized range of the interval [0,1] based on the extreme value information; wherein the label represents the air pollutant concentration value of each grid at a specific time stamp;
[0017] Step S14: Gaussian convolution operation is performed on the static features of the grid where the target feature is located and the neighboring grids within a predetermined range around it by a preset formula to absorb spatial information. The preset formula is:
[0018] Where I(i,j) is the original static feature information of the grid with coordinates (i,j), G is the preset weight matrix of Gaussian convolution, and I'(i,j) is the newly generated static feature;
[0019] Step S15: Encode the continuous dynamic features of the grid where the target feature is located at the target timestamp, and use the encoded features to replace the original dynamic features;
[0020] Step S16: splice the newly generated static feature I'(i,j) to the original static feature I(i,j), and then continue to splice it with the encoding feature to obtain the total feature vector of the target grid at the target timestamp, and perform dimensionality reduction processing on the total feature vector.
[0021] In a preferred embodiment, the step S14 includes:
[0022] The longitude and latitude distance between the grids is calculated according to the longitude and latitude coordinates of the grid where the target feature is located, and whether two grids are adjacent is determined by judging whether the longitude and latitude distance is less than or equal to a preset distance threshold.
[0023] In a preferred embodiment, the step S20 includes:
[0024] Step S21: removing noise data from data of different monitoring stations at the same time and in the same grid;
[0025] Step S22: Calculate the average value of the pollutant data of the remaining monitoring stations as the label data of the pollutant of the target grid at the target timestamp;
[0026] Step S23: removing isolated timestamp data and data without pollutant labels of the target grid;
[0027] Step S24: Save the maximum and minimum values of the same pollutant label data at all timestamps and all grid data, and based on the extreme value information, map the label data to the [0,1] interval for normalization processing.
[0028] In a preferred embodiment, in the step S12 or the step S21, it includes:
[0029] For the data from different monitoring stations in the same grid at the same time, the mean μ and standard deviation σ of all data points are calculated for each feature, and then all data points outside the interval [μ-3σ,μ+3σ] are removed. Then, the average of all data in the interval [μ-3σ,μ+3σ] is taken to represent the data of the current grid at the current time point.
[0030] In a preferred embodiment, the step S30 includes:
[0031] Step S31: the multivariate feature data of each grid is divided into a training set and a test set based on the time dimension, and then the training sets and test sets of all grids are merged to generate a total training set and a total test set;
[0032] Step S32: Set a time window for model training for each grid, and generate the input and output arrays of the model based on the total training set; wherein, set the model input array to [batch size, sequence length, feature dimension], and set the model output array to [batch size, number of dynamic features plus number of labels], the batch size is the number of input or output data in each batch, the sequence length is the set number of time windows, and the feature dimension is the number of dimensions of the total features of the batch size plus the sequence length; each output array contains all dynamic feature prediction values and all label prediction values of the next time window of the corresponding input;
[0033] Step S33: training a time series prediction model based on the input array and the output array, and using a preset loss function to tune model parameters during the training process until the loss function converges;
[0034] Step S34: Evaluate the time series prediction model trained in step S33 on the total test set based on preset model evaluation indicators, until the model evaluation indicators of the time series prediction model meet preset requirements.
[0035] In a preferred embodiment, the step S33 includes:
[0036] Step S331: Process the features of each piece of data through a fully connected layer and a nonlinear activation function LeakyRelu, wherein the LeakyRelu function is:
[0037] Step S332: the data outputted in step S331 is operated through n layers of self-attention layers by a self-attention encoder to capture temporal dependencies, thereby obtaining a latent space representation of the time series;
[0038] Step S333: For each dimension of the feature dimension, the representation of each position obtained within the time window is mapped to a 1-dimensional array through a trained linear fully connected layer and a nonlinear activation function LeakyRelu, that is, the last two dimensions of the original array [batch size, sequence length, feature dimension] are transposed and applied to the fully connected layer to obtain an output of [batch size, 1];
[0039] Step S334: For different dimensions of the model, a one-dimensional array is linearly mapped to it through a feedforward neural network and used as the predicted values of all dynamic features of the data. An array with a dimension of [batch size, number of dynamic features plus number of labels] is obtained as the output predicted value, and the loss function is calculated by comparing it with the true value, and then training is continued until the loss function has not decreased for n consecutive rounds.
[0040] In a preferred embodiment, in step S332, the operation mode of a self-attention layer includes:
[0041] For each element, a query vector, a key vector, and a value vector are calculated, where the three vectors are obtained by multiplying the original element with the parameter matrix;
[0042] Specifically, suppose the sequence X contains n elements, and the dimension of each element is d, then X is represented as an n×d matrix, and then the query matrix Q=X*Wq, the key matrix K=X*Wk and the value matrix V=X*Wv are calculated by multiplying the weight matrices Wq, Wk and Wv of size d×d. The three matrices correspond to the query vector, key vector and value vector of each element;
[0043] For each element in the sequence, calculate its attention score with all other elements by taking the dot product of the query vector of the element and the key vectors of the other elements, and dividing by a scaling factor, where the scaling factor is the square root of the dimension of the key vector.
[0044] Normalize the attention scores so that their sum is 1;
[0045] Calculate the weighted sum of each element. For each element in the sequence, multiply its value by the normalized attention scores of all other elements, and then add these products to get the weighted sum of the element:
[0046] Specifically, let X = {x1, x2, ..., x T} is the input sequence, Attention(Q,K) is the calculated normalized attention score matrix, Output is the output sequence of the self-attention layer, each element of which represents the weighted sum of the corresponding position, where,
[0047] In a preferred embodiment, the step S50 includes:
[0048] Step S51: Perform Gaussian kernel convolution on the multi-dimensional feature data to absorb surrounding grid information using a preset formula, wherein the preset formula is:
[0049] In the formula, I(i,j) represents the feature information of the grid with coordinates (i,j), and G represents the preset Gaussian convolution weight matrix;
[0050] Step S52: removing noise data from the static feature data, mapping the features to the interval [0,1] according to the saved extreme value information of each feature, and completing the scaling process of the feature value;
[0051] Step S53: input the scaled data into the time series prediction model, obtain the dynamic feature time series prediction results and pollutant label prediction results for the future predetermined period, and inversely scale the pollutant label prediction results by the corresponding label extreme values to obtain the actual prediction results;
[0052] Step S54: recursively iterate based on the prediction results of the future predetermined time period to generate dynamic feature time series prediction results and pollutant label prediction results for a longer time period in the future, until the prediction value results for the predetermined future time are obtained.
[0053] In a preferred embodiment, the method further comprises the steps of:
[0054] Collect data in real time, and store the processed data sets in the corresponding database by designing a reasonable table structure;
[0055] The time series prediction model is trained according to the latest data set, and the trained model is serialized and output and written into the knowledge base of the large model agent;
[0056] Obtaining the air quality prediction instruction issued by the user each time, and converting the natural language instruction into an SQL query statement, and then interacting with the database to query the multi-dimensional feature data of the corresponding grid and the formatted data of historical air quality, so as to input into the subsequent time series prediction model;
[0057] Calling the time series prediction model in the knowledge base, writing the time series prediction code according to the user's needs, returning the prediction result to the user, and storing the conversation content in the internal memory cache;
[0058] Collect the latest data in real time, connect to the database to automatically update the data, and retrain and optimize the time series prediction model stored in the knowledge base based on the real-time updated data.
[0059] The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion provided by the present invention can provide integrated services including data collection and processing, model training, user questions, query data and return results, thereby using grid multi-source big data and deep learning models to explore the complex relationship between air quality and urban basic characteristics and time series dependence, and can accurately and reliably infer and predict future atmospheric pollution and air quality conditions, solving the problem that existing methods cannot effectively combine time series and basic characteristics to model and capture their complex interactive relationships, and provide a reliable model theoretical basis for urban environmental governance. Compared with the traditional model, this intelligent solution has significant advantages such as high efficiency, friendly interaction, and flexible application.
Brief Description of the Drawings
[0060] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0061] Figure 1 A flow chart of the air quality time series prediction method based on agent interaction and multi-dimensional feature fusion provided by the present invention;
[0062] Figure 2 A schematic diagram of the structure of the time series prediction model provided by the present invention;
[0063] Figure 3 A schematic diagram of a workflow providing a one-stop service for the present invention.
[0064] Figure 4 It is a schematic diagram of the workflow of the method for fusing air quality time series prediction by combining a large model intelligent agent with gridded multi-dimensional spatiotemporal features of the present invention;
[0065] Figure 5 A framework diagram of the air quality time series prediction device based on agent interaction and multi-dimensional feature fusion provided by the present invention. [Specific implementation method]
[0066] In order to make the purpose, technical solution and beneficial technical effect of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. It should be understood that the specific implementation methods described in this specification are only for explaining the present invention, not for limiting the present invention.
[0067] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0068] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0069] Embodiment 1
[0070] In an embodiment of the present invention, a method for air quality time series prediction based on agent interaction and multi-dimensional feature fusion is provided, which mainly includes the steps of multi-feature collection and processing, grid unit air quality data acquisition, prediction model training, label prediction of unknown units in the future, etc. It is used to combine gridded multi-source big data and deep learning models, and can effectively explore the complex relationship between air quality and related basic characteristics and time series dependence.
[0071] Before describing the steps of the method in detail, some terms that may be involved need to be explained to facilitate understanding of the technical solution.
[0072] Grid: represents the spatial grid, which is a square area formed by gridding the preset area (such as 1km×1km);
[0073] Timestamp: It is the time interval after time is discretized (the length of a timestamp is one time series unit);
[0074] Cell: represents the state of a grid at a specific time stamp. The characteristics and air pollutant concentration values of each cell are fixed values.
[0075] Features: It is a formatted expression of the state of each unit. In this method, features are divided into static features and dynamic features, among which static features are divided into basic features and time features. Basic features include: longitude and latitude, altitude, temperature and humidity, green area, etc.; time features include: year, month, date, day of the week, etc. Taking into account the periodicity of time series, the time characteristics of static features will have a significant impact on the concentration value of air pollutants; and dynamic features refer to features that change over time (for example, the longitude and latitude of a grid are static features, because the longitude and latitude are fixed and will not change over time; and the temperature of the grid is a dynamic feature, because the temperature changes dynamically at any time).
[0076] Label: Indicates the air pollutant concentration value of each unit (such as PM2.5, PM10, CO, O3, SO2, NO2).
[0077] like Figure 1 As shown, the air quality time series prediction method based on agent interaction and multi-dimensional feature fusion includes steps S10-S50.
[0078] Step S10: Acquire multidimensional features of each grid within a specific time range and a specific area, and perform data fusion processing on the multidimensional features to generate multivariate feature data of the specific grid at a specific time point; wherein the multidimensional features include static features and dynamic features.
[0079] Specifically, step S10 includes steps S11-S16.
[0080] Step S11: fill in the missing values in the features of all grids within the specific time range and the specific area by linear interpolation.
[0081] Step S12: Remove noise data from data from different monitoring stations at the same time and in the same grid.
[0082] Among them, for the data of different monitoring stations in the same grid at the same time, the mean μ and standard deviation σ of all data points are calculated for each feature, and then all data points outside the interval [μ-3σ,μ+3σ] are removed, and then the average of all data in the interval [μ-3σ,μ+3σ] is taken to represent the data of the current grid at the current time point.
[0083] Step S13: Save the labels of each pollutant and the maximum and minimum values of the data of each feature on all grids and all timestamps, and based on the extreme value information, map all data of the corresponding feature to a standardized range of the interval [0,1] to prevent model instability caused by different dimensions between features.
[0084] Step S14: Gaussian convolution operation is performed on the static features of the grid where the target feature is located and the neighboring grids within a predetermined range around it by a preset formula to absorb spatial information. The preset formula is:
[0085] In the formula, I(i,j) is the original static feature information of the grid with coordinates (i,j), G is the preset Gaussian convolution weight matrix, and I'(i,j) is the newly generated static feature.
[0086] Furthermore, the longitude and latitude distance between grids may be calculated based on the longitude and latitude coordinates of the grid where the target feature is located, and whether two grids are adjacent may be determined by judging whether the longitude and latitude distance is less than or equal to a preset distance threshold.
[0087] Step S15: Encode the continuous dynamic features of the grid where the target feature is located at the target timestamp, and use the encoded features to replace the original dynamic features, thereby discretizing the dynamic features.
[0088] Step S16: After the newly generated static feature I'(i, j) is spliced to the original static feature I(i, j), it is then spliced with the dynamic coding feature to obtain the total feature vector of the target grid at the target timestamp, and the total feature vector is subjected to dimensionality reduction processing. For example, the static feature is mapped to a lower dimensional space through the PCA (Principal Component Analysis) dimensionality reduction algorithm to reduce data noise.
[0089] Step S20: Acquire the air quality data of each grid within a specific time range and a specific area at a preset time, and process the air quality data to obtain a valid label of the specific grid at a specific time point.
[0090] Specifically, step S20 includes steps S21-S24.
[0091] Step S21: remove noise data from data of different monitoring stations at the same time and in the same grid.
[0092] Among them, for the data of different monitoring stations in the same grid at the same time, the mean μ and standard deviation σ of all data points are calculated for each feature, and then all data points outside the interval [μ-3σ,μ+3σ] are removed, and then the average of all data in the interval [μ-3σ,μ+3σ] is taken to represent the data of the current grid at the current time point.
[0093] Step S22: Calculate the average value of the pollutant data of the remaining monitoring stations as the label data of this type of pollutant for the target grid at the target timestamp, so as to facilitate the screening of continuous data with both features and labels and a time window of a certain length in subsequent steps.
[0094] Step S23: removing isolated timestamp data and data without pollutant labels of the target grid;
[0095] Step S24: Save the maximum and minimum values of the same pollutant label data at all timestamps and all grid data, and based on the extreme value information, map the label data to the [0,1] interval for normalization processing.
[0096] Step S30: construct a neural network-based time series prediction model in the large model agent, and input the multivariate feature data and valid labels into the time series prediction model for prediction training.
[0097] like Figure 2As shown, it is a structural diagram of a time series prediction model based on a neural network. During the training process, step S30 includes steps S31-S34.
[0098] Step S31: The multivariate feature data of each grid is divided into a training set and a test set based on the time dimension, and then the training sets and test sets of all grids are merged to generate a total training set and a total test set.
[0099] For example, for each grid, the first 80% of the feature-label data in the time dimension is added to the training set, and the last 20% of the feature-label data is added to the test set.
[0100] Step S32: Set a time window for model training for each grid, and generate input and output arrays of the model based on the total training set; wherein, the model input array is set to [batch size, sequence length, feature dimension], and the model output array is set to [batch size, number of dynamic features plus number of labels], the batch size is the number of input or output data in each batch, the sequence length is the set number of time windows, and the feature dimension is the number of dimensions of the total features of the batch size plus the sequence length; each output array contains all dynamic feature prediction values and all label prediction values of the next time window of the corresponding input.
[0101] In this embodiment, the time window may be selected as 15, that is, the feature-label data of the first 15 time series units (eg, hours / days) of a certain grid is used as the total feature for predicting the label value of the next time series unit.
[0102] Step S33: training a time series prediction model based on the input array and the output array, and using a preset loss function to tune the model parameters during the training process until the loss function converges.
[0103] In this embodiment, the tuning process selects MSE (mean square error) as the loss function of the model, substitutes the output value of the model into the loss function to obtain the loss value of the sample, and performs back propagation training based on the loss value. The goal of back propagation training is to minimize the loss value (make the output value of the model and the true value as close as possible). Among them, the back propagation operation uses the chain rule to obtain the gradient value of each parameter of the model, and uses the gradient descent algorithm to optimize the model parameters.
[0104] Step S34: Evaluate the time series prediction model trained in step S33 on the total test set based on preset model evaluation indicators until the model evaluation indicators of the time series prediction model meet preset requirements.
[0105] In this embodiment, RMSE, SMAPE, MAE, R 2 As the model evaluation indicator on the test set, the calculation method of the above evaluation indicator is:
[0106] Among them, y i is the true value, is the predicted value, n is the number of samples;
[0107] Among them, y i is the true value, is the predicted value, n is the number of samples;
[0108] Among them, y i is the true value, is the predicted value, n is the number of samples;
[0109] Among them, y is the true value, y Λ is the predicted value and y is the mean of the true values.
[0110] Combination Figure 2 As shown, step S33 includes steps S331-334.
[0111] Step S331: Process the features of each piece of data through a fully connected layer and a nonlinear activation function LeakyRelu, where the LeakyRelu function is:
[0112] In this embodiment, the dimension of the input data after being processed by the LeakyRelu function changes from [batch size, sequence length, feature dimension] to [batch size, sequence length, 128].
[0113] Step S332: The data output from step S331 is operated through n layers of self-attention layers through a self-attention encoder to capture temporal dependencies, thereby obtaining a latent space representation of the time series.
[0114] Among them, the operation mode of a certain self-attention layer includes:
[0115] (1) Calculation of query, key and value: Calculate the query vector, key vector and value vector for each element, where the three vectors are obtained by multiplying the original element with the parameter matrix. Specifically, assume that the sequence X contains n elements, and the dimension of each element is d, then X is represented as an n×d matrix, and then the query matrix Q=X*Wq, key matrix K=X*Wk and value matrix V=X*Wv are calculated by multiplying the weight matrices Wq, Wk and Wv of size d×d. The three matrices correspond to the query vector, key vector and value vector of each element;
[0116] (2) Calculation of attention score: For each element in the sequence, calculate its attention score with all other elements. The calculation method is: dot product the query vector of the element with the key vectors of other elements, and then divide it by a scaling factor to obtain the attention score, where the scaling factor is the square root of the key vector dimension. When calculating the attention score, a parallel multi-head attention mechanism is used, so that multiple features in the data can be captured and spliced together. In this embodiment, the number of attention heads is set to 4.
[0117] (3) Normalization of attention scores: The attention scores are normalized so that their sum is 1.
[0118] (4) Calculate the weighted sum of each element. For each element in the sequence, multiply its value by the normalized attention scores of all other elements, and then add these products to obtain the weighted sum of the element. Specifically, set X = {x1, x2, ..., x T} is the input sequence, Attention(Q,K) is the calculated normalized attention score matrix, Output is the output sequence of the self-attention layer, each element of which represents the weighted sum of the corresponding position, where,
[0119] Step S333: For each dimension of the feature dimension, the representation of each position obtained within the time window is mapped to a 1-dimensional array through a trained linear fully connected layer and a nonlinear activation function LeakyRelu, that is, the last two dimensions of the original array [batch size, sequence length, feature dimension] are transposed and applied to the fully connected layer to obtain an output of [batch size, 1]. In this embodiment, the last two dimensions of the original array [batch size, sequence length, 128] are transposed and applied to the fully connected layer to obtain an output of [batch size, 1].
[0120] Step S334: Deep neural network decoder: For different dimensions of the model, a feedforward neural network (multi-layer perceptron) is used to linearly map them to a one-dimensional array, and use them as the predicted values of all dynamic features of the data. An array with a dimension of [batch size, number of dynamic features plus number of labels] is obtained as the output predicted value, and the loss function is calculated by comparing it with the true value. Then, training continues until the loss function does not decrease for n consecutive rounds, and the model training process stops.
[0121] Step S40: receiving an air quality prediction instruction for a target grid at a predetermined future time sent by a user, and then querying to obtain multi-dimensional feature data and historical air quality data of the target grid.
[0122] Step S50: input the multi-dimensional feature data and historical air quality data of the target grid into the trained time series prediction model to obtain the air quality data of the target grid at a predetermined future time.
[0123] Specifically, step S50 includes steps S51-54.
[0124] Step S51: Perform Gaussian kernel convolution on the multi-dimensional feature data to absorb surrounding grid information using a preset formula. The preset formula is:
[0125] In the formula, I(i,j) represents the feature information of the grid with coordinates (i,j), and G represents the preset Gaussian convolution weight matrix.
[0126] Step S52: remove noise data from the static feature data, map the features to the interval [0,1] according to the saved extreme value information of each feature, and complete the feature value scaling process.
[0127] Step S53: Input the scaled data into the time series prediction model to obtain the dynamic feature time series prediction results and pollutant label prediction results for a predetermined period in the future (e.g., the next day), and inversely scale the pollutant label prediction results by the corresponding label extreme values to obtain the actual prediction results.
[0128] Step S54: Perform recursive iteration based on the prediction results of a predetermined future time period (e.g., the next day), and generate dynamic feature time series prediction results and pollutant label prediction results for a longer time period in the future according to the above steps until the prediction value results for a predetermined future time (e.g., multiple days in the future) are obtained.
[0129] It should be noted that the above steps only belong to the "time series prediction" link in the workflow of the large model agent. Prior to this, the large model agent used crawler technology to collect air quality index data from the meteorological website in real time, and used multi-source heterogeneous data perception fusion algorithm to update the large model agent database and the time series prediction model in the large model agent knowledge base in real time. Figure 3 and Figure 4 As shown, the specific steps are as follows:
[0130] Step S61: collect data in real time, process the data using the above-disclosed multi-source heterogeneous data perception fusion algorithm to form a high-quality unified data set, and store the data set after data fusion processing in a corresponding database by designing a reasonable table structure;
[0131] Step S62: training the time series prediction model according to the latest data set, and serializing and outputting the trained model and writing it into the knowledge base of the large model agent;
[0132] Step S63: Obtain the air quality prediction instruction issued by the user each time, and convert the natural language instruction into an SQL query statement, and then interact with the database to query the multi-dimensional feature data of the corresponding grid and the formatted data of the historical air quality, so as to input the subsequent time series prediction model;
[0133] Step S64: calling the time series prediction model in the knowledge base, writing the time series prediction code according to the user's needs, returning the prediction result to the user, and storing the conversation content in the internal memory cache;
[0134] Step S65: Collect the latest data in real time, connect to the database to automatically update the data, and retrain and optimize the time series prediction model stored in the knowledge base based on the real-time updated data to achieve true real-time intelligent air quality monitoring and prediction.
[0135] Embodiment 2
[0136] The second aspect of the present invention provides an air quality time series prediction device 100 based on agent interaction and multi-dimensional feature fusion, which is used to combine gridded multi-source big data and deep learning models, and can effectively mine the complex relationship between air quality and related basic features and time series dependencies. It should be noted that the implementation principle and specific implementation method of the air quality time series prediction device 100 based on agent interaction and multi-dimensional feature fusion can refer to the above-mentioned air quality time series prediction method based on agent interaction and multi-dimensional feature fusion, so it will not be repeated below.
[0137] like Figure 5 As shown, the air quality time series prediction device 100 based on agent interaction and multi-dimensional feature fusion includes:
[0138] The multi-dimensional feature acquisition module 10 is used to acquire the multi-dimensional features of each grid within a specific time range and a specific area, and perform data fusion processing on the multi-dimensional features to generate multivariate feature data of a specific grid at a specific time point; wherein the multi-dimensional features include static features and dynamic features;
[0139] The air quality data acquisition module 20 is used to acquire the air quality data of each grid within a specific time range and a specific area at a preset time, and perform data processing on the air quality data to obtain a valid label of a specific grid at a specific time point;
[0140] A time series prediction model training module 30 is used to construct a neural network-based time series prediction model in a large model agent, and input the multivariate feature data and the valid labels into the time series prediction model for prediction training;
[0141] The quality prediction instruction receiving module 40 is used to receive the air quality prediction instruction of the target grid at a predetermined future time sent by the user, and then query to obtain the multi-dimensional feature data and historical air quality data of the target grid;
[0142] The prediction result data output module 50 is used to input the multi-dimensional feature data and historical air quality data of the target grid into the trained time series prediction model to obtain the air quality data of the target grid at a predetermined future time.
[0143] Embodiment 3
[0144] The present invention provides a terminal, which includes a memory, a processor, and a computer program stored in the memory. When the computer program is executed by the processor, the various steps of the air quality time series prediction method based on intelligent agent interaction and multi-dimensional feature fusion as described in any one of the above-mentioned implementation modes are implemented.
[0145] Embodiment 4
[0146] The present invention provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the various steps of the air quality time series prediction method based on intelligent agent interaction and multi-dimensional feature fusion as described in any of the above-mentioned implementation modes.
[0147] Embodiment 5
[0148] The present invention provides a computer program product, including a computer program or instructions, which, when processed and executed, implement the various steps of the air quality time series prediction method based on intelligent agent interaction and multi-dimensional feature fusion as described in any of the above-mentioned implementation modes.
[0149] In summary, the air quality time series prediction method based on agent interaction and multi-dimensional feature fusion provided by the present invention, and the time series prediction method based on large model agent technology can provide integrated services including data collection and processing, model training, user questions, query data and return results, thereby utilizing grid multi-source big data and deep learning models to mine the complex relationship between air quality and urban basic characteristics and time series dependencies, and can accurately and reliably infer and predict future atmospheric pollution and air quality conditions, solving the problem that existing methods cannot effectively combine time series and basic characteristics for modeling and capture their complex interactive relationships, and providing a reliable model theoretical basis for urban environmental governance. Compared with traditional models, this intelligent solution has significant advantages such as high efficiency, friendly interaction, and flexible application.
[0150] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0151] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0152] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0153] In the embodiments provided by the present invention, it should be understood that the disclosed systems or devices / terminal equipment and methods can be implemented in other ways. For example, the system or device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the system or unit can be electrical, mechanical or other forms.
[0154] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0155] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0156] The present invention is not limited to what is described in the specification and implementation modes, and therefore additional advantages and modifications can be easily realized by those skilled in the art. Therefore, without departing from the spirit and scope of the general concept defined by the claims and their equivalents, the present invention is not limited to the specific details, representative devices, and illustrative examples shown and described herein.
Claims
1. A method for air quality time series prediction based on agent interaction and multi-dimensional feature fusion, It is characterized in that include: Step S10: acquiring multidimensional features of each grid within a specific time range and a specific area, and performing data fusion processing on the multidimensional features to generate multivariate feature data of the specific grid at a specific time point; wherein the multidimensional features include static features and dynamic features; Step S20: obtaining air quality data of each grid within a specific time range and a specific area at a preset time, and performing data processing on the air quality data to obtain a valid label of the specific grid at a specific time point; Step S30: constructing a neural network-based time series prediction model in a large model agent, and inputting the multivariate feature data and the valid labels into the time series prediction model for prediction training; Step S40: receiving an air quality prediction instruction of a target grid at a predetermined future time sent by a user, and then querying to obtain multi-dimensional feature data and historical air quality data of the target grid; Step S50: input the multi-dimensional feature data and historical air quality data of the target grid into the trained time series prediction model to obtain the air quality data of the target grid at a predetermined future time.
2. The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion as claimed in claim 1, It is characterized in that The step S10 comprises: Step S11: Fill in the missing values in the features of all grids within the specific time range and the specific area by linear interpolation; Step S12: removing noise data from data of different monitoring stations at the same time and the same grid; Step S13: Save the label of each pollutant and the maximum and minimum values of the data of each feature at all grids and all time stamps, and map all data of the corresponding feature to a standardized range of the interval [0,1] based on the extreme value information; wherein the label represents the air pollutant concentration value of each grid at a specific time stamp; Step S14: Gaussian convolution operation is performed on the static features of the grid where the target feature is located and the neighboring grids within a predetermined range around it by a preset formula to absorb spatial information. The preset formula is: Where I(i,j) is the original static feature information of the grid with coordinates (i,j), G is the preset weight matrix of Gaussian convolution, and I'(i,j) is the newly generated static feature; Step S15: Encode the continuous dynamic features of the grid where the target feature is located at the target timestamp, and use the encoded features to replace the original dynamic features; Step S16: splice the newly generated static feature I'(i,j) to the original static feature I(i,j), and then continue to splice it with the encoding feature to obtain the total feature vector of the target grid at the target timestamp, and perform dimensionality reduction processing on the total feature vector.
3. The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion as claimed in claim 2, It is characterized in that The step S14 comprises: The longitude and latitude distance between the grids is calculated according to the longitude and latitude coordinates of the grid where the target feature is located, and whether two grids are adjacent is determined by judging whether the longitude and latitude distance is less than or equal to a preset distance threshold.
4. The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion as claimed in claim 1, It is characterized in that The step S20 comprises: Step S21: removing noise data from data of different monitoring stations at the same time and in the same grid; Step S22: Calculate the average value of the pollutant data of the remaining monitoring stations as the label data of the pollutant of the target grid at the target timestamp; Step S23: removing isolated timestamp data and data without pollutant labels of the target grid; Step S24: Save the maximum and minimum values of the same pollutant label data at all timestamps and all grid data, and based on the extreme value information, map the label data to the [0,1] interval for normalization processing.
5. The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion as claimed in claim 2 or 4, It is characterized in that In the step S12 or the step S21, it includes: For the data from different monitoring stations in the same grid at the same time, the mean μ and standard deviation σ of all data points are calculated for each feature, and then all data points outside the interval [μ-3σ,μ+3σ] are removed. Then, the average of all data in the interval [μ-3σ,μ+3σ] is taken to represent the data of the current grid at the current time point.
6. The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion as claimed in claim 2, It is characterized in that The step S30 comprises: Step S31: the multivariate feature data of each grid is divided into a training set and a test set based on the time dimension, and then the training sets and test sets of all grids are merged to generate a total training set and a total test set; Step S32: Set a time window for model training for each grid, and generate the input and output arrays of the model based on the total training set; wherein, set the model input array to [batch size, sequence length, feature dimension], and set the model output array to [batch size, number of dynamic features plus number of labels], the batch size is the number of input or output data in each batch, the sequence length is the set number of time windows, and the feature dimension is the number of dimensions of the total features of the batch size plus the sequence length; each output array contains all dynamic feature prediction values and all label prediction values of the next time window of the corresponding input; Step S33: training a time series prediction model based on the input array and the output array, and using a preset loss function to tune model parameters during the training process until the loss function converges; Step S34: Evaluate the time series prediction model trained in step S33 on the total test set based on preset model evaluation indicators, until the model evaluation indicators of the time series prediction model meet preset requirements.
7. The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion as claimed in claim 6, It is characterized in that The step S33 comprises: Step S331: Process the features of each piece of data through a fully connected layer and a nonlinear activation function LeakyRelu, wherein the LeakyRelu function is: Step S332: the data outputted in step S331 is operated through n layers of self-attention layers by a self-attention encoder to capture temporal dependencies, thereby obtaining a latent space representation of the time series; Step S333: For each dimension of the feature dimension, the representation of each position obtained within the time window is mapped to a 1-dimensional array through a trained linear fully connected layer and a nonlinear activation function LeakyRelu, that is, the last two dimensions of the original array [batch size, sequence length, feature dimension] are transposed and applied to the fully connected layer to obtain an output of [batch size, 1]; Step S334: For different dimensions of the model, a one-dimensional array is linearly mapped to it through a feedforward neural network and used as the predicted values of all dynamic features of the data. An array with a dimension of [batch size, number of dynamic features plus number of labels] is obtained as the output predicted value, and the loss function is calculated by comparing it with the true value, and then training is continued until the loss function has not decreased for n consecutive rounds.
8. The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion as claimed in claim 7, It is characterized in that In step S332, the operation of a self-attention layer includes: For each element, a query vector, a key vector, and a value vector are calculated, where the three vectors are obtained by multiplying the original element with the parameter matrix; Specifically, suppose the sequence X contains n elements, and the dimension of each element is d, then X is represented as an n×d matrix, and then the query matrix Q=X*Wq, the key matrix K=X*Wk and the value matrix V=X*Wv are calculated by multiplying the weight matrices Wq, Wk and Wv of size d×d. The three matrices correspond to the query vector, key vector and value vector of each element; For each element in the sequence, calculate its attention score with all other elements by taking the dot product of the query vector of the element and the key vectors of the other elements, and dividing by a scaling factor, where the scaling factor is the square root of the dimension of the key vector. Normalize the attention scores so that their sum is 1; Calculate the weighted sum of each element. For each element in the sequence, multiply its value by the normalized attention scores of all other elements, and then add these products to get the weighted sum of the element: Specifically, set X = {x 1 ,x 2 ,...,x T } is the input sequence, Attention(Q,K) is the calculated normalized attention score matrix, Output is the output sequence of the self-attention layer, each element of which represents the weighted sum of the corresponding position, where, 9. The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion as claimed in claim 2, It is characterized in that The step S50 comprises: Step S51: Perform Gaussian kernel convolution on the multi-dimensional feature data to absorb surrounding grid information using a preset formula, wherein the preset formula is: In the formula, I(i,j) represents the feature information of the grid with coordinates (i,j), and G represents the preset Gaussian convolution weight matrix; Step S52: removing noise data from the static feature data, mapping the features to the interval [0,1] according to the saved extreme value information of each feature, and completing the scaling process of the feature value; Step S53: input the scaled data into the time series prediction model, obtain the dynamic feature time series prediction results and pollutant label prediction results for the future predetermined period, and inversely scale the pollutant label prediction results by the corresponding label extreme values to obtain the actual prediction results; Step S54: recursively iterate based on the prediction results of the future predetermined time period to generate dynamic feature time series prediction results and pollutant label prediction results for a longer time period in the future, until the prediction value results for the predetermined future time are obtained.
10. The air quality time series prediction method based on agent interaction and multi-dimensional feature fusion as claimed in claim 1, It is characterized in that Also includes the steps: Collect data in real time, and store the processed data sets in the corresponding database by designing a reasonable table structure; The time series prediction model is trained according to the latest data set, and the trained model is serialized and output and written into the knowledge base of the large model agent; Obtaining the air quality prediction instruction issued by the user each time, and converting the natural language instruction into an SQL query statement, and then interacting with the database to query the multi-dimensional feature data of the corresponding grid and the formatted data of historical air quality, so as to input into the subsequent time series prediction model; Calling the time series prediction model in the knowledge base, writing the time series prediction code according to the user's needs, returning the prediction result to the user, and storing the conversation content in the internal memory cache; Collect the latest data in real time, connect to the database to automatically update the data, and retrain and optimize the time series prediction model stored in the knowledge base based on the real-time updated data.
Citation Information
Patent Citations
High-precision gridding air quality inference method and system, terminal equipment and storage medium
CN111461423A
Air quality inference method, terminal and storage medium
CN117909931A
Cited By
Intelligent heat supply load prediction method and system based on big data
CN122548655A
