Water quality prediction method based on LocalRNN enhancement
By introducing a LocalRNN enhancement module, the water quality prediction model (LG-Forecaster) solves the problem of insufficient capture of local time dependencies in water quality prediction, achieves high-precision prediction of water quality characteristics, and improves the accuracy and reliability of water quality monitoring and management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2026-03-24
AI Technical Summary
Existing water quality prediction methods are not very effective in capturing local time-dependent relationships, especially in predicting water quality characteristics with low accuracy, resulting in low prediction precision and weak generalization ability.
A water quality prediction model based on LocalRNN enhancement (LG-Forecaster) is adopted. The LocalRNN enhancement module captures local dependencies in time series data, and combined with the global modeling capability of the Informer model, feature embedding, encoder and decoder modules are constructed to improve the model's ability to perceive short-term change patterns and long-term dependencies.
It significantly improves the accuracy of dissolved oxygen content prediction and the generalization ability of the model, effectively handles long-term dependencies and short-term variation patterns in water quality data, and provides reliable support for water quality monitoring and management.
Smart Images

Figure CN121725928A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of artificial intelligence and water quality monitoring, and specifically relates to a water quality prediction method based on LocalRNN enhancement, mainly used for predicting the dissolved oxygen content in water. BACKGROUND
[0002] Water quality prediction is an important part of environmental monitoring and water resource management. Dissolved oxygen is one of the key indicators of water quality, which directly affects the survival of aquatic organisms and the health of the water ecosystem. Traditional water quality prediction methods mainly rely on physical and chemical models and statistical methods, which often have low accuracy and weak generalization ability when dealing with complex water quality data.
[0003] In recent years, deep learning technology has made significant progress in time series prediction. Among them, the Informer model, as a high-efficiency Transformer variant, has shown excellent performance in long sequence time series prediction tasks and has been widely applied to various time series prediction scenarios. In the field of water quality prediction, researchers have also begun to use the Informer model for prediction analysis of water quality parameters. However, in the specific scenario of water quality prediction, the original Informer model has poor performance in capturing local temporal dependencies, especially in the prediction of some water quality characteristics.
[0004] Therefore, based on the Informer architecture, the LocalRNN (Local Recurrent Neural Network) mechanism is introduced to enhance the model's ability to capture local temporal features, thereby improving the accuracy of water quality prediction. The model analyzes multi-dimensional water quality data such as time, temperature, pH, oxygen content, turbidity, and conductivity to achieve accurate prediction of dissolved oxygen content in water. SUMMARY
[0005] The purpose of the present application is to solve the problem of low accuracy and short prediction period of existing water quality prediction methods, and to provide a water quality prediction method based on LocalRNN enhancement. Through the design of the LocalRNN-enhanced water quality prediction model (LG-Forecaster), the accuracy and reliability of water quality prediction are improved.
[0006] To achieve the above purpose, the present application adopts the following technical solutions:
[0007] A water quality prediction method based on LocalRNN enhancement, comprising the following steps:
[0008] Step 1, pre-process the original water quality data, including data cleaning, standardization, and feature engineering processing.
[0009] Step 2, constructing a water quality prediction model based on LocalRNN enhancement, including a feature embedding module, a LocalRNN enhancement module, an encoder module, a decoder module, and a prediction output module.
[0010] Step 3, inputting the preprocessed multi-dimensional water quality data into the feature embedding module to generate high-dimensional feature representations containing token information, position information, and time information; then using the LocalRNN enhancement module for feature enhancement, capturing local dependencies in time series through recurrent neural networks to enhance the model's ability to perceive short-term change patterns.
[0011] Step 4, inputting the enhanced high-dimensional feature representations into the encoder module to extract key time series features through the Informer's unique probabilistic sparse attention mechanism, achieving efficient modeling of long-term dependencies. The encoder module uses a multi-layer encoder layer stacking structure, each layer containing a probabilistic sparse attention layer and a feedforward neural network layer, inheriting the Informer's global time series feature extraction capability.
[0012] Step 5, inputting the features output by the encoder into the decoder module to generate prediction features through the masked multi-head self-attention mechanism. The decoder module uses a hierarchical structure corresponding to the encoder module, each layer containing a multi-head self-attention layer, a multi-head cross-attention layer, and a feedforward neural network layer.
[0013] Step 6, converting the prediction features into the final water quality parameter prediction values through the prediction output module.
[0014] Further, the preprocessing operations are as follows: first, clean the original water quality data, remove abnormal data, and handle missing values; then standardize the water quality parameters in the processed data and extract time features through feature engineering to construct a time label vector. The water quality parameters include time, temperature, pH, oxygen content, turbidity, and conductivity
[0015] Further, the feature embedding module uses a combination of token embedding, position embedding, and time embedding to convert input data into high-dimensional feature representations containing token information, position information, and time information.
[0016] Further, the LocalRNN enhancement module supports three types of recurrent neural networks: LSTM, GRU, and RNN, which perform feature enhancement on the obtained high-dimensional feature representations through a sliding window approach, with the window size configurable according to requirements.
[0017] Further, the prediction output module maps the prediction features output by the decoder module to the prediction value of dissolved oxygen content through a linear projection layer.
[0018] Further, the method further comprises end-to-end training the water quality prediction model based on LocalRNN enhancement, adopting mean square error (MSE) as a loss function, and updating parameters through an Adam optimizer.
[0019] The present application has the following advantages:
[0020] The present application provides a water quality prediction model based on LocalRNN enhancement (LG-Forecaster) with high precision, which combines the local feature capturing ability of LocalRNN and the global modeling ability of Informer, significantly improves the accuracy of dissolved oxygen content prediction compared to traditional Informer model, effectively handles long-term dependence and short-term change patterns in water quality data, and has good generalization ability and robustness in practical application, providing reliable technical support for water quality monitoring and management. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 Figure 1 is a schematic diagram of the overall architecture of the water quality prediction model based on LocalRNN enhancement (LG-Forecaster).
[0022] Figure 2 Figure 2 is a workflow diagram of the LocalRNN module.
[0023] DETAILED DESCRIPTION
[0024] In order to more specifically describe the present application, the technical solutions of the present application will be described in detail below in combination with the drawings and specific embodiments.
[0025] A water quality prediction method based on LocalRNN enhancement, comprising the following steps:
[0026] Step 1, pre-processing the original water quality data, including data cleaning, standardization and feature engineering processing.
[0027] Step 2, constructing a water quality prediction model based on LocalRNN enhancement, including a feature embedding module, a LocalRNN enhancement module, an encoder module, a decoder module and a prediction output module.
[0028] Step 3, inputting the pre-processed multi-dimensional water quality data into the feature embedding module to generate high-dimensional feature representation containing token information, position information and time information; then using the LocalRNN enhancement module for feature enhancement, capturing the local dependence relationship in the time series through the recurrent neural network, and enhancing the model's ability to perceive short-term change patterns.
[0029] Step 4, the enhanced high-dimensional feature representation is input into the encoder module, and the key time sequence features are extracted through the probability sparse attention mechanism unique to the Informer, so as to realize efficient modeling of long-term dependencies. The encoder module adopts a multi-layer encoder layer stacking structure, each layer containing a probability sparse attention layer and a feedforward neural network layer, inheriting the global time sequence feature extraction capability of the Informer.
[0030] Step 5, the features output by the encoder are input into the decoder module, and the predicted features are generated through the masked multi-head self-attention mechanism. The decoder module adopts a hierarchical structure corresponding to the encoder module, each layer containing a multi-head self-attention layer, a multi-head cross-attention layer and a feedforward neural network layer.
[0031] Step 6, the predicted features are converted into the final water quality parameter prediction value through the prediction output module.
[0032] In a possible implementation, the preprocessing specific steps are as follows:
[0033] 1-1, data cleaning is performed on the original water quality data, and abnormal data is removed and missing value processing is performed, and the linear interpolation method is used to fill the missing data.
[0034] 1-2, the processed data is divided into a training set and a validation set, and the ratio is 8:2.
[0035] 1-3, the numerical features of the water quality parameters including time and temperature, pH, oxygen content, turbidity and conductivity in the training set are subjected to Z-score standardization processing.
[0036] 1-4, time features are extracted from the standardized data through feature engineering processing, and a time label vector is constructed.
[0037] In a possible implementation, the feature embedding module is implemented as follows:
[0038] 2-1-1, the word embedding uses a one-dimensional convolutional layer to map the input features to a feature space, the convolution kernel size is 3, and a cyclic padding method is used to obtain the word feature representation.
[0039] 2-1-2, the position embedding adopts a trigonometric function absolute position encoding method to generate a unique position encoding for each position in the input feature, and obtains the position feature representation.
[0040] 2-1-3, the time embedding maps the time label vector to a feature vector, and obtains the time feature representation.
[0041] 2-1-4. Add the lexical feature representation, positional feature representation, and temporal feature representation together, and perform regularization processing through a random deactivation layer to obtain a high-dimensional feature representation containing lexical information, positional information, and temporal information.
[0042] In one possible implementation, the LocalRNN enhancement module's specific workflow is as follows:
[0043] 2-2-1. Divide the high-dimensional feature representation output by the feature embedding module into blocks according to the sliding window size, and zero-padded for data blocks that are not large enough.
[0044] 2-2-2. Apply the selected recurrent neural network type (LSTM / GRU / RNN) to each data block to extract local temporal features.
[0045] 2-2-3. Concatenate the outputs of all data blocks to restore the original sequence length.
[0046] 2-2-4. Finally, regularization is performed through a random deactivation layer to prevent overfitting and obtain a high-dimensional feature representation after feature enhancement.
[0047] In one possible implementation, the encoder encoding is specifically implemented as follows:
[0048] 3-1. The encoder module consists of multiple encoder layers, each containing a probabilistic sparse attention layer and a feedforward neural network layer. This multi-layered stacked structure enables the model to capture features at different time scales, with shallower networks focusing on short-term local changes and deeper networks extracting long-term dependencies.
[0049] 3-2. The probabilistic sparse attention layer is implemented through a probabilistic sparse attention mechanism, which employs a logarithmic sampling strategy to select important query-key pairs. Specifically, the input of the encoder layer is first mapped to query vectors, key vectors, and value vectors, respectively. The dot product of the query vector and all key vectors is calculated to obtain the QK similarity score matrix. Then, the top k most important query-key pairs are selected from the QK similarity score matrix using a sparse metric M, where M is defined as the difference between the maximum and average QK similarity scores. The probabilistic sparse attention mechanism uses this metric to evaluate the importance of query-key pairs, and through a sampling strategy, it selects the most representative temporal dependencies, paying particular attention to key inflection points and periodic patterns in water quality parameter changes, thus achieving efficient processing of long sequences.
[0050] 3-3. The feedforward neural network layer takes the feature representations corresponding to the k key query-key pairs output by the previous probabilistic sparse attention layer as input, and includes two one-dimensional convolutional layers: the first convolutional layer expands the input dimension from d_model to d_ff, where d_ff is typically set to 4*d_model; the second convolutional layer restores the dimension to d_model. A ReLU activation function is used between the two convolutional layers, and a cyclic padding pattern is used to enhance feature extraction capabilities, thereby effectively modeling the nonlinear relationships between input features. Finally, the output is a high-dimensional feature representation after nonlinear transformation.
[0051] 3-4. In the encoder layer, the components are connected in the following order: First, the output of the probabilistic sparse attention layer is residually connected to the input of the encoder layer, and layer normalization is performed on the connection result. Then, the layer normalization result is input into the feedforward neural network layer, and the output of the feedforward neural network layer is again residually connected to the layer normalization result. Finally, layer normalization is performed again on the residual connection result to obtain the output of the current encoder layer. This design of multiple residual connections and layer normalizations ensures the preservation and enhancement of key features during multi-layer propagation, improves the model's sensitivity to abnormal changes and trend reversals in water quality parameters, effectively improves model training stability, and prevents gradient vanishing.
[0052] 3-5. The encoder module processes the original input sequence step by step through multiple encoder layers, transforming it into a high-dimensional representation containing multi-level temporal features. The output of each layer serves as the input for the next layer. Ultimately, the high-dimensional feature representation output by the encoder module integrates key temporal patterns from local to global perspectives, providing a robust feature foundation for the subsequent decoding process.
[0053] In one possible implementation, the decoder decodes as follows:
[0054] 4-1. The decoder module consists of multiple decoder layers, each containing a multi-head self-attention layer, a multi-head cross-attention layer, and a feedforward neural network layer. This multi-layered stacked structure allows the model to progressively refine predicted features. Shallow networks primarily focus on basic pattern recognition, while deep networks are responsible for extracting and integrating complex features, thus achieving hierarchical modeling of features from simple to complex.
[0055] 4-2. The multi-head self-attention layer takes the input of the decoder layer as its input and performs autocorrelation analysis on the input sequence through a masked full attention mechanism to extract short-term dependencies within the prediction sequence. This mechanism focuses only on itself and its preceding positions at each location, effectively preventing the leakage of future information and thus providing basic temporal context information for the recent trends in water quality parameters. The output of the multi-head self-attention layer is the feature representation after autocorrelation analysis.
[0056] 4-3. The multi-head cross-attention layer uses the output of the previous multi-head self-attention layer as the query vector and interacts with the key and value vectors output by the encoder layer corresponding to its layer number (i.e., the i-th decoder layer corresponds to the i-th encoder layer), achieving effective fusion of encoder and decoder features. The multi-head cross-attention layer fully computes the attention matrix between the decoder query and the encoder key-value pairs, fusing the long-term temporal features extracted by the encoder into the decoding process, completing the feature mapping from historical information to future predictions. This is a crucial step in generating predictive features.
[0057] 4-4. To ensure the causality of the aforementioned attention mechanism, the decoder module employs a causal masking mechanism, which is applied to both the multi-head self-attention layer and the multi-head cross-attention layer. In the multi-head self-attention layer, the causal masking masks future information by constructing an upper triangular matrix. Specifically, a Boolean mask matrix is first generated, and the attention score of the masked position is set to negative infinity. After passing through a linear regression function, the weights approach zero, ensuring that each position can only access information from itself and its previous positions. In the multi-head cross-attention layer, the masking restricts the decoder query to interact only with all historical key-value pairs of the encoder, enabling the decoder to fully utilize the long-term historical features extracted by the encoder while maintaining the autoregressive nature of the decoding process. Through this design, the prediction process is ensured to be strictly based on known historical information, guaranteeing the causality and effectiveness of the prediction, and laying the foundation for feature extraction in the subsequent feedforward neural network layer.
[0058] 4-5. The feedforward neural network layer takes the output of the multi-head cross-attention layer as input and performs a nonlinear transformation on it to extract higher-level feature representations, enhancing the model's ability to model complex water quality patterns. The feedforward neural network layer includes two one-dimensional convolutional layers with a ReLU activation function in between, and enhances feature transfer capability through residual connections and layer normalization operations. This structure effectively improves the model's ability to model complex water quality change patterns and enhances the accuracy of predicting abnormal changes and trend reversals.
[0059] 4-6. The decoder module processes the key temporal features output by the encoder with the decoder input through multiple decoder layers, gradually fusing and refining them. Each decoder layer is processed sequentially by a multi-head self-attention layer, a multi-head cross-attention layer, and a feedforward neural network layer, and gradient stability and feature enhancement are maintained through residual connections and layer normalization. Finally, the decoder module outputs a high-dimensional feature vector, which, after linear transformation, generates a predicted sequence of future water quality parameters.
[0060] Furthermore, the number of layers, hidden units, attention heads, and activation functions of the encoder and decoder modules are configured according to task requirements.
[0061] In one possible implementation, the prediction output module is specifically implemented as follows:
[0062] 5-1. First, determine the prediction step size, which directly affects the length of the decoder output sequence and the design of the linear projection layer dimension. After determining the prediction step size, the predicted features output by the decoder module are mapped to the prediction space through the corresponding dimension of the linear projection layer to obtain the prediction result. The number of output channels c_out of the linear projection layer is determined according to different prediction modes: specifically, c_out represents the number of water quality parameters predicted by the model at each time step. In the multivariate-to-multivariate prediction mode, c_out is equal to the number of output features, and in the multivariate-to-univariate and univariate-to-univariate prediction modes, c_out is equal to 1.
[0063] 5-2. Users can choose prediction strategies according to different application needs:
[0064] Single-step prediction strategy: Predicts only the water quality parameter value at the next time point. This strategy is suitable for real-time monitoring scenarios, such as water quality anomaly early warning systems, which require rapid response to water quality changes. Under this strategy, the decoder output length is 1, therefore the input dimension of the linear projection layer is d_model×1, and the output dimension is 1×c_out.
[0065] Multi-step prediction strategy: Predicts water quality parameter values for multiple consecutive future time points in a single step. This strategy is suitable for medium- to long-term water quality planning and management, such as predicting water quality trends over the next 24 hours or week. Under this strategy, the decoder output length is equal to the preset prediction step size n, therefore the input dimension of the linear projection layer is d_model×n, and the output dimension is n×c_out.
[0066] Recursive multi-step prediction strategy: This strategy employs a rolling prediction approach, predicting only one time point at a time and using the prediction result as the input for the next step, repeating this process until the target prediction length is reached. This strategy is particularly suitable for long-sequence prediction scenarios, such as seasonal water quality change analysis, and can effectively balance prediction accuracy and computational efficiency. Under this strategy, the decoder output length is 1 in each iteration; therefore, the input dimension of the linear projection layer is fixed at d_model × 1, and the output dimension is 1 × c_out.
[0067] Strategy selection criteria: Single-step prediction is preferred for scenarios with high real-time requirements; multi-step prediction is suitable for scenarios with sufficient computing resources and the need for batch prediction; recursive multi-step prediction is suitable for scenarios with very long sequence prediction or limited computing resources. The selection of different strategies should comprehensively consider prediction accuracy requirements, computing resource limitations, and application scenario characteristics.
[0068] 5-3. Perform reverse normalization on the prediction results obtained based on the selected prediction strategy to restore them to the original numerical range. The specific process of reverse normalization is as follows: multiply the standardized prediction result by the standard deviation of the original data and add the mean to obtain the predicted value of the water quality parameter with actual physical meaning.
[0069] Single-step prediction strategy: Inverse normalization processes the standard deviation multiplication and mean addition operations on a single predicted value.
[0070] Multi-step prediction strategy: Reverse normalization processes n predicted values in batches, performing standard deviation multiplication and mean addition operations to restore n water quality parameter values with actual physical meaning.
[0071] Recursive multi-step prediction strategy: Inverse normalization processes only a single prediction value each time, and repeats this process n times to build a complete long-term prediction sequence.
[0072] In one possible implementation, the water quality prediction method supports three different prediction modes:
[0073] Multivariate-to-multivariate prediction mode: In this mode, the water quality prediction model simultaneously inputs multiple water quality parameters (including temperature, pH, oxygen content, turbidity, and conductivity) and outputs predicted values for multiple water quality parameters. The specific implementation process is as follows: First, the encoder module receives multiple input features and extracts the interdependencies between parameters through a probabilistic sparse attention mechanism; then, the decoder module generates multidimensional prediction features based on the features output by the encoder through multi-head self-attention and cross-attention mechanisms; finally, the prediction output module maps the multidimensional prediction features to a multidimensional output space (c_out equals the number of output features) through a linear projection layer and obtains the prediction results for multiple water quality features through inverse normalization. This mode fully utilizes the correlation between water quality features, improving the overall prediction accuracy.
[0074] Multivariate to Univariate Prediction Mode: In this mode, the water quality prediction model takes multiple water quality parameters as input (including temperature, pH, oxygen content, turbidity, and conductivity), but outputs only the predicted value of a single target parameter (such as dissolved oxygen content). The specific implementation process is as follows: the encoder receives multiple input features and extracts the interdependencies between them; the decoder generates predicted features for the target parameter based on the features output by the encoder; finally, the prediction output module maps the predicted features to a one-dimensional output space (c_out equals 1) through a linear projection layer and obtains the prediction result for a single water quality parameter through inverse normalization. This mode improves the prediction accuracy of the target parameter by using multi-feature information to assist in the prediction of a single target feature.
[0075] Univariate-to-univariate prediction mode: In this mode, the water quality prediction model only takes historical data of the target parameter as input and outputs the predicted value of that parameter. The specific implementation process is as follows: the encoder receives a single input feature and extracts its temporal features; the decoder generates the predicted features of the parameter based on the features output by the encoder; finally, the prediction output module maps the predicted features to a one-dimensional output space (c_out equals 1) through a linear projection layer and obtains the prediction result of the parameter through inverse normalization. This mode is suitable for situations where only historical features of a single parameter are available.
[0076] To verify the effectiveness of the technical solution of this invention, we conducted a comparative experiment, testing the performance of the LG-Forecaster model proposed in this invention and the original Informer model on the same dataset. The experiment used the following five commonly used evaluation metrics for evaluation: root mean square error (RMSE), mean absolute error (MAE), coefficient of determination (R²), mean absolute percentage error (MAPE), and mean square error (MSE).
[0077] The experimental results are shown in the table below:
[0078] Evaluation metrics Informer LG-Forecaster (the present method) RMSE 0.294455667 0.232561429 MAE 0.229238333 0.172289739 R² 0.788062667 0.867959147 MSE 0.086861333 0.054116226
[0079] The experimental results show that the LG-Forecaster model proposed in this invention exhibits significant advantages in all evaluation metrics:
[0080] 1. In terms of RMSE, this method reduces it by 21.0% compared to Informer, indicating a significant reduction in prediction error;
[0081] 2. In terms of the MAE metric, this method reduced it by 24.8% compared to Informer, indicating a significant reduction in the average prediction error;
[0082] 3. In terms of R², our method achieved 0.867959147, which is 10.1% higher than Informer, indicating that the model has a stronger ability to interpret the data;
[0083] 4. In terms of the MSE metric, this method reduced it by 37.7% compared to Informer, further validating the significant improvement in prediction accuracy;
[0084] 5. Regarding the MAPE index, both methods show similar performance, with this method showing a slight increase but the difference is not significant.
[0085] Experimental results fully demonstrate that by introducing a LocalRNN enhancement module, the LG-Forecaster model proposed in this invention can effectively capture local dependencies in water quality time series, complementing the global modeling capabilities of Informer, thereby significantly improving the accuracy and reliability of water quality prediction. Particularly in processing short-term change patterns and long-term dependencies in water quality data, this method exhibits significant advantages, providing more precise technical support for practical water quality monitoring and management.
[0086] The above description of the embodiments is provided to enable those skilled in the art to understand and apply the present invention. It will be apparent to those skilled in the art that various modifications can be made to the above embodiments, and the general principles described herein can be applied to other embodiments without inventive effort. Therefore, the present invention is not limited to the above embodiments, and any improvements and modifications made to the present invention by those skilled in the art based on the disclosure thereof should be within the scope of protection of the present invention.
Claims
1. A water quality prediction method based on LocalRNN enhancement, characterized in that, The steps include the following: Step 1: Preprocess the raw water quality data, including data cleaning, standardization, and feature engineering. Step 2: Construct a water quality prediction model based on LocalRNN enhancement, including a feature embedding module, a LocalRNN enhancement module, an encoder module, a decoder module, and a prediction output module; Step 3: Input the preprocessed multidimensional water quality data into the feature embedding module to generate a high-dimensional feature representation containing word information, location information and time information; then use the LocalRNN enhancement module to enhance the features, and capture the local dependencies in the time series through the recurrent neural network to enhance the model's ability to perceive short-term change patterns. Step 4: Input the enhanced high-dimensional feature representation into the encoder module, and extract key temporal features through the Informer's unique probabilistic sparse attention mechanism to achieve efficient modeling of long-term dependencies; the encoder module adopts a multi-layer encoder layer stacked structure, each layer containing a probabilistic sparse attention layer and a feedforward neural network layer; Step 5: Input the features output by the encoder into the decoder module, and generate predicted features through the masked multi-head self-attention mechanism; The decoder module adopts a hierarchical structure corresponding to the encoder module, with each layer containing a multi-head self-attention layer, a multi-head cross-attention layer, and a feedforward neural network layer. Step 6: Convert the predicted features into the final predicted water quality parameters through the prediction output module.
2. The water quality prediction method based on LocalRNN enhancement according to claim 1, characterized in that, The specific preprocessing operations are as follows: First, the original water quality data is cleaned to remove abnormal data and handle missing values. Then, the water quality parameters in the processed data are standardized, and time features are extracted through feature engineering to construct a time stamp vector. The water quality parameters include time, temperature, pH, oxygen content, turbidity, and conductivity.
3. The water quality prediction method based on LocalRNN enhancement according to claim 1, characterized in that, The feature embedding module uses a combination of lexical embedding, positional embedding, and temporal embedding to convert the input data into a high-dimensional feature representation that includes lexical information, positional information, and temporal information.
4. The water quality prediction method based on LocalRNN enhancement according to claim 1, characterized in that, The LocalRNN enhancement module supports three types of recurrent neural networks: LSTM, GRU, and RNN. It enhances the high-dimensional feature representations obtained through a sliding window approach, with the window size configurable according to requirements.
5. The water quality prediction method based on LocalRNN enhancement according to claim 1, characterized in that, The prediction output module maps the predicted features output by the decoder module to the predicted value of dissolved oxygen content through a linear projection layer.
6. The water quality prediction method based on LocalRNN enhancement according to claim 1, characterized in that, The method also includes end-to-end training of the water quality prediction model based on LocalRNN enhancement, using mean squared error as the loss function, and updating parameters through the Adam optimizer.
7. The water quality prediction method based on LocalRNN enhancement according to claim 3, characterized in that, The feature embedding module is implemented as follows: 2-1-1. Lexical embedding uses a one-dimensional convolutional layer to map the input features to the feature space. The convolutional kernel size is 3, and a cyclic padding method is used to obtain the lexical feature representation. 2-1-2. The location embedding adopts the trigonometric function absolute location encoding method to generate a unique location code for each location in the input feature, thereby obtaining the location feature representation; 2-1-3. Temporal embedding maps time-stamped vectors to feature vectors, resulting in temporal feature representations. 2-1-4. Add the lexical feature representation, positional feature representation, and temporal feature representation together, and perform regularization processing through a random deactivation layer to obtain a high-dimensional feature representation containing lexical information, positional information, and temporal information.
8. The water quality prediction method based on LocalRNN enhancement according to claim 4, characterized in that, The specific workflow of the LocalRNN enhancement module is as follows: 2-2-1. Divide the high-dimensional feature representation output by the feature embedding module into blocks according to the sliding window size, and zero-padded for data blocks that are not large enough. 2-2-2. Apply the selected recurrent neural network type to each data block to extract local temporal features; 2-2-3. Concatenate the outputs of all data blocks to restore the original sequence length; 2-2-4. Finally, regularization is performed through a random deactivation layer to prevent overfitting and obtain a high-dimensional feature representation after feature enhancement.
9. The water quality prediction method based on LocalRNN enhancement according to claim 5, characterized in that, The prediction output module is implemented as follows: 5-1. First, determine the prediction step size. Map the predicted features output by the decoder module to the prediction space through a linear projection layer of the corresponding dimension to obtain the prediction result. The number of output channels c_out of the linear projection layer is determined according to different prediction modes. 5-2. Select a forecasting strategy based on requirements: Single-step prediction strategy: Predict only the water quality parameter value at the next time point; under this strategy, the decoder output length is 1, so the input dimension of the linear projection layer is d_model×1, and the output dimension is 1×c_out; Multi-step prediction strategy: Predict water quality parameter values at multiple consecutive time points in the future at once; under this strategy, the decoder output length is equal to the preset prediction step size n, so the input dimension of the linear projection layer is d_model×n, and the output dimension is n×c_out; Recursive multi-step prediction strategy: A rolling prediction method is adopted, which predicts only one time point at a time and uses the prediction result as the input for the next step. This process is repeated until the target prediction length is reached. Under this strategy, the output length of the decoder is 1 in each iteration. Therefore, the input dimension of the linear projection layer is fixed at d_model×1 and the output dimension is 1×c_out. 5-3. Perform reverse normalization on the prediction results obtained based on the selected prediction strategy to restore them to the original numerical range. The specific process of reverse normalization is as follows: multiply the standardized prediction results by the standard deviation of the original data and add the mean to obtain the predicted values of water quality parameters with actual physical meaning. Single-step prediction strategy: Inverse normalization performs standard deviation multiplication and mean addition operations on a single predicted value; Multi-step prediction strategy: Reverse normalization processes n predicted values in batches, performing standard deviation multiplication and mean addition operations to restore n water quality parameter values with actual physical meaning; Recursive multi-step prediction strategy: Inverse normalization processes only a single prediction value each time, and repeats this process n times to build a complete long-term prediction sequence.
10. The water quality prediction method based on LocalRNN enhancement according to claim 9, characterized in that, Water quality prediction methods support three different prediction models: Multivariate-to-multivariate prediction mode: In this mode, the water quality prediction model simultaneously inputs multiple water quality parameters and outputs predicted values for multiple water quality parameters. The specific implementation process is as follows: First, the encoder module receives multiple input features and extracts the interdependencies between the parameters through a probabilistic sparse attention mechanism; then, the decoder module generates multidimensional prediction features based on the features output by the encoder through multi-head self-attention and cross-attention mechanisms; finally, the prediction output module maps the multidimensional prediction features to the multidimensional output space through a linear projection layer and obtains the prediction results of multiple water quality features through inverse normalization processing. Multivariate to Univariate Prediction Mode: In this mode, the water quality prediction model takes multiple water quality parameters as input, but outputs only the predicted value of a single target parameter. The specific implementation process is as follows: the encoder receives multiple input features and extracts the interdependencies between the features; the decoder generates prediction features for the target parameter based on the features output by the encoder; finally, the prediction output module maps the prediction features to a one-dimensional output space through a linear projection layer, and obtains the prediction result of a single water quality parameter through inverse normalization. Univariate-to-univariate prediction mode: In this mode, the water quality prediction model only takes historical data of the target parameter as input and outputs the predicted value of the parameter; the specific implementation process is as follows: the encoder receives a single input feature and extracts its time series features; The decoder generates predicted features for the parameter based on the features output by the encoder. Finally, the prediction output module maps the predicted features to a one-dimensional output space through a linear projection layer and obtains the prediction result of the parameter through inverse normalization.