Method for predicting water quality of industrial wastewater

By combining adaptive attention mechanism with multidimensional temporal feature encoding, the problems of insufficient utilization of temporal features and multi-parameter correlation modeling in industrial wastewater quality prediction are solved, realizing multi-parameter collaborative prediction and high-precision water quality prediction, and improving the interpretability and engineering applicability of the model.

CN121963944APending Publication Date: 2026-05-01CHINA COAL TECH & ENG GRP HANGZHOU ENVIRONMENTAL PROTECTION INST
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA COAL TECH & ENG GRP HANGZHOU ENVIRONMENTAL PROTECTION INST
Filing Date
2025-12-11
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing industrial wastewater quality prediction methods suffer from insufficient utilization of time-series features, weak multi-parameter correlation modeling, poor ability to process periodic features, and insufficient model interpretability, making it difficult to achieve joint prediction of multiple parameters and adaptive attention adjustment.

Method used

An adaptive attention mechanism and multidimensional time feature encoding are adopted. By acquiring historical time series data of key water quality parameters of industrial wastewater, periodic and linear trend feature encoding is performed. Combined with a two-layer LSTM network and an adaptive attention mechanism with a learnable scaling factor, multi-parameter collaborative prediction is carried out.

Benefits of technology

It significantly improves the accuracy and efficiency of industrial wastewater quality prediction, can predict multiple key parameters simultaneously, provides highly interpretable decision support, reduces reagent consumption and energy consumption, and improves the effluent compliance rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121963944A_ABST
    Figure CN121963944A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of electronic digital data processing, and discloses an industrial wastewater quality prediction method which comprises the following steps: acquiring historical time sequence data of key water quality parameters including an organic pollutant index, a nutritive salt index and a physical and chemical index, and preprocessing; performing periodic feature coding and linear trend feature coding on an input timestamp, and splicing all features into an enhanced feature sequence; inputting the enhanced feature sequence into a recurrent neural network for time sequence coding, and extracting a long-term dependency relationship of historical data; based on time sequence coding output, introducing an adaptive attention mechanism capable of learning a scaling factor to calculate the attention weight of each time step, and carrying out adaptive weighted fusion on the features; and processing the weighted and fused features, and outputting a plurality of key water quality parameter predicted values of a plurality of time steps in the future. The problems of insufficient utilization of time sequence features and weak multi-parameter correlation modeling are solved, and the purposes of multi-parameter joint prediction and adaptive attention adjustment are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

A method for predicting the quality of industrial wastewater Technical Field

[0001] This invention relates to the field of electronic digital data processing technology, and in particular to a method for predicting the quality of industrial wastewater. Background Technology

[0002] Industrial wastewater treatment is a crucial aspect of environmental protection. Accurately predicting water quality trends is essential for guiding process adjustments, reducing treatment costs, and ensuring compliance with discharge standards. Currently, industrial wastewater quality prediction primarily employs traditional statistical methods, such as ARIMA and linear regression, building predictive models based on historical data. While these methods are computationally simple, their prediction accuracy is limited, and they struggle to handle nonlinear relationships. With the development of machine learning, algorithms like Support Vector Machines (SVM) and Random Forests have begun to be applied to water quality prediction. Although these methods can handle nonlinear problems, their utilization of temporal features remains insufficient. In recent years, deep learning methods, especially recurrent neural networks such as LSTM and GRU, have demonstrated advantages in temporal data processing, capable of learning long-term dependencies, but they still suffer from insufficient differentiation of importance at different time steps. Attention mechanisms have achieved significant success in natural language processing and computer vision, but their application in water quality prediction is still limited, and there is a lack of dedicated designs tailored to the characteristics of water quality data. The current state of existing technologies in industrial wastewater quality prediction shows that most methods can only predict a single parameter, lack the ability to jointly predict multiple parameters, do not fully utilize the periodic characteristics of water quality data, have poor model interpretability, and are difficult to provide decision support for operators.

[0003] For example, Chinese patent CN117291069B discloses an LSTM wastewater quality prediction method based on an improved DE and attention mechanism, providing the following technical solution: 1) preprocessing the dataset of important features of wastewater treatment plants; 2) constructing and initializing an ATT-LSTM water quality prediction model; 3) optimizing the hyperparameters of the ATT-LSTM water quality prediction model using ADE to obtain an optimal hyperparameter ADE-ATT-LSTM water quality prediction model; 4) constructing training and testing sets based on the preprocessed data to train the optimal hyperparameter ADE-ATT-LSTM water quality prediction model; 5) inputting the collected data into the trained ADE-ATT-LSTM water quality prediction model to obtain the DO prediction result. The water quality prediction model of this invention can ensure optimal prediction model parameters, thereby effectively improving the accuracy of water quality prediction; and this invention, by combining ADE with ATT and LSTM models, greatly improves the computational efficiency of the water quality prediction model. However, the aforementioned LSTM wastewater quality prediction method based on improved DE and attention mechanism only predicts a single water quality parameter, lacks multi-parameter coordination capability, and does not fully utilize its temporal characteristics. Furthermore, its attention mechanism is fixed and lacks the ability to adaptively adjust weights. At the same time, its prediction step size is singular, limiting its engineering application value. Summary of the Invention

[0004] This invention addresses the problems of insufficient utilization of temporal features, weak multi-parameter correlation modeling, poor ability to process periodic features, and insufficient model interpretability in existing technologies. It proposes a method for predicting the quality of industrial wastewater, achieving the goals of multi-parameter joint prediction, adaptive attention adjustment, effective encoding of temporal features, and strong model interpretability.

[0005] Furthermore, this invention achieves multi-parameter coordination and high-precision time series prediction in industrial wastewater through an adaptive attention mechanism and multi-dimensional time feature encoding, thereby solving the problems of insufficient identification of key time periods and inadequate utilization of periodic patterns in existing methods.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: a method for predicting the quality of industrial wastewater, comprising: acquiring historical time-series data of key water quality parameters including organic pollutant indicators, nutrient indicators, and physicochemical indicators, and performing preprocessing; performing periodic feature encoding and linear trend feature encoding on the input timestamps respectively, and concatenating all features into an enhanced feature sequence; inputting the enhanced feature sequence into a recurrent neural network for time-series encoding to extract long-term dependencies of historical data; based on the time-series encoding output, introducing an adaptive attention mechanism with a learnable scaling factor to calculate the attention weights at each time step, and performing adaptive weighted fusion of features; processing the weighted fused features to output predicted values ​​of several key water quality parameters for multiple future time steps.

[0007] By comprehensively processing time-series data and introducing an adaptive attention mechanism, the accuracy and efficiency of industrial wastewater quality prediction are significantly improved. It can predict multiple key parameters simultaneously, facilitating precise process adjustments.

[0008] Preferably, the periodic feature encoding uses sine and cosine functions to encode 24-hour and 7-day periodic features; the linear trend feature encoding constructs hourly linear normalized features, weekday linear normalized features, and month normalized features; the periodic feature encoding and the linear trend feature encoding together form a 7-dimensional time feature vector.

[0009] By using sine and cosine functions to encode periodic and linear trend features, a 7-dimensional time feature vector is constructed, which effectively captures the daily and weekly cycle patterns of industrial wastewater quality and enhances the model's ability to learn time patterns.

[0010] Preferably, the adaptive attention mechanism that introduces a learnable scaling factor includes: calculating the global average feature vector of the input sequence, performing a linear transformation through a trainable weight matrix and bias parameters, and obtaining an adaptive scaling factor by mapping with a modified Sigmoid function; scaling the dot product of the query matrix and the transpose of the key matrix using the adaptive scaling factor, and then normalizing it with a Softmax function to obtain the attention weights.

[0011] By dynamically adjusting the attention distribution through a learnable adaptive scaling factor, key time steps are automatically identified, improving the model's efficiency in utilizing important information and thus enhancing prediction accuracy.

[0012] Preferably, the adaptive attention mechanism that introduces a learnable scaling factor further includes applying a regularization constraint to the adaptive scaling factor, wherein the regularization constraint employs adding a penalty term to the loss function that is proportional to the square of the scaling factor's deviation from the baseline value.

[0013] Applying regularization constraints to the adaptive scaling factor ensures that the scaling factor fluctuates within a reasonable range, improving the model's stability and generalization ability, and preventing overfitting.

[0014] Preferably, the recurrent neural network is a two-layer LSTM network, which performs temporal encoding on the enhanced feature sequence; the output of the second-layer LSTM network is used as the input of the adaptive attention mechanism, and the weighted feature representation output by the adaptive attention mechanism is processed by residual connections and layer normalization before being input into the subsequent fully connected network for prediction; in the two-layer LSTM network, each LSTM network output sequence is followed by a Dropout layer for regularization.

[0015] A two-layer LSTM network is used to extract long-term temporal dependencies. Combined with residual connections and layer normalization, training stability is enhanced, gradient vanishing or exploding is prevented, and the model convergence performance is improved.

[0016] Preferably, the fully connected network includes: first, performing global average pooling on the sequence features processed by the adaptive attention mechanism to obtain a feature vector of fixed length, and then performing nonlinear mapping through two fully connected layers to finally output the predicted value; the fully connected layers use the ReLU activation function and are connected to a Dropout layer.

[0017] Global average pooling is used to compress variable-length sequence features into fixed-length vectors, which are then non-linearly mapped by a fully connected layer to effectively extract high-level features and improve prediction accuracy. At the same time, a Dropout layer is used to prevent overfitting.

[0018] Preferably, the output of several key water quality parameters predicted for multiple future time steps specifically includes: selecting key water quality parameters including chemical oxygen demand, ammonia nitrogen content, and total phosphorus content for joint prediction, predicting their respective values ​​for multiple future time steps, using a weighted multi-parameter mean square error loss function, assigning weights according to parameter importance, and combining the regularization loss of the adaptive scaling factor to form the overall loss function.

[0019] Key water quality parameters are selected for joint prediction. A weighted multi-parameter loss function is used, and weights are assigned according to the importance of the parameters to make full use of the correlation information between the parameters and improve the consistency and efficiency of the prediction.

[0020] Preferably, the prediction model training process of the joint prediction adopts an adaptive learning rate scheduling strategy and an early stopping mechanism. The adaptive learning rate scheduling strategy reduces the learning rate when the validation set loss does not improve for several consecutive training cycles until a preset minimum learning rate limit is reached. The early stopping mechanism terminates training when the validation set loss does not improve for several consecutive training cycles and saves the optimal model parameters when the validation loss is minimized.

[0021] Adaptive learning rate scheduling and early stopping mechanisms are employed to dynamically adjust the learning rate and avoid overtraining, thereby accelerating model convergence, preserving optimal model parameters, and improving training efficiency and model performance.

[0022] Preferably, the preprocessing includes: using the Laida principle to detect outliers, filling missing values ​​with linear interpolation, filling data with historical average values ​​for consecutive missing values ​​exceeding a preset threshold, and eliminating high-frequency noise through smoothing filtering.

[0023] Outliers are detected using the Laida principle, missing values ​​are filled using linear interpolation and historical averages, and noise is eliminated by smoothing filtering to improve data quality.

[0024] Preferably, the organic pollutant indicators include chemical oxygen demand (COD) and biochemical oxygen demand (BOD), the nutrient indicators include ammonia nitrogen content, total phosphorus content, and total nitrogen content, and the physicochemical indicators include pH value, suspended solids, and dissolved oxygen.

[0025] The specific composition of organic pollutant indicators, nutrient indicators, and physicochemical indicators should be clearly defined to ensure that the model covers key water quality parameters of industrial wastewater and improve the comprehensiveness and practicality of predictions.

[0026] Compared with the prior art, the beneficial effects of the present invention are as follows.

[0027] 1. This invention dynamically identifies key time steps in historical data through an adaptive attention mechanism, effectively improving the model's efficiency in utilizing important information. This keeps all error indicators at a low level, ensuring the accuracy of water quality prediction and providing a reliable data foundation for subsequent process adjustments.

[0028] 2. This invention achieves multi-parameter collaborative prediction and efficient computation. It employs a shared feature extraction layer to simultaneously predict multiple key water quality indicators, significantly reducing computational overhead while maintaining the physical correlation between parameters. The model training converges quickly and exhibits good stability, effectively preventing overfitting through an early stopping mechanism and regularization techniques. This enhances the system's engineering practicality, enabling early warning of water quality anomalies and supporting integrated automated control.

[0029] 3. The attention weight visualization function of this invention makes the model's decision-making process transparent, providing a basis for operators. By accurately predicting and guiding process optimization, it can effectively reduce reagent consumption and energy consumption, and improve the effluent compliance rate. Attached Figure Description

[0030] Figure 1 is an overall flowchart of a method for predicting the quality of industrial wastewater according to the present invention.

[0031] Figure 2 is a model training convergence curve of the industrial wastewater quality prediction method of the present invention.

[0032] Figure 3 is a comparison of the multi-parameter prediction results of the industrial wastewater quality prediction method of the present invention.

[0033] Figure 4 is a comparison of the multi-parameter prediction results of the industrial wastewater quality prediction method of the present invention.

[0034] Figure 5 is a comparison of the multi-parameter prediction results of the industrial wastewater quality prediction method of the present invention (Figure c).

[0035] Figure 6 is a visualization of the attention weights in the industrial wastewater quality prediction method of the present invention. Detailed Implementation

[0036] Referring to Figures 1-6, a method for predicting the water quality of industrial wastewater includes: acquiring historical time-series data of key water quality parameters, including organic pollutant indicators, nutrient indicators, and physicochemical indicators, and performing preprocessing; performing periodic feature encoding and linear trend feature encoding on the input timestamps respectively, and concatenating all features into an enhanced feature sequence; inputting the enhanced feature sequence into a recurrent neural network for time-series encoding to extract long-term dependencies of historical data; based on the time-series encoding output, introducing an adaptive attention mechanism with a learnable scaling factor to calculate the attention weights at each time step, and performing adaptive weighted fusion of features; processing the weighted fused features to output predicted values ​​of several key water quality parameters for multiple future time steps.

[0037] Existing industrial wastewater quality prediction technologies suffer from insufficient utilization of temporal features. Traditional methods such as LSTM assign equal weights to all historical time steps, failing to automatically identify time periods more critical to the prediction results, leading to limited prediction accuracy. Furthermore, complex interrelationships exist among various water quality parameters in industrial wastewater, including COD, BOD, NH3-N, and TP. Existing methods often employ independent single-parameter predictions, failing to effectively utilize inter-parameter correlation information and exhibiting insufficient multi-parameter correlation modeling capabilities. Additionally, industrial wastewater quality exhibits clear daily and weekly time patterns, but existing methods lack effective periodic feature encoding mechanisms, resulting in weak periodic feature processing capabilities. Existing deep learning methods are mostly black-box models, unable to explain the basis of prediction results, hindering guidance for process adjustments and exhibiting poor model interpretability. Most existing methods can only predict values ​​at the next time point, failing to provide multi-step predictions, resulting in a single prediction time domain and limiting practical application value.

[0038] Therefore, this invention proposes an industrial wastewater quality prediction method based on an adaptive attention mechanism. By constructing an adaptive weight learning mechanism and multidimensional temporal feature encoding technology, it solves the technical problems of existing technologies in terms of temporal feature utilization, multi-parameter correlation modeling, and periodic feature processing.

[0039] As shown in Figure 1, which is an overall flowchart of the industrial wastewater quality prediction method of the present invention, this invention provides an industrial wastewater quality prediction method. First, historical time-series data is acquired from the industrial wastewater treatment system. This data includes several key water quality parameters, mainly covering organic pollutant indicators including chemical oxygen demand (COD) and biochemical oxygen demand (BOD), nutrient indicators including ammonia nitrogen content, total phosphorus content, and total nitrogen content, and physicochemical indicators including pH, suspended solids, and dissolved oxygen. After data acquisition, a preprocessing stage is initiated. In this stage, the system uses the Laida principle for outlier detection and removal. For missing values ​​in the data, linear interpolation is preferentially used for filling. If the continuous missing time exceeds a preset threshold, the mean of historical data from the same period is used for filling to ensure data continuity. Finally, high-frequency noise in the data is eliminated through smoothing filtering technology, thereby obtaining a clean and complete time-series data sequence.

[0040] Then, this invention performs refined encoding on the timestamp information corresponding to each data point to fully capture the temporal patterns inherent in the changes in industrial wastewater quality. The encoding process consists of two parallel paths: periodic feature encoding and linear trend feature encoding. Periodic encoding targets daily and weekly cycles, using sine and cosine functions respectively to transform hourly and weekday information into continuous periodic feature vectors. Linear trend encoding aims to characterize the progressive effect of time itself, transforming hourly, weekday, and monthly information into scaled linear features through normalization. The above encodings collectively generate a seven-dimensional time feature vector.

[0041] Next, the preprocessed multidimensional water quality parameter sequence is concatenated with the generated seven-dimensional temporal feature vector to form a more informative enhanced feature sequence. This sequence is then fed into a specially designed recurrent neural network for deep temporal encoding. This network employs a two-layer long short-term memory (LSTM) structure: the first layer captures basic temporal dependency patterns, and the second layer further extracts higher-level temporal features. To prevent overfitting, a randomly deactivated layer is connected after the output of each LTM layer. Through this network, the model can effectively learn complex long-term dependencies in historical data.

[0042] Subsequently, the core innovation of this invention—the adaptive attention mechanism—comes into play. This mechanism uses the temporal encoding output from the previous stage of the Long Short-Term Memory (LSTM) network as input. Its core lies in introducing a learnable adaptive scaling factor. This factor is generated by calculating the global statistical features of the input sequence, passing it through a linear transformation layer containing trainable weights and biases, and then mapping it through a modified form of the Sigmoid function. This design allows the model to dynamically adjust the sensitivity and focus of the attention distribution based on the characteristics of the current input data. Furthermore, during model training, a regularization constraint term is added to the loss function to prevent the scaling factor from deviating from a reasonable range. The calculated attention weights are ultimately used to weightedly fuse the temporal features, and through residual connections and layer normalization operations, output a feature representation that enhances key information.

[0043] Subsequently, the weighted and fused feature sequence enters the prediction output stage. This sequence first passes through a global average pooling layer, where it is compressed into a fixed-length global feature vector. This vector then undergoes a non-linear transformation and mapping through a sub-network consisting of two fully connected layers. Each fully connected layer uses a linear rectified activation function and is also equipped with a random deactivation layer to enhance generalization ability.

[0044] Finally, the network output layer directly generates the final multi-step, multi-parameter prediction results. This invention selects chemical oxygen demand (COD), ammonia nitrogen content, and total phosphorus content as key prediction indicators. The model architecture supports simultaneously outputting the predicted values ​​of each indicator for multiple consecutive time steps in the future. To optimize multi-task learning, a weighted multi-parameter mean squared error loss function is used during training. Differentiated loss weights are assigned to different parameters based on their actual importance, and this loss is combined with the regularization loss of the aforementioned adaptive scaling factor to form the overall goal of model training. In the entire model training optimization process, this invention also employs an adaptive learning rate scheduling strategy and an early stopping mechanism. The learning rate scheduling automatically reduces the learning rate until it reaches the lower limit when the validation set loss stagnates; the early stopping mechanism terminates training early when the validation loss shows no improvement, saving the optimal model parameters, thereby ensuring training efficiency and preventing overfitting.

[0045] In another embodiment, the core technical process is as follows: The present invention adopts a five-layer cascaded processing architecture: raw data acquisition → feature engineering processing → LSTM temporal coding → adaptive attention weighting → multi-parameter joint prediction.

[0046] The main technical modules include: data preprocessing and feature engineering module: realizing the fusion processing of 8-dimensional water quality parameters and 7-dimensional time features; adaptive attention mechanism module: core innovative technology, introducing a learnable scaling factor α; two-layer LSTM network module: extracting long-term dependencies of time series data; multi-parameter joint prediction module: simultaneously predicting three key water quality indicators: COD, NH3-N, and TP.

[0047] The specific process includes: 1. Raw data processing: receiving 8 core water quality parameters from the industrial wastewater treatment system: chemical oxygen demand (COD), pH, suspended solids (SS), biochemical oxygen demand (BOD), ammonia nitrogen (NH3-N), total phosphorus (TP), total nitrogen (TN), and dissolved oxygen (DO). The data acquisition frequency is once per hour.

[0048] Data cleaning employs the 3σ criterion for outlier detection, missing values ​​are filled using linear interpolation, and data with consecutive missing values ​​exceeding 6 hours are filled using the historical average for the same period. High-frequency noise is eliminated using a 3-point moving average method.

[0049] 2. Multidimensional temporal feature coding technology constructs a 7-dimensional three-dimensional temporal feature coding method, which includes multi-scale periodic features and linear trend features.

[0050] Periodic Feature Encoding: Sine and cosine functions are used to encode 24-hour and 7-day periodic features, respectively, h... sin h cos d sin d cos Among them, h sin sin(2π multiplied by t) h Divide by 24 again, h cos cos(2π multiplied by t) h Divide by 24 again, d sin sin(2π multiplied by t) d Divide by 7 again, d cos cos(2π multiplied by t) d Divide by 7 again.

[0051] Linear feature encoding: Constructing hourly linearly normalized features h linear , Weekly linear normalized feature d linear Monthly Normalized Features m norm Among them, h linear For t h Divide by 23, d linear For t d Divide by 6, m norm For t m Divide by 11.

[0052] Feature fusion: The 8-dimensional water quality parameters are concatenated with the 7-dimensional time features to form a 15-dimensional enhanced feature vector, which is used to construct a time series input matrix of 72 hours of historical data.

[0053] 3. Learning Mechanism of Adaptive Scaling Factor α: Traditional attention mechanisms use a fixed scaling factor of 1 / √d. k This invention introduces a learnable adaptive scaling factor α, enabling the attention mechanism to automatically adjust the sensitivity of the weight distribution based on the characteristics of the input data.

[0054] The adaptive scaling factor is calculated through global feature extraction and parameterized mapping: first, the global average feature vector of the input sequence is calculated, then a linear transformation is performed through a trainable weight matrix and bias parameters, and finally a modified sigmoid function is used to ensure that the α value is within a reasonable range.

[0055] 4. Enhanced Attention Weight Calculation: The input sequence is transformed linearly to generate a query matrix Q, a key matrix K, and a value matrix V. An adaptive attention score is then calculated, specifically: S adaptive Equals query matrix Q multiplied by K T Multiply by α and then divide by √d k .

[0056] The weights are normalized using the Softmax function, and the final weighted feature aggregation result is obtained.

[0057] 5. Regularization constraint mechanism: To prevent the α factor from deviating excessively from a reasonable range, a regularization loss is introduced, specifically: L reg,α It equals λα multiplied by |α minus 1.0| 2 The regularization coefficient is set to 0.01.

[0058] 6. Two-layer LSTM temporal modeling employs a two-layer LSTM network structure for temporal feature extraction: the first LSTM layer contains 128 hidden units, and the second LSTM layer contains 64 hidden units, both configured to maintain sequence output mode. A dropout layer with a dropout rate of 0.2 is added after each LSTM layer to prevent overfitting.

[0059] 7. Adaptive Attention Layer Integration: The output of the second LSTM layer is used as the input of the adaptive attention layer. Attention weights and weighted feature representations are calculated according to the adaptive attention mechanism described above. Training stability is ensured through residual connections and layer normalization.

[0060] 8. The multilayer fully connected prediction network uses global average pooling to compress variable-length sequence features into a 64-dimensional fixed-length vector, and performs nonlinear mapping through two layers of fully connected networks: the first layer has 128 neurons and the second layer has 64 neurons, both of which use the ReLU activation function and are set with dropout regularization with dropout rates of 0.3 and 0.2 respectively, and finally outputs an 18-dimensional prediction result.

[0061] 9. Multi-task output design selects three key water quality indicators—COD, NH3-N, and TP—for joint prediction. Each parameter predicts the next six time steps, forming a 3×6=18-dimensional output structure. Computational redundancy is reduced by sharing a feature extraction layer, while maintaining the physical correlation between different water quality parameters.

[0062] 10. The joint loss function design adopts a weighted multi-parameter mean squared error loss function, and the weights are assigned according to the importance of the parameters: COD weight 0.4, NH3-N weight 0.3, TP weight 0.3, and the overall loss function is formed by combining the regularization loss of the adaptive scaling factor.

[0063] This invention also includes a model training optimization strategy, specifically including: adaptive learning rate scheduling, with the initial learning rate set to 5×10. -4 When the validation set loss shows no improvement after 5 consecutive training epochs, the learning rate is multiplied by a decay factor of 0.5, and the minimum learning rate lower bound is set to 1×10. -8 .

[0064] An early stopping mechanism monitors the validation set loss and sets the patience parameter to 15 training epochs. When the validation loss does not improve for 15 consecutive epochs, training is automatically stopped, and the optimal model parameters with the minimum validation loss are saved.

[0065] 11. Data Transmission and Mechanism of Action: Key data transmission nodes include: Feature Enhancement Processing Node, which takes 8-dimensional water quality parameters and timestamps as input and outputs a 15-dimensional enhanced feature vector, realizing continuous numerical representation of discrete-time information and enhancing the model's ability to learn periodic patterns; Adaptive Attention Processing Node, which takes a 72×64-dimensional LSTM hidden state tensor as input and outputs a 72×64-dimensional weighted feature representation, automatically identifying time steps in the historical sequence that are more important for prediction and improving the utilization efficiency of important information; and Multi-Parameter Output Processing Node, which takes a 64-dimensional global feature vector as input and outputs an 18-dimensional prediction vector, achieving multi-parameter collaborative prediction while maintaining the physical correlation between parameters.

[0066] Data dimensionality transformation path: The dimensionality transformation sequence in the data processing process is as follows: original 8-dimensional water quality data → 15-dimensional enhanced features → 72×15-dimensional sequence matrix → 72×64-dimensional LSTM encoding → 72×64-dimensional attention weighting → 64-dimensional global features → 18-dimensional prediction output.

[0067] Through the above technical solution design, this invention constructs a complete and efficient industrial wastewater quality prediction technology system, which significantly improves prediction accuracy and engineering practicality while ensuring technical integrity.

[0068] In summary, the adaptive scaling factor α mechanism of this invention overcomes the limitations of fixed scaling in traditional attention mechanisms by introducing a learnable adaptive scaling factor to dynamically adjust the attention distribution based on data characteristics. This solves the problem of unreasonable attention weight distribution in high-noise industrial wastewater environments and significantly improves the model's ability to identify key time steps.

[0069] The seven-dimensional time feature encoding of this invention constructs a comprehensive time feature encoding system that includes multiple time scales (hour-day-month) and multiple feature types (periodic-trend). It fully captures the multi-level periodic variation patterns of industrial wastewater, significantly improving the model's ability to learn time patterns.

[0070] The multi-parameter collaborative prediction architecture of this invention employs shared feature extraction and joint output design to achieve collaborative prediction of multiple related water quality parameters. It maintains the physical correlation between parameters, improves prediction consistency, and reduces computational overhead by approximately 67% compared to independent prediction methods.

[0071] Based on this, the attention mechanism of the present invention can also adopt: a multi-head adaptive attention scheme, which extends the single-head adaptive attention into multiple parallel attention heads, each head having an independent α factor, capable of learning different types of attention patterns, but the computational complexity increases accordingly; and a gated adaptive attention scheme, which adds a gating mechanism to control the information flow on the basis of adaptive attention, providing more refined information flow control, but the number of parameters and training complexity increase significantly.

[0072] Based on this, the network architecture of the present invention can also adopt: a pure Transformer architecture scheme, which completely uses the Transformer encoder to replace the hybrid architecture of LSTM and attention, which has strong parallel computing capabilities, but is prone to overfitting to small datasets; a CNN-LSTM hybrid architecture scheme, which adds a one-dimensional convolutional layer before LSTM to extract local temporal features, which can extract multi-scale temporal features, but the network complexity increases accordingly.

[0073] Based on this, the prediction output step of the present invention can also adopt: a recursive multi-step prediction scheme, which uses a single-step prediction model to recursively generate multi-step prediction results. The model structure is simple and easy to train, but there is an error accumulation problem; a hierarchical prediction architecture scheme, which adopts a two-layer prediction structure of coarse granularity and fine granularity, which can model changes at different time scales respectively, but the model complexity increases significantly.

[0074] This invention also includes a complete industrial wastewater quality prediction system architecture, comprising the following main modules: a data acquisition module, a data preprocessing module, a deep learning prediction module, and an output processing module. The deep learning prediction module includes a two-layer LSTM, an adaptive attention layer, and a fully connected layer; the output processing module includes multi-parameter prediction results and visualization of attention weights.

[0075] Figure 2 shows the model training convergence curve of the industrial wastewater quality prediction method of this invention. Based on experimental verification results, this figure is a combination of two sub-figures. The left sub-figure is the loss function convergence curve, with the horizontal axis representing the training period (1-40 epochs) and the vertical axis representing the loss value (0-0.14). It shows that the training loss (blue solid line) rapidly decreases from 0.138 to 0.012, and the validation loss (orange solid line) decreases from 0.043 to 0.012. Both curves tend to stabilize after the 8th epoch. The right sub-figure is the MAE index change curve, with the horizontal axis also representing the training period and the vertical axis representing the MAE value (0-0.28). Both the training MAE and validation MAE show a stable decreasing trend, eventually converging to around 0.08. Key nodes in the figure are marked, such as the learning rate adjustment points in the 21st, 28th, and 38th epochs.

[0076] As shown in Figures 3-5, Figure 3 (a), Figure 4 (b), and Figure 5 (c) are comparison charts of the multi-parameter prediction results of the industrial wastewater quality prediction method of the present invention. Based on the verification of actual prediction results, the figures are presented in three sub-figures (a, b, and c). Each sub-figure shows the prediction effect of one water quality parameter (COD, NH3-N, TP), with the horizontal axis representing the time step (0-100) and the vertical axis representing the normalized parameter value (0-0.9). Each sub-figure contains three elements: the actual value curve (blue solid line), the predicted value curve (red solid line), and the error range area (pink shaded area). The figures show that the predicted curves closely match the actual curves, with a small error range, reflecting the model's prediction accuracy. The MAPE values ​​of each parameter are labeled in the upper right corner of the figures (COD: 28.28%, NH3-N: 24.83%, TP: 32.91%).

[0077] Figure 6 shows the attention weight visualization of the industrial wastewater quality prediction method of this invention. Based on the model interpretability analysis results, the figure contains two side-by-side subplots. The left subplot shows the importance analysis of query weights, with the horizontal axis representing feature indices (0-64) and the vertical axis representing the average absolute weight value (0.09-0.13). The blue line shows the weight distribution of each feature, with peaks appearing at feature indices 7, 25, 31, 57, and 58. The right subplot shows the importance analysis of key weights, with the horizontal axis representing feature indices (0-64) and the vertical axis representing the average absolute weight value (0.10-0.22). The red line shows higher weight values ​​at feature indices 20, 34, 51, 55, and 56.

[0078] The advantages of this invention are as follows: It achieves a significant improvement in prediction accuracy. Actual test results show a mean squared error (MSE) of 0.0159, a mean absolute error (MAE) of 0.0836, a root mean square error (RMSE) of 0.1260, and mean absolute percentage errors (MAPE) for each parameter of 28.28% for COD, 24.83% for NH3-N, and 32.91% for TP. This technical effect is mainly due to the adaptive attention mechanism's ability to automatically identify key time periods in historical data, significantly improving the model's efficiency in utilizing important information.

[0079] Regarding multi-parameter joint prediction capabilities, this invention can simultaneously predict the future 6-hour variation trends of three key water quality parameters, significantly improving prediction efficiency and parameter consistency compared to single-parameter prediction methods. This effect is achieved through shared feature extraction and joint output design, fully utilizing the correlation information between different water quality parameters. Model interpretability is significantly enhanced; through attention weight visualization, key time steps and important features affecting the prediction can be identified, providing operators with a scientific basis for decision-making. This is mainly due to the fact that the attention weights output by the adaptive attention layer can directly reflect the model's decision-making process.

[0080] In terms of training convergence performance, the model of this invention achieves optimal performance within 38 training epochs, with the training loss decreasing from 0.1380 to 0.0120, verifying stable loss convergence and demonstrating good learning ability. This effect is achieved by employing adaptive learning rate scheduling, early stopping mechanism, and regularization techniques, effectively preventing overfitting. Computational efficiency is significantly improved compared to traditional multi-model independent prediction schemes. The joint prediction framework of this invention reduces computational overhead by approximately 67%, mainly achieved by reducing redundant computation through shared feature extraction layers.

[0081] In terms of engineering application value, this invention can provide early warning of water quality anomalies up to 6 hours in advance, offering sufficient reaction time for process adjustments. The prediction accuracy meets industrial application requirements and supports integration into automated control systems. The model's interpretability provides a scientific basis for human intervention. By guiding process optimization through accurate prediction, it can reduce reagent usage by 15-20%, lower energy consumption by 10-15%, and improve effluent compliance rates, resulting in significant environmental and economic benefits.

Claims

1. A method for predicting the quality of industrial wastewater, characterized in that, This includes: acquiring historical time-series data of key water quality parameters, including organic pollutant indicators, nutrient indicators, and physicochemical indicators, and performing preprocessing; The input timestamps are encoded with periodic features and linear trend features respectively, and all features are concatenated into an enhanced feature sequence. The enhanced feature sequence is input into a recurrent neural network for temporal encoding to extract long-term dependencies from historical data. Based on the temporal encoding output, an adaptive attention mechanism with a learnable scaling factor is introduced to calculate the attention weights at each time step, and the features are adaptively weighted and fused. The weighted and fused features are then processed to output the predicted values ​​of several key water quality parameters for multiple future time steps.

2. The method for predicting the quality of industrial wastewater according to claim 1, characterized in that, The periodic feature encoding uses sine and cosine functions to encode 24-hour and 7-day periodic features; the linear trend feature encoding constructs hourly linear normalized features, weekday linear normalized features, and month normalized features; A 7-dimensional time feature vector is constructed by combining periodic feature encoding and linear trend feature encoding.

3. The method for predicting the quality of industrial wastewater according to claim 1 or 2, characterized in that, The adaptive attention mechanism that introduces a learnable scaling factor includes: calculating the global average feature vector of the input sequence, performing a linear transformation through a trainable weight matrix and bias parameters, and obtaining an adaptive scaling factor by mapping with a modified Sigmoid function; scaling the dot product of the query matrix and the transpose of the key matrix using the adaptive scaling factor, and then normalizing it with a Softmax function to obtain the attention weights.

4. The method for predicting the quality of industrial wastewater according to claim 3, characterized in that, The adaptive attention mechanism that introduces a learnable scaling factor also includes applying a regularization constraint to the adaptive scaling factor, wherein the regularization constraint employs adding a penalty term to the loss function that is proportional to the square of the scaling factor's deviation from the baseline value.

5. The method for predicting the quality of industrial wastewater according to claim 4, characterized in that, The recurrent neural network is a two-layer LSTM network that performs temporal encoding on the enhanced feature sequence. The output of the second-layer LSTM network is used as the input of the adaptive attention mechanism. The weighted feature representation output by the adaptive attention mechanism is processed by residual connections and layer normalization before being input into the subsequent fully connected network for prediction. In the two-layer LSTM network, each LSTM network output sequence is followed by a Dropout layer for regularization.

6. The method for predicting the quality of industrial wastewater according to claim 5, characterized in that, The fully connected network includes: first, global average pooling is performed on the sequence features processed by the adaptive attention mechanism to obtain a fixed-length feature vector; then, nonlinear mapping is performed through two fully connected layers to finally output the predicted value; the fully connected layers use the ReLU activation function and are connected to a Dropout layer.

7. A method for predicting the quality of industrial wastewater according to claim 1 or 6, characterized in that, The output of predicted values ​​for several key water quality parameters for multiple future time steps specifically includes: selecting key water quality parameters, including chemical oxygen demand, ammonia nitrogen content, and total phosphorus content, for joint prediction, predicting their values ​​for multiple future time steps, using a weighted multi-parameter mean square error loss function, assigning weights according to parameter importance, and combining the regularization loss of the adaptive scaling factor to form the overall loss function.

8. The method for predicting the quality of industrial wastewater according to claim 7, characterized in that, The prediction model training process of the joint prediction adopts an adaptive learning rate scheduling strategy and an early stopping mechanism. The adaptive learning rate scheduling strategy reduces the learning rate when the validation set loss does not improve for several consecutive training cycles until it reaches the preset minimum learning rate limit. The early stopping mechanism terminates training when the validation set loss does not improve for several consecutive training cycles and saves the best model parameters when the validation loss is minimized.

9. A method for predicting the quality of industrial wastewater according to claim 1 or 8, characterized in that, The preprocessing includes: using the Laida principle to detect outliers, filling missing values ​​with linear interpolation, filling data with historical average values ​​for consecutive missing values ​​exceeding a preset threshold, and eliminating high-frequency noise through smoothing filtering.

10. The method for predicting the quality of industrial wastewater according to claim 9, characterized in that, The organic pollutant indicators include chemical oxygen demand (COD) and biochemical oxygen demand (BOD); the nutrient indicators include ammonia nitrogen content, total phosphorus content, and total nitrogen content; and the physicochemical indicators include pH value, suspended solids, and dissolved oxygen.

Citation Information

Patent Citations

  • A LSTM sewage quality prediction method based on improved DE and attention mechanism

    CN117291069B