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

Through the improved differential evolution algorithm, the attention mechanism and LSTM neural network are optimized, and the problems of high time delay and calculation costs in the water quality prediction of sewage treatment plants are solved, achieving more efficient and accurate water quality prediction.

CN117291069BActive Publication Date: 2025-02-18SHENZHEN YUNYIDA BIOTECHNOLOGY CO LTD

Patent Information

Application Number
CN202311148279.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-06
Publication Date
2025-02-18
Estimated Expiration
2043-09-06

AI Technical Summary

Technical Problem

The water quality prediction methods of existing sewage treatment plants have time delays, time-consuming and costly, which are difficult to meet the needs of fast predictions, and traditional neural networks are difficult to effectively deal with time series characteristics and sequence dependencies.

Method used

The improved differential evolution algorithm (ADE) optimizes the attention mechanism (ATT) combined with the long and short-term memory (LSTM) neural network model, optimizes the hyperparameters of ATT-LSTM through ADE, and introduces attention mechanisms into the LSTM model to improve water quality characteristics. mining ability.

Benefits of technology

The accuracy and calculation efficiency of wastewater quality prediction have been improved, and faster and more economical water quality prediction has been achieved, especially in the prediction of dissolved oxygen (DO).

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117291069B_ABST
    Figure CN117291069B_ABST
Patent Text Reader

Abstract

The present invention discloses a LSTM sewage water quality prediction method based on improved DE and attention mechanism, comprising the following steps: 1) pre-processing important feature data sets of sewage 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 a training set and a test set based on the pre-processed 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 a DO prediction result. The water quality prediction model of the present invention can ensure that the prediction model parameters are optimal, thereby effectively improving the water quality prediction accuracy; and the present invention greatly improves the computational efficiency of the water quality prediction model by combining ADE with ATT and LSTM models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of water quality prediction, and specifically relates to an LSTM sewage quality prediction method based on improved DE and attention mechanism. Background Art

[0002] At present, the most effective way to prevent further deterioration and pollution of water resources is to improve the predictive ability of key features in the sewage treatment process, which is difficult to describe with traditional mathematical models due to the uncertainty, nonlinearity and time lag of the sewage treatment process. At the same time, the change of dissolved oxygen (DO) in the water body is closely related to the metabolic rate of the water body, so DO is crucial in assessing the health of the water ecosystem in the sewage treatment plant. However, the lack of reliable DO prediction and forecasting methods has seriously affected the effective monitoring and control of sewage treatment quality. Although accurate concentrations can be obtained by traditional prediction methods, such as the determination of potassium dichromate and potassium permanganate index, there will inevitably be a significant time delay, ranging from a few minutes to a few hours. This delay is too late for advanced wastewater treatment systems that require more precise and timely control. Improving the predictive ability of important features of sewage treatment plants can help sewage treatment plants to make plans, which is of great significance for controlling regional water environmental pollution.

[0003] Traditional prediction methods are time-consuming and costly, and it is difficult to meet the needs of rapid prediction in practical applications. In recent years, neural networks have been gradually introduced into the field of wastewater treatment for data-driven modeling based on their powerful fitting ability and adaptability. However, the time series characteristics of sewage data are ignored, and there is a lack of effective processing of the sequence dependencies between input variables, which limits the model's ability to handle time series predictions. LSTM neural networks have been proposed to balance the time and nonlinear relationship of sewage data. But similar to traditional neural networks, it is difficult to select hyperparameters.

[0004] In order to solve this problem, the present invention provides a prediction method based on a long short-term memory (LSTM) neural network model with an improved differential evolution algorithm (ADE) and an attention mechanism (ATT). Since the hyperparameters of LSTM are difficult to select, ADE is used to optimize ATT-LSTM. In addition, adding ATT to the LSTM model can mine water quality characteristics and improve DO prediction accuracy, which has important practical engineering significance. Summary of the invention

[0005] Purpose of the invention: In view of the problems pointed out in the background technology, the present invention provides a LSTM sewage quality prediction method based on improved DE and attention mechanism. The ATT-LSTM model is optimized by ADE, and finally DO prediction is performed on the sewage, thereby obtaining an accurate DO prediction result, which not only helps to improve the computational efficiency of the model, but also helps to improve the prediction accuracy of the model.

[0006] Technical solution: The present invention provides a LSTM sewage quality prediction method based on improved DE and attention mechanism, comprising the following steps:

[0007] Step 1: Preprocess the important characteristic data set of the sewage treatment plant, which includes the current pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and the historical data of dissolved oxygen at previous moments;

[0008] Step 2: Construct and initialize the ATT-LSTM water quality prediction model, which is a long short-term memory LSTM neural network model based on the attention mechanism ATT;

[0009] Step 3: Based on the preprocessed data, the hyperparameters of the ATT-LSTM water quality prediction model are optimized using the improved differential evolution algorithm ADE to obtain the optimal hyperparameter ADE-ATT-LSTM water quality prediction model;

[0010] Step 4: Based on the preprocessed data, a training set and a test set are constructed to train the optimal hyperparameter ADE-ATT-LSTM water quality prediction model;

[0011] Step 5: Input the collected data sets, including the current pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and the historical data of dissolved oxygen at previous moments, into the trained ADE-ATT-LSTM water quality prediction model to obtain the DO value prediction result.

[0012] Furthermore, the step of preprocessing the data set in step 1 includes:

[0013] S11: Outlier processing: First, the eigenvalues ​​are subjected to descriptive statistics to check for unreasonable data and whether the data obeys a normal distribution. When the sample is greater than 3 standard deviations from the mean, the sample is identified as an outlier and deleted from the data set.

[0014] S12: Missing value processing: index the data with missing values ​​in the data set, and fill the indexed missing values ​​according to the data at the previous time point and the next time point;

[0015] S13: Normalization processing: Map data of different scales and ranges into a unified range to eliminate dimensional differences between different features.

[0016] Furthermore, the attention mechanism in step 2 assigns corresponding weights according to the importance of the input features, and the calculation formula is as follows:

[0017]

[0018]

[0019]

[0020] Where T is the total time step; h m is the output feature vector of LSTM; α m is the result of the first weighted calculation through the fully connected layer; W l αh and b α are the weight matrix and bias of the fully connected layer respectively; β m is calculated by the softmax activation function and assigned to the corresponding h m The final weight of ; and the vector γ is the important feature extracted.

[0021] Furthermore, in step 3, based on the preprocessed data, the hyperparameters of the ATT-LSTM water quality prediction model are optimized using ADE, including:

[0022] S31: The number of hidden layer neurons and learning rate of the ATT-LSTM water quality prediction model are selected as the optimization parameters of the ADE algorithm, the optimization range of the parameters to be optimized is determined, and the population P is randomly initialized;

[0023] S32: Calculate the fitness value of each individual in the ADE algorithm:

[0024]

[0025] Among them, p is the number of samples, y p is the true value of the sample, is the predicted value;

[0026] S33: The entire population P is randomly divided into an exploration subpopulation P1, an exploitation subpopulation P2 and a balance subpopulation P3, and a mutation strategy is adaptively selected;

[0027] S34: Entering the mutation phase, executing the corresponding particle mutation method according to the corresponding mutation strategy and the adaptive mutation factor F;

[0028] S35: Entering the mutation phase, executing the corresponding particle mutation method according to the adaptive crossover probability Cr;

[0029] S36: Calculate the fitness value of the individual, determine the optimal value among the three sub-populations, and merge the three sub-populations;

[0030] S37: Determine whether the conditions for terminating iteration are met; if the number of iterations reaches the maximum value, return the optimal hyperparameters of the model; otherwise, repeat S33 until the termination conditions are met.

[0031] Furthermore, the S33 neutron population adaptive selection mutation strategy is as follows:

[0032] 1) Explore subpopulation P1

[0033] The exploration subpopulation P1 uses DE / rand / 2 as the mutation strategy; two random difference vectors are used to interfere with the target individual. The mutation strategy is as follows:

[0034] "DE / rand / 2": V i,G =X r1,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )

[0035] Among them, V i,G is the individual X in the current population i,G Generate a mutation vector using the mutation strategy, where r1, r2, r3, r4, and r5 represent mutually exclusive integers randomly generated in the range [1, N], and F∈[0,1] is the mutation factor;

[0036] 2) Development of subpopulation P2

[0037] The development subpopulation P2 uses DE / best / 2 as the mutation strategy and searches near the optimal individual of the current population. The mutation strategy is as follows:

[0038] "DE / best / 2": V i,G =X best,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )

[0039] Among them, X best,G is the individual vector with the best fitness value in the G-th generation population;

[0040] 3) Balanced subpopulation P3

[0041] For the balanced subpopulation P3, the population that is currently iterated to the Gth generation is divided into an excellent population and a common population according to the size of the individual fitness value. In the mutation strategy of the improved differential evolution algorithm, X r1,G ,X r2,G ,X r4,G Randomly select from the excellent population, X r3,G and X r5,G Randomly selected from the general population, the adaptive mutation strategy is selected as follows:

[0042]

[0043] Among them, the ratio of excellent population size to the total population size is set to 0.4, Q G The probability of being selected in the two mutation strategies in the above formula is calculated as follows:

[0044]

[0045] Furthermore, in S34, the mutation phase is entered, and a corresponding particle mutation method is executed according to a corresponding mutation strategy and an adaptive mutation factor F. The adaptive mutation factor F is generated as follows:

[0046]

[0047] Among them, F0 is the initial value of the mutation factor, G is the number of current iterations, and G m is the maximum number of iterations; F decreases from 2F0 to F0.

[0048] Furthermore, the adaptive crossover probability Cr of each individual in S35 is generated as follows:

[0049]

[0050] Among them, Cr max ,Cr min is the maximum and minimum value given to Cr, f i , f min and f max They represent the fitness of the i-th individual, the average fitness of the population, the fitness of the best individual, and the fitness of the worst individual respectively.

[0051] Beneficial Effects

[0052] (1) Aiming at the problem of sewage quality prediction, the present invention proposes an improved differential evolution algorithm and designs an adaptive mutation strategy, which aims to assist P3 in expanding the search range in the early stage of evolution and help P3 improve the convergence speed in the later stage of evolution. This improves the balance of population P3 and simultaneously improves the prediction ability of the prediction model.

[0053] (2) The improved differential evolution algorithm proposed in the present invention designs an adaptive F and Cr strategy to improve the optimization performance of ADE. Then, the ADE algorithm is used to obtain the optimal number of hidden layer neurons and learning rate, thereby improving the prediction accuracy of the prediction model.

[0054] (3) The LSTM based on the attention mechanism proposed in the present invention can assign corresponding weights according to the importance of important features of the input sewage. In this way, the ability of the LSTM neural network to learn the importance of sewage data features can be improved, thereby achieving more accurate prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is the multi-population evolution strategy of the present invention;

[0056] Figure 2 is the structure of the attention module of the present invention;

[0057] Figure 3 This is the algorithm flow of DTL-EADE-LSWSVM of the present invention. DETAILED DESCRIPTION

[0058] The embodiments of the present invention are described in further detail below in conjunction with the accompanying drawings.

[0059] The present invention provides a LSTM sewage quality prediction method based on improved DE and attention mechanism, comprising the following steps:

[0060] Step 1: Preprocess the important characteristic data set of the sewage treatment plant. In this embodiment, the characteristic data set includes the current pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and dissolved oxygen historical data at previous moments;

[0061] The outlier processing formula for the data set is as follows:

[0062]

[0063] Where x is the value of the data point; μ is the mean of the data set; σ is the standard deviation of the data set. If the absolute value of Z of a data point exceeds a threshold (usually 2 or 3 are chosen), the data point can be marked as an outlier.

[0064] The missing value processing of the data set is as follows:

[0065] x # =(x f +x b ) / 2

[0066] Among them, x # is the padding value; x f is the data at the previous time point; x b The missing value is filled with the average value of the data at the adjacent time points, so that the filled value reflects the changing trend of the real data to a certain extent.

[0067] The data set is normalized, and the formula is as follows:

[0068]

[0069] where x* is the normalized value; and x maxand x min They are the maximum and minimum values ​​in the data set, respectively. They can help the prediction model better understand and capture the relationship between different features and improve the model's sensitivity to data.

[0070] Step 2: Build and initialize the ATT-LSTM water quality prediction model;

[0071] The ATT-LSTM water quality prediction model is constructed to obtain the initial framework of the ATT-LSTM hybrid model, in which the hybrid model includes two parts, ATT and LSTM. ATT can be simply understood as a weighted sum, which can assign corresponding weights according to the importance of the input features. The calculation formula is as follows:

[0072]

[0073]

[0074]

[0075] Where T is the total time step; h m is the output feature vector of LSTM; α m is the result of the first weighted calculation through the fully connected layer; W l αh and b α are the weight matrix and bias of the fully connected layer respectively; β m is calculated by the softmax activation function and assigned to the corresponding h m The final weight of ; and the vector γ is the important feature extracted. LSTM predicts the water quality time series after feature weighting.

[0076] Step 3: Based on the preprocessed data, ADE is used to optimize the hyperparameters of the ATT-LSTM water quality prediction model to obtain the optimal hyperparameter ADE-ATT-LSTM water quality prediction model.

[0077] S31: The number of hidden layer neurons and the learning rate of the ATT-LSTM model are selected as the optimization parameters of the ADE algorithm, the optimization range of the parameters to be optimized is determined, and the population P is randomly initialized.

[0078] The first step in the initialization of the population P is to generate an initial population X of N×D dimensions in the search space. i,G ={x 1 i,G ,…,x D i,G}, i=1,...,N, G=0,1,...,G max , where N represents the population size, D represents the dimension of the decision vector, and G maxIndicates the maximum number of iterations. In addition, the search upper and lower limits of each dimension in the decision variable are set according to the problem to be optimized, where the search lower limit is defined as X min ={x 1 min ,...,x D min}, the search upper limit is defined as X max ={x 1 max ,...,x D max In order to make the initial population cover the entire search space as much as possible, the individuals in the population are generally initialized uniformly and randomly within the given search upper and lower limits. The expression is as follows:

[0079]

[0080] Here, rand(0,1) represents a random variable uniformly distributed in the range [0,1].

[0081] S32: Calculate the fitness value of each individual in the ADE algorithm:

[0082]

[0083] Among them, p is the number of samples, y p is the true value of the sample, is the predicted value.

[0084] S33: The entire population P is randomly divided into exploration subpopulation P1, development subpopulation P2 and balance subpopulation P3, and the mutation strategy is adaptively selected. How to select the mutation strategy is as follows:

[0085] Subpopulation adaptive selection mutation strategy:

[0086] 1) Explore subpopulation P1

[0087] The exploration subpopulation P1 uses DE / rand / 2 as the mutation strategy. This mutation strategy uses two random difference vectors to interfere with the target individual, which has stronger perturbation and better global search capabilities, and can significantly improve the diversity of the population. The mutation strategy is as follows:

[0088] "DE / rand / 2": V i,G =X r1,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )

[0089] Among them, V i,G is the individual X in the current population i,GGenerate a mutation vector using mutation strategy. r1, r2, r3, r4, r5 represent mutually exclusive integers randomly generated in the range [1, N]. F∈[0,1] is the mutation factor.

[0090] 2) Develop subpopulations

[0091] The development subpopulation P2 uses DE / best / 2 as the mutation strategy. This mutation strategy searches near the optimal individual of the current population, has good local development capabilities, and is conducive to the convergence of the entire population. The mutation strategy is as follows:

[0092] "DE / best / 2": V i,G =X best,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G )

[0093] Among them, X best,G is the individual vector with the best fitness value in the G-th generation population.

[0094] 3) Balanced subpopulation

[0095] For the balanced subpopulation P3, the population that is currently iterating to the Gth generation is divided into an excellent population and a common population according to the size of the individual fitness value. The performance of the algorithm is improved by the cooperation between the excellent population and the common population. The excellent population aims to provide the most promising evolutionary direction, thereby enhancing the local search ability of the algorithm. The common population aims to adjust the search direction to increase the diversity of the population, increase the global search ability, and avoid premature convergence. In the mutation strategy of the improved differential evolution algorithm, X r1,G ,X r2,G ,X r4,G Randomly select from the excellent population, X r3,G and X r5,G Randomly select from the general population. The adaptive mutation strategy is selected as follows:

[0096]

[0097] Among them, the ratio of excellent population size to the total population size is set to 0.4, Q G The probability of being selected in the two mutation strategies in the above formula is calculated as follows:

[0098]

[0099] S34: Entering the mutation phase, executing the corresponding particle mutation method according to the corresponding mutation strategy and the adaptive mutation factor F; the adaptive mutation factor F is generated as follows:

[0100] F=F0·2 λ

[0101]

[0102] Among them, F0 is the initial value of the mutation factor, G is the number of current iterations, and G m is the maximum number of iterations; F decreases from 2F0 to F0. In this way, the global search capability of the algorithm can be enhanced and the search range can be expanded in the early stage of the algorithm, and the convergence speed of the algorithm can be improved in the later stage.

[0103] S35: Enter the mutation phase and execute the corresponding particle mutation method according to the adaptive crossover probability Cr. The adaptive crossover probability Cr of each individual is generated as follows:

[0104]

[0105] Among them, Cr max ,Cr min is the maximum and minimum value given to Cr, f i , f min and f max They represent the fitness of the i-th individual, the average fitness of the population, the fitness of the best individual, and the fitness of the worst individual respectively.

[0106] S36: Calculate the fitness value of the individual, determine the optimal value among the three sub-populations, and merge the three sub-populations;

[0107] S37: Determine whether the algorithm meets the conditions for terminating iterations; if the number of iterations reaches the maximum value, return the optimal hyperparameters of the model; otherwise, repeat S23 until the algorithm meets the termination conditions.

[0108] Step 4: Based on the preprocessed data, a training set and a test set are constructed to train the optimal hyperparameter ADE-ATT-LSTM water quality prediction model.

[0109] It should be noted that to verify whether ADE-ATT-LSTM can be put into practical use, a certain amount of data sets are needed for verification and output of predicted values. The prediction ability of the model is evaluated based on the predicted values ​​and the actual values ​​of the verification samples.

[0110] Step 5: Input the collected data sets, including the current pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and the historical data of dissolved oxygen at previous moments, into the trained ADE-ATT-LSTM water quality prediction model to obtain the DO prediction results. The specific process is as follows:

[0111] S51: Obtain water quality data samples, and perform abnormal, missing and normalization processing in turn;

[0112] S52: Input the processed water quality data sample into the trained ADE-ATT-LSTM water quality prediction model;

[0113] S53: Output the final water quality prediction result through the calculation of the neural network.

[0114] In order to objectively and fairly evaluate the prediction effect of the proposed ADE-ATT-LSTM model, the root mean square error (RMSE), mean absolute error (MAE), mean percentage error (MAPE) and determination coefficient (R 2 ) as the evaluation indicator. The relevant formula is as follows:

[0115]

[0116]

[0117]

[0118]

[0119] Where N is the number of samples, y n is the true value, is the average of the true values, is the predicted value of the model.

[0120] The performance indicators of all models are shown in Table 1.

[0121] Table 1 Evaluation index results of each classification model

[0122]

[0123] The model of the present invention is compared with LSTM, ATT-LSTM, PSO-LSTM, DE-LSTM and DE-ATT-LSTM. It can be seen from Table 1 that compared with other algorithms, the R 2 , RMSE, MAPE and MAE are all optimal. Compared with the standard LSTM, DE-ATT-LSTM has been improved in all four indicators. Compared with DE-LSSVM, after integrating the attention mechanism and adaptive DE, the classification performance of ADE-ATT-LSSVM has been greatly improved, which can effectively solve the problem of sewage quality prediction.

[0124] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent transformation or modification made according to the spirit of the present invention should be included in the protection scope of the present invention.

Claims

1. A LSTM sewage quality prediction method based on improved DE and attention mechanism, characterized in that: The steps include: Step 1: Preprocess the important characteristic data set of the sewage treatment plant, which includes the current pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and dissolved oxygen DO historical data at previous moments; Step 2: Construct and initialize the ATT-LSTM water quality prediction model, which is a long short-term memory LSTM neural network model based on the attention mechanism ATT; Step 3: Based on the preprocessed data, the hyperparameters of the ATT-LSTM water quality prediction model are optimized using the improved differential evolution algorithm ADE to obtain the optimal hyperparameter ADE-ATT-LSTM water quality prediction model; S31: The number of hidden layer neurons and learning rate of the ATT-LSTM water quality prediction model are selected as the optimization parameters of the ADE algorithm, the optimization range of the parameters to be optimized is determined, and the population P is randomly initialized; S32: Calculate the fitness value of each individual in the ADE algorithm: Among them, p is the number of samples, y p is the true value of the sample, is the predicted value; S33: The entire population P is randomly divided into an exploration subpopulation P1, an exploitation subpopulation P2 and a balance subpopulation P3, and a mutation strategy is adaptively selected; 1) Explore subpopulation P1 The exploration subpopulation P1 uses DE / rand / 2 as the mutation strategy; two random difference vectors are used to interfere with the target individual. The mutation strategy is as follows: "DE / row / 2": V i,G =X r1,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G ) Among them, V i,G is the individual X in the current population i,G Generate a mutation vector using the mutation strategy, where r1, r2, r3, r4, and r5 represent mutually exclusive integers randomly generated in the range [1, N], and F∈[0,1] is the mutation factor; 2) Development of subpopulation P2 The development subpopulation P2 uses DE / best / 2 as the mutation strategy and searches near the optimal individual of the current population. The mutation strategy is as follows: "DE / best / 2”:V i,G =X best,G +F×(X r2,G -X r3,G )+F×(X r4,G -X r5,G ) Among them, X best,G is the individual vector with the best fitness value in the G-th generation population; 3) Balanced subpopulation P3 For the balanced subpopulation P3, the population that is currently iterated to the Gth generation is divided into an excellent population and a common population according to the size of the individual fitness value. In the mutation strategy of the improved differential evolution algorithm, X r1,G ,X r2,G ,X r4,G Randomly select from the excellent population, X r3,G and X r5,G Randomly selected from the general population, the adaptive mutation strategy is selected as follows: Among them, the ratio of excellent population size to the total population size is set to 0.4, Q G The probability of being selected in the two mutation strategies in the above formula is calculated as follows: S34: Entering the mutation phase, executing the corresponding particle mutation method according to the corresponding mutation strategy and the adaptive mutation factor F; S35: Entering the mutation phase, executing the corresponding particle mutation method according to the adaptive crossover probability Cr; S36: Calculate the fitness value of the individual, determine the optimal value among the three sub-populations, and merge the three sub-populations; S37: Determine whether the condition for terminating iteration is met; if the number of iterations reaches the maximum value, return the optimal hyperparameters of the model; otherwise, repeat S33 until the termination condition is met; Step 4: Based on the preprocessed data, a training set and a test set are constructed to train the optimal hyperparameter ADE-ATT-LSTM water quality prediction model; Step 5: Input the collected data sets, including the current pH, conductivity, water temperature, turbidity, potassium permanganate, total phosphorus, ammonia nitrogen, total nitrogen and the historical data of dissolved oxygen at previous moments, into the trained ADE-ATT-LSTM water quality prediction model to obtain the future DO value prediction results.

2. The LSTM sewage quality prediction method with improved DE and attention mechanism according to claim 1 is characterized in that: The step of preprocessing the data set in step 1 includes: S11: Outlier processing: First, the eigenvalues ​​are subjected to descriptive statistics to check for unreasonable data and whether the data obeys a normal distribution. When the sample is greater than 3 standard deviations from the mean, the sample is identified as an outlier and deleted from the data set. S12: Missing value processing: index the data with missing values ​​in the data set, and fill the indexed missing values ​​according to the data at the previous time point and the next time point; S13: Normalization processing: Map data of different scales and ranges into a unified range to eliminate dimensional differences between different features.

3. The LSTM sewage quality prediction method with improved DE and attention mechanism according to claim 1 is characterized in that: The attention mechanism in step 2 assigns corresponding weights according to the importance of the input features. The calculation formula is as follows: Where T is the total time step; h m is the output feature vector of LSTM; α m is the result of the first weighted calculation through the fully connected layer; W l αh and b α are the weight matrix and bias of the fully connected layer respectively; β m is calculated by the softmax activation function and assigned to the corresponding h m The final weight of ; and the vector γ is the important feature extracted.

4. The LSTM sewage quality prediction method with improved DE and attention mechanism according to claim 1 is characterized in that: In S34, the mutation phase is entered, and a corresponding particle mutation method is executed according to a corresponding mutation strategy and an adaptive mutation factor F. The adaptive mutation factor F is generated as follows: F=F0·2 λ Among them, F0 is the initial value of the mutation factor, G is the number of current iterations, and G m is the maximum number of iterations; F decreases from 2F0 to F0.

5. The LSTM sewage quality prediction method with improved DE and attention mechanism according to claim 1 is characterized in that: The adaptive crossover probability Cr of each individual in S35 is generated as follows: Among them, Cr max ,Cr min is the maximum and minimum value given to Cr, and f max They represent the fitness of the i-th individual, the average fitness of the population, the fitness of the best individual, and the fitness of the worst individual respectively.

Citation Information

Patent Citations

  • A short-term network traffic prediction method for optimizing a wavelet neural network based on an adaptive differential evolution algorithm

    CN109818775A

  • Sewage quality prediction method based on optimized LSTM neural network

    CN112884056A

  • Discrete differential evolution-based multi-strategy optimization x-architecture minimum tree construction method

    WO2021218157A1

Cited By

  • Method for predicting water quality of industrial wastewater

    CN121963944A