River channel monitoring section water quality prediction method based on STL decomposition and attention mechanism

Through deep learning methods of STL decomposition and attention mechanism, water quality data is decomposed into trend, period and residual terms, and combined with LSTM, NeuralProphet and XGBoost algorithms, the problem of inaccurate water quality prediction in the existing technology is solved, and the more Accurate water quality prediction and model interpretability of river channel monitoring sections.

CN119090114APending Publication Date: 2024-12-06INNOVATION CENTER OF YANGTZE RIVER DELTA ZHEJIANG UNIVERSITY
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410976601.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-20
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

Existing water quality prediction methods are difficult to accurately capture the complex and changeable water quality evolution mechanism of rivers, and common data decomposition methods decompose the original data into subsequences with no actual physical significance, ignoring the impact of spatial information on water quality prediction, resulting in inaccurate prediction results. .

Method used

STL decomposition is used to decompose water quality data into trend terms, periodic terms and residual terms, and combine the deep learning model of attention mechanism, and use LSTM, NeuralProphet and XGBoost algorithms to predict, enhance the ability to capture space-time information, and establish an integrated deep learning model to Improve prediction accuracy.

Benefits of technology

Through the STL decomposition and attention mechanism method, the water quality changes in the river monitoring section can be more accurately predicted, effectively suppressing the cumulative error of the long-term step model, and improving the accuracy of water quality prediction and the interpretability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119090114A_ABST
    Figure CN119090114A_ABST
Patent Text Reader

Abstract

The invention relates to the field of monitoring section water quality prediction in river channel water quality management, in particular to a river channel monitoring section water quality prediction method based on STL decomposition and an attention mechanism, and the method comprises the following steps: 1, decomposing original water quality data into trend terms, periodicity and residual terms with practical significance by using STL decomposition; and secondly, an attention mechanism is introduced to enhance the capturing capability of the deep learning model on spatio-temporal information. According to the method, the accuracy of water quality prediction is improved while it is guaranteed that the trend and the period condition of water quality change can be obtained through all items subjected to data decomposition, and the accumulative error phenomenon in long-time step model prediction is effectively restrained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of water quality prediction of monitoring sections in river water quality management, and in particular to a water quality prediction method for river monitoring sections based on STL decomposition and attention mechanism. By performing targeted predictions on trend items, periodic items and residual items of water quality changes respectively, the time series changes of key water quality indicators of the river monitoring section in future time periods can be more accurately predicted. Background Art

[0002] With the development of the global economy and the rapid growth of the population, fresh water and clean water are becoming increasingly scarce, and the management and protection of water resources are becoming increasingly important. In the practice of river water quality management, the prevention and control of water pollution often lack foresight due to the lack of in-depth insight into the future trends of key water quality indicators. If the dynamic changes of these key indicators in the future can be predicted more accurately, potential pollution incidents can be warned, thereby strengthening proactive management and prevention measures, which is crucial to maintaining and improving the quality of the water environment.

[0003] However, the current water quality mechanism model is difficult to accurately capture the complex and changeable water quality evolution mechanism of rivers. Data-driven machine learning or deep learning technology can effectively capture the complex nonlinear changes of water quality parameters. At the same time, with the rapid development of Internet of Things technology, the improvement of water quality monitoring data collection efficiency has greatly increased the amount of data. Deep learning technology has become mainstream and widely used in water environment management. In order to reduce the complexity of water quality data and improve predictability, data decomposition methods are widely used in water quality prediction. The use of spatiotemporal information from multiple sites can enhance the accuracy of model prediction. However, there are still the following shortcomings:

[0004] 1. Currently, most commonly used data decomposition preprocessing methods decompose the original data into multiple subsequences without actual physical meaning, which lacks practicality;

[0005] 2. Most data-driven models focus on the use of temporal information and ignore the impact of spatial information on water quality prediction, especially its inhibitory effect on the cumulative error of time series prediction.

[0006] Therefore, it is necessary to propose a deep learning method for water quality prediction based on data decomposition, which can divide the original data into subsequences with actual physical meanings, and thereby more accurately predict the changes in water quality of river monitoring sections. This is of great significance for changing water quality management strategies from "ex post control" to "ex ante prevention" and improving the surface water environment. Summary of the invention

[0007] The present invention provides a water quality prediction method for a river monitoring section based on STL decomposition and attention mechanism. The method uses STL decomposition to decompose the original water quality data into trend terms, periodicity and residual terms with practical significance. Secondly, the attention mechanism is introduced to enhance the ability of the deep learning model to capture spatiotemporal information, thereby improving the accuracy of the prediction results of key water quality indicators.

[0008] A water quality prediction method for a river monitoring section based on STL decomposition and attention mechanism includes the following steps:

[0009] (1) Automatic water quality monitoring stations are arranged at each monitoring section of the river to monitor and record historical water quality data and meteorological data, sort them by time series, and perform preprocessing to construct a sequence format data set;

[0010] (2) Decomposing the original water quality data to be predicted using the STL method (trend decomposition method) on the original data set in the sequence format constructed in step (1), thereby obtaining trend terms, period terms and residual terms;

[0011] (3) The trend term, period term and residual term data obtained in step (2) are used to build prediction models using LSTM, NeuralProphet and XGBoost algorithms based on the attention mechanism, respectively, and an integrated deep learning model based on the attention mechanism (deep learning model Attention-based LSTM) is established for prediction, and the trend, periodicity and residual of the target water quality parameters are predicted at different time steps;

[0012] (4) combining the trend, periodicity and residual prediction results of the target water quality parameters obtained in step (3) to predict the time series changes of the target water quality parameters;

[0013] Furthermore, the method also includes step (5): utilizing the integrated deep learning model based on the attention mechanism established in step (3), and utilizing SHAP analysis to perform interpretability analysis on the model to improve the applicability of the model.

[0014] Furthermore, in step (1), automatic water quality monitoring stations are arranged at each monitoring section of the river to monitor and record historical water quality data and meteorological data, sort them by time series, and perform preprocessing to construct a sequence format data set, including:

[0015] The required water quality parameter data is obtained, and the IQR (InterQuartile Range) method is used to remove outliers in the data, and linear interpolation is used to fill in missing values ​​to complete the preprocessing operation.

[0016] Furthermore, in step (2), the predicted original water quality data is decomposed by the STL method (trend decomposition method) to obtain trend terms, periodic terms and residual terms. The specific decomposition formula is:

[0017] Y t =T t +S t +R t

[0018] Where Y t represents the original monitoring water quality data of the site to be predicted; T t represents the trend term after decomposition using the STL algorithm; S t represents the periodic term after decomposition using the STL algorithm; R t Represents the residual term after decomposition using the STL algorithm;

[0019] Furthermore, in step (3), prediction models are built using LSTM, NeuralProphet and XGBoost algorithms based on the attention mechanism, respectively, to predict the trend, periodicity and residual of the target water quality parameters at different time steps, specifically including:

[0020] The LSTM algorithm based on the attention mechanism is used to predict the trend item, the NeuralProphet algorithm is used to predict the period item, and the XGBoost algorithm is used to predict the residual item. The input of each model is the data of the water quality parameter to be predicted n moments ago (including the site to be predicted and other sites in the study area) and the data of the meteorological parameter n moments ago. The specific formula is:

[0021]

[0022] In the formula, It represents the predicted value of water quality index at time t+1, the superscript m represents the monitoring site, the subscript n represents the time, X represents the meteorological parameter, the superscript k represents the number of meteorological parameters, and the subscript n represents the time.

[0023] The different time steps include 1 hour, 2 hours, 12 hours and 24 hours.

[0024] Furthermore, the LSTM algorithm based on the attention mechanism in step (3) uses temporal attention and spatial attention. Specifically, the weight value h of temporal attention is j The calculation formula is:

[0025]

[0026] In the formula, v d ,b d ∈R m ,W d ∈Rm×2p and U d ∈R m×m are all parameters that the model needs to learn, p is the number of hidden states in temporal attention, σ c refers to the hyperbolic tangent function, σ z refers to the softmax function, and are the hidden state and unit state of the previous LSTM hidden layer in temporal attention, and These are all intermediate learning parameters.

[0027] The spatial attention used in this study can dynamically learn the spatial correlation between external factors to predict water quality indicators. This module describes the influence of external attributes through attention weights, whose sum is equal to 1. It does not ignore the influence of any external attributes, nor does it allow low-correlation external attributes to distort the results of water quality parameter prediction. Since spatial correlation is represented by assigning attention weights to original attributes through the spatial attention mechanism, and temporal relations are represented by assigning attention weights to hidden states of spatial attention through the temporal attention mechanism, we can learn joint spatiotemporal relations by learning spatial correlation and temporal correlation simultaneously. Specifically, the weight value h′ of spatiotemporal attention is j The calculation formula is:

[0028]

[0029] In the formula, v′ d ,b′ d ∈R m+n ,W′ d ∈R (m+n)×2q and U′ d ∈R m×m are all parameters that the model needs to learn, q is the number of hidden states in spatiotemporal attention, σ c refers to the hyperbolic tangent function, σ z refers to the softmax function, and are the hidden state and unit state of the previous LSTM hidden layer in spatiotemporal attention, and are all intermediate learning parameters, A concatenated vector representing simultaneous joint spatiotemporal relations.

[0030] Furthermore, in step (5), the integrated deep learning model based on the attention mechanism established in step (3) is used to perform interpretability analysis on the model using SHAP analysis to improve the applicability of the model, specifically including:

[0031] By calculating the SHAP value, we can obtain the importance ranking of the model input features and evaluate the impact of global and local features on the model results. The calculation formula of the SHAP value is:

[0032]

[0033] In the formula, It represents the contribution value of the i-th feature, N represents the set of all features, n represents the number of features in N, S is the subset containing feature i, and v(N) is the base value, which represents the prediction result of each feature in N when the feature value is unknown.

[0034] The present invention arranges automatic water quality monitoring stations at each monitoring section of the river, monitors and records historical water quality data and meteorological data, sorts them by time series, and performs preprocessing to construct a sequence format data set; the constructed sequence format original data set is decomposed by the STL method (trend decomposition method) to the original water quality data to be predicted, so as to obtain trend items, period items and residual items; the obtained trend items, period items and residual items are respectively modeled by LSTM, NeuralProphet and XGBoost algorithms based on the attention mechanism, and the trend, periodicity and residual of the target water quality parameters are predicted with different time steps; the trend, periodicity and residual prediction results of the target water quality parameters are combined to predict the time series changes of the target water quality parameters; the previously constructed deep learning model Attention-basedLSTM is used, and the model is interpreted by SHAP analysis to improve the applicability of the model. While ensuring that the various items after data decomposition can obtain the trend and periodicity of water quality changes, the present invention improves the accuracy of water quality prediction and effectively suppresses the cumulative error phenomenon in the long-term step model prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 This is a schematic diagram of the water quality monitoring section of a city’s river basin.

[0036] Figure 2 The present invention is a flowchart of the method.

[0037] Figure 3 This is a comparison chart of the two model results of the predicted value and the measured value of dissolved oxygen in the S1 monitoring section in an embodiment of the present invention.

[0038] Figure 4 This is a diagram of the SHAP analysis results of the dissolved oxygen prediction model for the S1 monitoring section in an embodiment of the present invention. DETAILED DESCRIPTION

[0039] like Figure 1As shown in Figure 1, the river basin area of ​​a certain city is about 84 square kilometers. The abundant water resources in the basin provide a strong guarantee for the stable development of various industries in and around the region. However, with the rapid economic development and the continuous improvement of urbanization, the water consumption in the region has increased rapidly, and a large amount of industrial wastewater and domestic sewage has been discharged. The water quality of urban surface water bodies has once shown a deteriorating trend, and water quality-type water shortage has become increasingly prominent.

[0040] A method for predicting water quality of a river monitoring section based on STL decomposition and attention mechanism in this embodiment includes the following steps:

[0041] (1) Automatic water quality monitoring stations were set up at 7 monitoring sections of the river in the area to monitor and record historical water quality data and meteorological data from January 1, 2021 to January 31, 2022, and sorted them in time series to construct a sequence format dataset.

[0042] (2) The original data of the sequence format data set is decomposed using the STL decomposition method to obtain trend terms, periodic terms and residual terms.

[0043] (3) The LSTM model based on the attention mechanism was used to predict the trend item, and the optimal parameters of DA-RNN were determined by grid search, where batchsize=16, nhidden_encoder=128, nhidden_decoder=128, epochs=10000, and learning_rate=0.00001; the NeuralProphet model was used to predict the periodic item, epochs=1000, learning_rate=0.01, and the XGBoost model was used to predict the residual item, n_estimators=1000, and learning_rate=0.05.

[0044] (4) Add the trend term, period term and residual term prediction results of the water quality parameter to be predicted to predict the time series change of the target water quality parameter. The process can be expressed as:

[0045]

[0046] In the formula, It represents the predicted value of the time series change of the water quality index to be predicted at the future time t; Indicates the change of indicator trend item at the future time t predicted by LSTM based on attention mechanism; Represents the change of the periodic term at the future time t predicted by NeuralProphet; Represents the change in the error term at the future time t predicted by XGBoost.

[0047] (5) The previously constructed LSTM model based on the attention mechanism was analyzed using the SHAP method to obtain the importance ranking of the model input features and evaluate the impact of global and local features on the model results.

[0048] For the model prediction results, the coefficient of determination (R 2 ) and mean absolute error (MAE) to evaluate the prediction accuracy of the algorithm. The specific calculation formula is as follows:

[0049]

[0050] Among them, y i Indicates the monitored value of water quality parameters to be predicted. Indicates the predicted value of the water quality parameter to be predicted, It represents the average value of the monitored value of the water quality parameter to be predicted, and n represents the number of data values ​​in the time series.

[0051] The flow chart of the method of (1) to (5) above is as follows Figure 2 As shown in the figure, this method can quickly and accurately predict the changes in key water quality parameters of the river section. At the same time, observing the various items after STL decomposition can obtain the trend and cycle of water quality changes, which is of great significance to water environment management.

[0052] In this example, in order to verify the prediction effect of the above method, dissolved oxygen and ammonia nitrogen were selected as the key water quality parameters of the river section for prediction. The prediction results are shown in Table 1. The actual monitoring values ​​of the water quality parameters of the studied river section are basically consistent with the model prediction values, among which R 2 The maximum value can reach 0.99, which shows that the prediction accuracy of this method is high and can fully reach the level of practical application.

[0053] Table 1 Average values ​​of prediction evaluation indicators of dissolved oxygen and ammonia nitrogen in seven river sections using the spatiotemporal attention model

[0054]

[0055] Depend on Figure 3 It can be seen that the model based on the spatiotemporal attention mechanism has better prediction effect for long-term step lengths than the model based on the temporal attention mechanism, and effectively suppresses the cumulative error phenomenon in the prediction of long-term step length models. Figure 4 The SHAP analysis results shown in the figure show that as the distance between the input monitoring site and the prediction site increases, the importance of the monitoring site decreases. This method effectively improves the interpretability of the model and greatly increases its practical application capabilities.

[0056] The above-described embodiment is only an application scheme of the present invention, but it is not intended to limit the present invention. A person skilled in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, any technical solution obtained by equivalent replacement or equivalent transformation is within the protection scope of the present invention.

Claims

1. A water quality prediction method for river monitoring sections based on STL decomposition and attention mechanism, characterized in that: The following steps are involved: (1) Automatic water quality monitoring stations are arranged at each monitoring section of the river to monitor and record historical water quality data and meteorological data, sort them by time series, and perform preprocessing to construct a sequence format data set; (2) Decomposing the original water quality data to be predicted in the sequence format constructed in step (1) by using the STL method to obtain trend terms, period terms and residual terms; (3) The trend item, period item and residual item data obtained in step (2) are respectively used to establish an integrated deep learning model based on the attention mechanism using the LSTM, NeuralProphet and XGBoost algorithms based on the attention mechanism to predict the trend, periodicity and residual of the target water quality parameters at different time steps; (4) Combining the trend, periodicity and residual prediction results of the target water quality parameters obtained in step (3) to predict the time series changes of the target water quality parameters; that is, adding the predicted trend term, periodicity term and residual term to obtain the final water quality parameter prediction result.

2. The method according to claim 1, characterized in that The preprocessing described in step (1) is to remove outliers from the historical water quality data and meteorological data using the IQR method and fill in missing values ​​using linear interpolation to complete the preprocessing operation.

3. The method according to claim 1, characterized in that In step (2), the original water quality data to be predicted is decomposed using the STL method to obtain trend terms, period terms and residual terms. The specific decomposition formula is: Y t =T t +S t +R t Where Y t T represents the original monitoring water quality data of the site to be predicted; t represents the trend term after decomposition using the STL algorithm; S t represents the periodic term after decomposition using the STL algorithm; R t Represents the residual term after decomposition using the STL algorithm.

4. The method according to claim 1, characterized in that In step (3), the prediction model is built using the LSTM, NeuralProphet and XGBoost algorithms based on the attention mechanism to predict the trend, periodicity and residual of the target water quality parameters at different time steps, including: The LSTM algorithm based on the attention mechanism is used to predict the trend item, the NeuralProphet algorithm is used to predict the period item, and the XGBoost algorithm is used to predict the residual item. The input of each model is the data of the water quality parameter to be predicted n moments ago and the data of the meteorological parameter n moments ago. The specific formula is: In the formula, represents the predicted value of water quality index at time t+1, superscript m represents the monitoring site, subscript n represents the time, X represents the meteorological parameter, superscript k represents the number of meteorological parameters, and subscript n represents the time; The different time steps include 1 hour, 2 hours, 12 hours and 24 hours.

5. The method according to claim 4, characterized in that The LSTM algorithm based on the attention mechanism uses temporal attention and spatial attention. Specifically, the weight value h of temporal attention j The calculation formula is: In the formula, v d , b d ∈R m , W d ∈R m×2p and U d ∈R m×m are all parameters that the model needs to learn, p is the number of hidden states in temporal attention, σ c refers to the hyperbolic tangent function, σ z refers to the softmax function, and are the hidden state and unit state of the previous LSTM hidden layer in temporal attention, and These are all intermediate learning parameters.

6. The method according to claim 4, characterized in that Spatial attention can dynamically learn the spatial correlation between external factors to predict water quality indicators; learn the joint spatiotemporal relationship by simultaneously learning spatial correlation and temporal correlation; the weight value h′ of spatiotemporal attention j The calculation formula is: In the formula, v′ d , b′ d ∈R m+n , W′ d ∈R (m+n)×2q and U′ d ∈R m×m are all parameters that the model needs to learn, q is the number of hidden states in spatiotemporal attention, σ c refers to the hyperbolic tangent function, σ z refers to the softmax function, and are the hidden state and unit state of the previous LSTM hidden layer in spatiotemporal attention, and are all intermediate learning parameters, A concatenated vector representing simultaneous joint spatiotemporal relations.

7. The method according to claim 1, characterized in that The following steps are also included: (5) Using the integrated deep learning model based on the attention mechanism established in step (3), SHAP analysis is used to analyze the interpretability of the model to improve the applicability of the model.

8. The method according to claim 7, characterized in that In step (5), the deep learning model Attention-based LSTM established in step (3) is used to analyze the model for interpretability using SHAP analysis to improve the applicability of the model, including: By calculating the SHAP value, we can obtain the importance ranking of the model input features and evaluate the impact of global and local features on the model results. The calculation formula of the SHAP value is: In the formula, It represents the contribution value of the i-th feature, N represents the set of all features, n represents the number of features in N, S is the subset containing feature i, and v(N) is the base value, which represents the prediction result of each feature in N when the feature value is unknown.

Citation Information

Cited By

  • Underground water environment monitoring method and system based on big data

    CN120804843A

  • Groundwater environment monitoring method and system based on big data

    CN120804843B

  • River channel space section water quality prediction method based on physical information neural network

    CN121744953A

  • River space section water quality prediction method based on physical information neural network

    CN121744953B