A water quality prediction method, system, and product based on temporal decomposition and multi-component dedicated attention.
By employing a water quality prediction method based on temporal decomposition and multi-component dedicated attention, the problems of insufficient water quality prediction accuracy and poor shock load early warning capability in existing technologies are solved. This method achieves high-precision water quality prediction and wastewater treatment process optimization, thereby improving the stability and energy consumption management of wastewater treatment plants.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-21
- Publication Date
- 2026-04-03
AI Technical Summary
Existing water quality prediction technologies struggle to capture complex nonlinear dependencies, resulting in insufficient prediction accuracy. Furthermore, standard deep learning models are unable to distinguish between different features when processing various types of time-series characteristics, leading to poor early warning capabilities for shock loads.
We employ a temporal decomposition and multi-component dedicated attention approach. By using the STL time series decomposition algorithm, we decompose water quality parameters into trend, seasonal, and residual components. We then construct deep learning prediction modules for each component and apply an encoder-decoder LSTM architecture and a dedicated attention mechanism for prediction.
It significantly improves the accuracy of water quality prediction and sensitivity to shock loads, provides high-precision influent water quality early warning, guides the optimization of wastewater treatment processes, avoids system collapse, and achieves energy saving and consumption reduction.
Smart Images

Figure CN121565314B_ABST
Abstract
Description
Technical Field
[0001] This application relates to a water quality prediction method, system, and product based on time-series decomposition and multi-component dedicated attention for the field of wastewater treatment. Background Technology
[0002] Wastewater treatment plants are critical infrastructure for urban water environment protection. The influent quality of wastewater treatment plants encompasses multiple dimensions, such as chemical oxygen demand (COD) and total nitrogen (TN). Influent water quality exhibits complex, non-linear, non-stationary, and multi-periodic fluctuations due to factors such as industrial and domestic wastewater discharge and weather changes. Among these, sudden high-concentration pollutant shock loads are a major risk source leading to treatment process malfunctions, effluent quality exceeding standards, and even the collapse of the biological treatment system. Therefore, accurate and timely prediction of influent water quality, especially early warning of shock loads, is of paramount importance for guiding wastewater treatment plants in proactive process control, ensuring stable system operation, and reducing energy and chemical consumption.
[0003] Currently, existing water quality prediction technologies mainly face the following challenges:
[0004] Traditional statistical models (such as ARIMA) for water quality prediction often suffer from insufficient accuracy because they are based on linear assumptions and struggle to capture the complex nonlinear dependencies in wastewater data. While standard deep learning models (such as single LSTM or Transformer) offer powerful end-to-end nonlinear fitting capabilities, the complex temporal variations in water quality parameters, involving multiple types of temporal features, often result in indiscriminate feature differentiation, leading to mutual influence and a "one-sided" limitation. Attempting to learn all temporal feature types in a unified manner can overfit to dominant feature patterns while neglecting crucial but weak anomalous shock signals, resulting in poor early warning capabilities for shock loads—precisely the problem that water quality treatment prediction needs to address. Furthermore, while standard deep learning models can focus on important features through attention mechanisms, these mechanisms lack specificity when dealing with complex combinations of diverse temporal features, failing to achieve optimal feature extraction strategies. Summary of the Invention
[0005] The purpose of this application is to overcome the shortcomings of the prior art and provide a water quality prediction method, system and product based on time series decomposition and multi-component dedicated attention. It can perform time series decomposition of water quality time series data to form different data components, and perform model training and data prediction based on different data components. Finally, it synthesizes the total prediction data, which can effectively deal with the multiple time series characteristics of water quality data and accurately capture and predict key shock load signals.
[0006] Firstly, this application provides a water quality prediction method based on temporal decomposition and multi-component dedicated attention, the technical solution of which includes a prediction model training step and a prediction step.
[0007] S1, acquire historical time-series data of water quality parameters;
[0008] S2 uses the STL time series decomposition algorithm to decompose the historical time series data of water quality parameters into three data components: trend component, seasonal component and residual component.
[0009] S3, construct deep learning prediction modules, namely trend prediction module, seasonal prediction module and residual prediction module, and each deep learning prediction module is trained using the corresponding data components;
[0010] The deep learning prediction module employs an encoder-decoder LSTM neural network, specifically as follows: Historical time-series data, initial hidden state h0, and initial cell state C0 are input into a linear layer, and after addition and layer normalization, feature weights are obtained through a fully connected layer and an activation function. The feature weights and historical time-series data are then input into the encoding layer, which uses LSTM as its basic unit. After parsing, the hidden states output by each LSTM are merged, and a context vector is output to the attention mechanism. The attention mechanism outputs the weighted context vector to the decoding layer, which decodes it and outputs the predicted time-series data. The difference between the predicted time-series data and the true target value is calculated using a loss function, and the model is trained with the goal of minimizing the loss function.
[0011] Each deep learning prediction module has a corresponding attention mechanism, namely trend attention mechanism, seasonal attention mechanism and residual attention mechanism;
[0012] The specific prediction steps are as follows:
[0013] S4, input the monitoring time series data of water quality parameters arranged in time series within the past preset time period into the prediction model, and decompose them into three types of data components: trend component, seasonal component and residual component through the STL time series decomposition algorithm.
[0014] S5. Input each data component into the corresponding deep learning prediction module, and output trend prediction time series data, seasonal prediction time series data and residual prediction time series data respectively. Add the various prediction time series data point by point to obtain the total prediction time series data of the target water quality parameters in the future time period.
[0015] S6, adjust the process parameters of wastewater treatment based on the total predicted time series data of water quality parameters.
[0016] By employing the above technical solution, before inputting time series data, the time series data is first decomposed into three single-mode dimensions using a time series decomposition algorithm: trend dimension, seasonal dimension, and residual dimension. Predictive models are then trained and predicted data is output for each of the different dimensions. Finally, the data is aggregated to form the final predicted data, which can significantly improve the accuracy of prediction.
[0017] Preferably, the water quality parameters mentioned in S1 include chemical oxygen demand (COD), nitrogen content (TN), ammonia nitrogen (NH3-N), phosphorus content (TP), and pH, with the time granularity of historical time series data being in the hour.
[0018] By using the above technical solutions, time-series data on different water quality parameters can be obtained, enabling model training and data prediction for each water quality parameter.
[0019] As a preferred method, the STL time series decomposition algorithm adopts additive decomposition. Specifically, a specific seasonal period is set, the trend period component is calculated on the original data, the trend period component is subtracted from the original data to obtain detrended data, the time granularity average of the original data is subtracted from the time granularity average of the detrended data to obtain the seasonal component, and the detrended data is subtracted from the seasonal component to obtain the residual component.
[0020] The above technical solution defines the periodicity of water quality parameter time series data, and then uses the STL time series decomposition algorithm to decompose the time series data into the calculation results of trend period components, seasonal components and residual components for a specific period.
[0021] As a preferred embodiment, in S3, the context vector output by the attention mechanism is input to the decoding layer through a fully connected layer. The LSTM of the decoding layer receives the hidden state and cell state output by the last LSTM of the encoding layer as the initial state for decoding. The information output by the LSTM of the decoding layer is processed by addition and layer normalization, then forward propagation calculation is performed through a feedforward neural network, and finally the predicted time series data is output after mapping through a fully connected layer.
[0022] The above scheme uses an attention mechanism to focus key information of the corresponding data components and outputs it to the decoder. The decoder then receives the context vector and uses it as a condition to gradually generate the target sequence of future predicted values.
[0023] Preferably, the trend attention mechanism is as follows:
[0024] The trend attention mechanism accepts the output of all time steps of the encoder as input, adds a parameter matrix for position encoding, uses a one-dimensional convolutional layer as a smoothing filter, and obtains a trend vector representing the global trend of the entire sequence by calculating the average of the global trend. The trend vector is projected through a linear layer and expanded to calculate the global features. The global features are added to the result of the smoothing filter and the linear layer projection. The result is then fed into the tanh activation function to calculate the attention weights, and finally generates the context vector.
[0025] Preferably, the seasonal attention mechanism is as follows:
[0026] The seasonal attention mechanism accepts the output of all time steps of the encoder as input and sets several initialization cycles of different scales. It then iterates through each cycle of different scales to reshape the cycle, extract the cycle pattern, expand the pattern, and apply the cycle attention.
[0027] Periodic fusion is performed on the traversal results of all set scales. The features of the periods of all scales are connected through the last dimension and compressed through a linear layer to obtain fused features containing periodic information of each scale. The fused features are projected using standard attention calculation, and then compressed to one dimension through tanh activation and softmax is applied to obtain the attention score. The context vector is obtained by weighting the attention score and the fused features containing periodic information of each scale.
[0028] Preferably, the residual attention mechanism is as follows:
[0029] The residual attention mechanism accepts the output of the encoder at all time steps as input, and feeds the input into two independent linear layers for anomalous feature learning and fluctuating feature learning;
[0030] The first sequence is obtained by performing one-dimensional convolution using a convolution kernel of k=3. The average value of the first sequence and the difference between each value and the average value are calculated to obtain the second sequence. The first sequence is combined with the abnormal features, and the fluctuation features of the second sequence are combined. The combined features of the two sequences are then connected in the final dimension. The result is compressed to one dimension to obtain the attention score. The attention score is used to perform a weighted summation on the original input to obtain the context vector.
[0031] By employing different attention mechanisms for the trend component, seasonal component, and residual component, the model's ability to process heterogeneous information and its overall performance can be significantly improved. This enhances the model's ability to express the features of specific data components, thereby improving the accuracy of predictions.
[0032] As a preferred option, adjusting the process parameters for wastewater treatment specifically includes adjusting aeration, adjusting the diversion of influent, and adjusting chemical dosing.
[0033] By using the above technical solutions, the corresponding wastewater treatment process parameters can be adjusted based on the total predicted time series data of the target water quality parameters over a future period, thereby achieving automated and intelligent wastewater treatment.
[0034] Secondly, this application provides a water quality prediction system based on time-series decomposition and multi-component dedicated attention, the technical solution of which includes a data receiving and decomposition module, a deep learning prediction module, a result integration module and a process parameter adjustment module;
[0035] The data receiving and decomposition module is used to receive historical time-series data and real-time time-series data of water quality parameters, and perform STL time series decomposition to decompose the historical time-series data and real-time time-series data into trend components, seasonal components and residual components.
[0036] The deep learning prediction module includes a parallel trend prediction module, a seasonal prediction module, and a residual prediction module. Each prediction module trains the corresponding model and outputs the corresponding prediction time series data based on the corresponding data components.
[0037] The result integration module is used to add up the parallel prediction time series data and output the total prediction time series data.
[0038] The process parameter adjustment module stores a mapping table of process parameters with respect to predicted time series data, and outputs corresponding process parameter adjustment and control commands based on the total predicted time series data.
[0039] Thirdly, this application provides a computer program product, which includes a computer program or instructions that enable the computer program or instructions to implement the steps of the above-mentioned water quality prediction method based on temporal decomposition and multi-component dedicated attention.
[0040] In summary, this application includes at least one of the following beneficial technical effects:
[0041] 1. This application adopts a "decompose first, then predict" strategy to transform a complex, multi-mode mixed water quality parameter time series prediction problem into three simpler sub-problems with a single mode, corresponding to the trend component, seasonal component, and residual component of the data component summary, respectively. Each sub-problem is selectively focused on features by a specially designed attention mechanism, avoiding mode confusion and interference in the single model learning process, thereby significantly improving the overall prediction accuracy.
[0042] 2. This application separates unpredictable abnormal shock signals from the original time series and incorporates them into the residual component. The residual prediction module is specifically responsible for learning these high-frequency, violent fluctuations, which makes the model highly sensitive and capable of capturing sudden high-concentration shock loads, and the early warning effect is far superior to traditional models.
[0043] 3. This application processes data with different characteristics separately, making the model insensitive to noise. Even if the data of a certain component fluctuates greatly, especially the severe oscillation of the residual component, it will not pollute the stability of the learning of the trend and seasonal terms, making the entire prediction system more robust and reliable, and the model has good robustness and generalization.
[0044] 4. This application can provide wastewater treatment plants with high-precision influent water quality early warning for the next 1-2 hours, giving on-site operators valuable decision-making and response time. It can effectively guide them to optimize processes, thereby avoiding system crashes, ensuring effluent meets standards, and achieving energy conservation and consumption reduction. Attached Figure Description
[0045] Figure 1 This is a flowchart illustrating the training steps of the prediction model for the water quality prediction method based on temporal decomposition and multi-component dedicated attention in the embodiments of this application.
[0046] Figure 2 This is a schematic diagram of the architecture of the deep learning prediction module of the water quality prediction method based on temporal decomposition and multi-component dedicated attention in the embodiments of this application.
[0047] Figure 3 This is a flowchart illustrating the prediction steps of the water quality prediction method based on temporal decomposition and multi-component dedicated attention in the embodiments of this application.
[0048] Figure 4 This is a schematic diagram of the architecture of a water quality prediction system based on temporal decomposition and multi-component dedicated attention in an embodiment of this application. Detailed Implementation
[0049] This specific embodiment is merely an explanation of this application and is not intended to limit it. After reading this specification, those skilled in the art can make modifications to this embodiment without contributing any inventive step, but such modifications are protected by patent law as long as they are within the scope of this application.
[0050] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. It should be noted that in the optional embodiments of this application, the object information and other related data involved require the permission or consent of the object when the embodiments of this application are applied to specific products or technologies, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. That is to say, if the embodiments of this application involve data related to the object, it needs to be obtained with the authorization and consent of the object, the authorization and consent of the relevant departments, and in compliance with the relevant laws, regulations, and standards of the country and region. If personal information is involved in the embodiments, the acquisition of all personal information requires the consent of the individual. If sensitive information is involved, the separate consent of the information subject is required, and the embodiments also need to be implemented with the authorization and consent of the object.
[0051] The embodiments of this application will now be described in further detail with reference to the accompanying drawings.
[0052] This application aims to address the problem that existing water quality prediction models have low accuracy when dealing with complex time series, especially their insufficient early warning capability for high-concentration shock loads.
[0053] To this end, embodiments of this application provide a water quality prediction method based on temporal decomposition and multi-component dedicated attention. First, a prediction model is trained using temporal historical data of water quality parameters. Then, based on the prediction model, water quality parameter monitoring time series data within a preset time period before the current moment is input to obtain water quality parameter prediction time series data for the future time period, thereby providing early warning of water quality changes and realizing intelligent control of water treatment processes.
[0054] For details, please refer to Figure 1 The specific steps for training the prediction model include:
[0055] S1, obtain historical time-series data of water quality parameters arranged in time series.
[0056] The wastewater treatment plant's online monitoring system collects water quality parameters hourly, forming time-series data. This accumulated large volume of historical time-series data provides a sufficient dataset for model training. These water quality parameters include chemical oxygen demand (COD), nitrogen content (TN), ammonia nitrogen (NH3-N), phosphorus content (TP), and pH. Different prediction models are trained for different water quality parameters, outputting predicted time-series data corresponding to each parameter type. This allows for the appropriate adjustment of water treatment process parameters based on the prediction results and combinations of various water quality parameters.
[0057] After acquiring historical time-series data, preprocessing is required, including missing value imputation and outlier smoothing. More specifically, in the embodiments of this application, a box plot method is used, and data from different types of water quality parameters at the same time point are used together as a reference to distinguish outliers and noise points.
[0058] S2. For the preprocessed historical time series data, the STL time series decomposition algorithm is used to decompose the characteristics to obtain three data components with different characteristics: trend component, seasonal component and residual component. The specific method is as follows.
[0059] The historical time-series data for water quality parameters has a time granularity of 1 hour. Taking the periodicity of water quality input from a wastewater treatment plant on a 24-hour timescale as an example, the seasonal period is set to 24. Since the seasonal period is an even number, the original data is used to calculate the trend period component using 2×24-MA, where MA is a moving average. In another embodiment, if it is desired to expand the periodicity timescale to weeks, the seasonal period can be set to 7*24=168.
[0060] Then, the influence of the trend needs to be removed from the original data. This is done by subtracting the trend cycle component 2×24-MA from the historical time series data to obtain the detrended data. The seasonal component is then obtained by subtracting the time granularity average of the original data from the time granularity average of the detrended data. In the embodiments of this application, the time granularity is 1 hour, and the time granularity average is the average of each hour (from 0:00 to 23:00) over all days of the historical time series data.
[0061] Finally, the residual component can be obtained by subtracting the detrended data from the seasonal component.
[0062] S3 constructs deep learning prediction modules, namely a trend prediction module, a seasonal prediction module, and a residual prediction module. Each deep learning prediction module is trained using its corresponding data components, and attention mechanisms are constructed for each module: a trend attention mechanism, a seasonal attention mechanism, and a residual attention mechanism. (See also...) Figure 2The deep learning prediction module uses an encoder-decoder LSTM neural network, and the specific architecture is as follows.
[0063] Historical time-series data X, initial hidden state h0, and initial cell state C0 are input into a linear layer, LinearLayer, to project their respective features onto a unified dimension. Then, a non-linear transformation is introduced through the activation function tanh to standardize the output, which is then fed to the ADD&Norm layer for addition and layer normalization to achieve information fusion. Finally, a fully connected layer FCW is used. f And the output feature weights of the activation function Softmax.
[0064] Feature weights and historical time-series data are weighted and input into the encoder layer. The encoder layer uses LSTM as its basic unit, consisting of t LSTM units. The hidden states h1, h2...ht output by each LSTM unit are merged using a function q through the encoder layer parsing. The encoder LSTM reads the input sequence step by step. At each step, it receives the input of the current time step and updates its internal hidden state. This hidden state is the model's summary and memory of the sequence information up to the current time step. After processing the entire input sequence, the encoder's final hidden state is the target of the context vector, comprehensively summarizing the core information of the entire input sequence.
[0065] The merged data undergoes Information Compression, and the output context vector is fed into the Timpral Attention mechanism for processing and output.
[0066] The Timpral Attention mechanism outputs a context vector containing all memory information, which is then passed through a fully connected layer (FCW). cp The input is fed into the decoder layer. The LSTM unit of the decoder layer receives the hidden state ht and cell state Ct output from the last LSTM unit of the encoder layer as input for decoding. The information output from the LSTM unit of the decoder layer is added and normalized by the ADD & Norm layers to achieve information fusion. Then, it undergoes forward propagation computation through a feedforward neural network (FFN) and finally passes through a fully connected layer (FCW). d The mapping process ultimately outputs the predicted time-series data, Predictions.
[0067] During training, the input to the LSTM decoder at each step is the previous value at the corresponding position in the real target sequence, which can provide more accurate guidance for the decoder, making the training process more stable and converge faster.
[0068] The decoder produces a prediction at each time step. The overall difference between the predicted value at the output time step and the true target value is calculated using a loss function. This error is then propagated back from the decoder to the encoder via backpropagation to update the parameters of both the encoder and decoder in the model. Through continuous iteration, with the goal of minimizing the loss function, the model is trained to achieve accurate predictions.
[0069] In the embodiments of this application, three different attention mechanisms are constructed for the three data components with different characteristics: trend attention mechanism, seasonal attention mechanism, and residual attention mechanism.
[0070] The trend attention mechanism is as follows:
[0071] The trend attention mechanism accepts the encoder's output at all time steps as input. A learnable parameter matrix is added as a positional encoding, allowing the model to perceive the absolute or relative position of time steps to capture long-term dependencies. A one-dimensional convolutional layer is used as a smoothing filter, and a vector representing the global trend of the entire sequence is calculated by averaging across the time dimension (dim=1). After obtaining the trend vector, it is projected through a linear layer and expanded to calculate global features. The global features are then added to the result of the smoothing filter and linear layer projection. The sum is then passed to the tanh activation function for attention weight calculation, ultimately generating the context vector.
[0072] The seasonal attention mechanism is as follows:
[0073] The seasonal attention mechanism accepts the encoder's output at all time steps as input. Several initialization periods of different scales are set, each corresponding to a different time dimension. For example, different initialization periods can be based on weeks, months, quarters, or years. Thus, in the STL time series decomposition algorithm, a seasonal period of 24 days (i.e., days) is artificially added. By sequentially traversing each period at different scales, period reshaping, pattern extraction, pattern expansion, and the application of periodic attention are performed.
[0074] Periodic fusion is performed on the traversal results of all set scales. The features of the periods of all scales are connected through the last dimension and compressed through a linear layer to obtain fused features containing periodic information of each scale. The fused features are projected using standard attention calculation, and then compressed to one dimension through tanh activation and softmax is applied to obtain the attention score. The context vector is obtained by weighting the attention score and the fused features containing periodic information of each scale.
[0075] The residual attention mechanism is specifically as follows:
[0076] The residual attention mechanism accepts the encoder's output at all time steps as input. The input is then fed into two independent linear layers for learning anomalous features and fluctuating features, respectively.
[0077] A first sequence is obtained by performing a one-dimensional convolution using a k=3 kernel. The average value of the first sequence and the difference between each value and the average value are calculated to obtain a second sequence. The first sequence is combined with the anomaly features, and the fluctuation features of the second sequence are combined. The combined features of the two sequences are then concatenated in the final dimension. The concatenation result is compressed to one dimension to obtain an attention score. The attention score is then used to perform a weighted summation of the original input to obtain a context vector.
[0078] Different attention mechanisms are employed for the trend, seasonality, and residual components, with customized processing tailored to the inherent characteristics of each component. This allows the model to more deeply and meticulously understand and utilize information at different scales in the time series, enabling it to capture information more precisely and generate more accurate and robust predictions. The three prediction modules are trained independently, each using mean squared error (MSE) as the loss function and employing the Adam optimizer for parameter optimization.
[0079] Please see Figure 3 The prediction steps specifically include:
[0080] S4, input the monitoring time series data of water quality parameters arranged in a time series within a preset time period into the prediction model. In the embodiments of this application, the monitoring time series data of water quality parameters for the 24 hours prior to the current time point are obtained, and then decomposed into three types of data components—trend, seasonal, and residual—using the STL time series decomposition algorithm.
[0081] S5 inputs each data component into the corresponding trend prediction module, seasonal prediction module, and residual prediction module, which outputs the trend prediction time series data (trend_pred), seasonal prediction time series data (seasonal_pred), and residual prediction time series data (residual_pred) for the next 2 hours, respectively. The various prediction time series data are then summed point by point to obtain the total prediction time series data for the target water quality parameter over the future time period.
[0082] Taking chemical oxygen demand as an example, we have:
[0083] COD_Final_pred=COD_trend_pred+COD_seasonal_pred+COD_residual_pred
[0084] S6. Adjustments are made to the wastewater treatment process parameters based on the overall predicted time-series data of water quality parameters. Specifically, these adjustments include aeration adjustments, influent diversion adjustments, and chemical dosing adjustments.
[0085] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0086] Please see Figure 4 Another embodiment of this application provides a water quality prediction system based on temporal decomposition and multi-component dedicated attention, including a data receiving and decomposition module 1, a deep learning prediction module 2, a result integration module 3, and a process parameter adjustment module 4.
[0087] The data receiving and decomposition module 1 is used to receive historical time-series data and real-time time-series data of water quality parameters, and to perform STL time series decomposition on the time-series data, decomposing the historical time-series data and real-time time-series data into trend components, seasonal components and residual components.
[0088] The deep learning prediction module 2 includes a parallel trend prediction module 21, a seasonal prediction module 22, and a residual prediction module 23. Each prediction module trains the corresponding model and outputs the corresponding prediction time series data based on the corresponding data components.
[0089] The result integration module 3 is used to add up the parallel prediction time series data and output the total prediction time series data.
[0090] The process parameter adjustment module 4 stores a mapping table of process parameters with respect to the predicted time series data, and outputs corresponding process parameter adjustment and control commands based on the total predicted time series data.
[0091] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the water quality prediction system based on temporal decomposition and multi-component dedicated attention described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0092] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0093] Another embodiment of this application provides a computer program product, including a computer program or instructions that enable the computer program or instructions to implement the steps of the above-described water quality prediction method based on temporal decomposition and multi-component dedicated attention.
[0094] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0095] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A water quality prediction method based on temporal decomposition and multi-component dedicated attention, characterized in that, This includes the prediction model training steps and the prediction steps; The specific steps for training a prediction model include: S1, acquire historical time-series data of water quality parameters; S2 uses the STL time series decomposition algorithm to decompose the historical time series data of water quality parameters into three data components: trend component, seasonal component and residual component. S3, construct deep learning prediction modules, namely trend prediction module, seasonal prediction module and residual prediction module, and each deep learning prediction module is trained using the corresponding data components; The deep learning prediction module employs an encoder-decoder LSTM neural network, specifically as follows: Historical time-series data, initial hidden state h0, and initial cell state C0 are input into a linear layer, and after addition and layer normalization, feature weights are obtained through a fully connected layer and an activation function. The feature weights and historical time-series data are then input into the encoding layer, which uses LSTM as its basic unit. After parsing, the hidden states output by each LSTM are merged, and a context vector is output to the attention mechanism. The attention mechanism outputs the weighted context vector to the decoding layer, which decodes it and outputs the predicted time-series data. The difference between the predicted time-series data and the true target value is calculated using a loss function, and the model is trained with the goal of minimizing the loss function. Each deep learning prediction module has a corresponding attention mechanism, namely trend attention mechanism, seasonal attention mechanism and residual attention mechanism; The specific prediction steps are as follows: S4, input the monitoring time series data of water quality parameters arranged in time series within the past preset time period into the prediction model, and decompose them into three types of data components: trend component, seasonal component and residual component through the STL time series decomposition algorithm. S5. Input each data component into the corresponding deep learning prediction module, and output trend prediction time series data, seasonal prediction time series data and residual prediction time series data respectively. Add the various prediction time series data point by point to obtain the total prediction time series data of the target water quality parameters in the future time period. S6, adjust the process parameters of wastewater treatment based on the total predicted time series data of water quality parameters.
2. The water quality prediction method based on temporal decomposition and multi-component dedicated attention as described in claim 1, characterized in that, The water quality parameters mentioned in S1 include chemical oxygen demand (COD), nitrogen content (TN), ammonia nitrogen (NH3-N), phosphorus content (TP), and pH. The time granularity of the historical time series data is in hours.
3. The water quality prediction method based on temporal decomposition and multi-component dedicated attention as described in claim 2, characterized in that, The STL time series decomposition algorithm uses additive decomposition. Specifically, it sets a specific seasonal period, calculates the trend period component on the original data, subtracts the trend period component from the original data to obtain detrended data, then subtracts the time granular average of the original data from the time granular average of the detrended data to obtain the seasonal component, and finally subtracts the detrended data from the seasonal component to obtain the residual component.
4. The water quality prediction method based on temporal decomposition and multi-component dedicated attention as described in claim 1, characterized in that, In S3, the context vector output by the attention mechanism is fed into the decoding layer through a fully connected layer. The LSTM of the decoding layer receives the hidden state and cell state output by the last LSTM of the encoding layer as the initial state for decoding. The information output by the LSTM of the decoding layer is added and normalized by the layer, then passed through the feedforward neural network for forward propagation calculation, and finally mapped through the fully connected layer to output the predicted time series data.
5. The water quality prediction method based on temporal decomposition and multi-component dedicated attention as described in claim 4, characterized in that, The trend attention mechanism is specifically as follows: The trend attention mechanism accepts the output of all time steps of the encoder as input, adds a parameter matrix for position encoding, uses a one-dimensional convolutional layer as a smoothing filter, and obtains a trend vector representing the global trend of the entire sequence by calculating the average of the global trend. The trend vector is projected through a linear layer and expanded to calculate the global features. The global features are added to the result of the smoothing filter and the linear layer projection. The result is then fed into the tanh activation function to calculate the attention weights, and finally generates the context vector.
6. The water quality prediction method based on temporal decomposition and multi-component dedicated attention according to claim 4, characterized in that, The seasonal attention mechanism is specifically as follows: The seasonal attention mechanism accepts the output of all time steps of the encoder as input and sets several initialization cycles of different scales. It then iterates through each cycle of different scales to reshape the cycle, extract the cycle pattern, expand the pattern, and apply the cycle attention. Periodic fusion is performed on the traversal results of all set scales. The features of the periods of all scales are connected through the last dimension and compressed through a linear layer to obtain fused features containing periodic information of each scale. The fused features are projected using standard attention calculation, and then compressed to one dimension through tanh activation and softmax is applied to obtain the attention score. The context vector is obtained by weighting the attention score and the fused features containing periodic information of each scale.
7. The water quality prediction method based on temporal decomposition and multi-component dedicated attention as described in claim 4, characterized in that, The residual attention mechanism is specifically as follows: The residual attention mechanism accepts the output of the encoder at all time steps as input, and feeds the input into two independent linear layers for anomalous feature learning and fluctuating feature learning; The first sequence is obtained by performing one-dimensional convolution using a convolution kernel of k=3. The average value of the first sequence and the difference between each value and the average value are calculated to obtain the second sequence. The first sequence is combined with the abnormal features, and the fluctuation features of the second sequence are combined. The combined features of the two sequences are then connected in the final dimension. The result is compressed to one dimension to obtain the attention score. The attention score is used to perform a weighted summation on the original input to obtain the context vector.
8. The water quality prediction method based on temporal decomposition and multi-component dedicated attention according to claim 1, characterized in that, Adjusting the process parameters for wastewater treatment specifically includes adjusting aeration, adjusting the diversion of influent, and adjusting chemical dosing.
9. A water quality prediction system based on temporal decomposition and multi-component dedicated attention, characterized in that, It includes a data receiving and decomposition module, a deep learning prediction module, a result integration module, and a process parameter adjustment module; The data receiving and decomposition module is used to receive historical time-series data and real-time time-series data of water quality parameters, and perform STL time series decomposition to decompose the historical time-series data and real-time time-series data into trend components, seasonal components and residual components. The deep learning prediction module includes a parallel trend prediction module, a seasonal prediction module, and a residual prediction module. Each deep learning prediction module is trained using corresponding data components. The deep learning prediction module adopts a neural network with an encoder-decoder LSTM architecture. The specific architecture is as follows: historical time series data, initial hidden state h0, and initial cell state C0 are input into a linear layer, and after addition and layer normalization, feature weights are obtained through a fully connected layer and an activation function. Feature weights and historical time-series data are input into the encoding layer, which uses LSTM as the basic unit. After parsing, the hidden states output by each LSTM are merged, and the output context vector is fed to the attention mechanism. The attention mechanism outputs the weighted context vector to the decoding layer, and after decoding, it outputs the predicted time-series data. The difference between the predicted time-series data and the true target value is calculated using a loss function, and the model is trained with the goal of minimizing the loss function. Corresponding attention mechanisms are constructed for each deep learning prediction module, namely trend attention mechanism, seasonal attention mechanism, and residual attention mechanism. The deep learning prediction module outputs trend prediction time-series data, seasonal prediction time-series data, and residual prediction time-series data based on the trend component, seasonal component, and residual component of the real-time time-series data. The result integration module is used to add the trend prediction time series data, seasonal prediction time series data and residual prediction time series data point by point, and output the total prediction time series data. The process parameter adjustment module stores a mapping table of process parameters with respect to predicted time series data, and outputs corresponding process parameter adjustment and control commands based on the total predicted time series data.
10. A computer program product, characterized in that, The computer program product includes a computer program or instructions that enable the computer program or instructions to implement the steps of the water quality prediction method based on temporal decomposition and multi-component dedicated attention as described in any one of claims 1 to 8.
Citation Information
Patent Citations
A multi-feature fusion Chinese news text abstract generation method based on a neural network
CN109344391A
Industrial park short-term load prediction method and system based on Diffusion-Transform-AR model
CN119154249A