Method and system for predicting water quality migration across river basins based on TCN

By using a TCN-based Seq2Seq model, training with source domain data and optimizing the input window length by combining target domain autocorrelation, the computational complexity and generalization ability issues of cross-basin water quality prediction are solved, achieving efficient cross-basin water quality data prediction.

CN121598024BActive Publication Date: 2026-04-07SHANDONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-01-28
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

When traditional water quality prediction models are applied across watersheds, it is necessary to re-measure the topography and the migration patterns of pollutants, resulting in high computational complexity and reduced generalization ability. Machine learning models have insufficient generalization ability in watersheds with scarce data, making it difficult to achieve regional applicability.

Method used

A Seq2Seq model based on TCN is adopted, which is trained through an encoder-decoder structure. The model weight parameters are solidified using source domain data, and the zero-retraining transfer potential is judged before the transfer. The input window length is dynamically optimized by combining the autocorrelation of the target domain historical window, so as to realize cross-basin water quality data prediction.

Benefits of technology

It improves the deployment efficiency and regional applicability of cross-basin water quality prediction, reduces the risk of ineffective migration, realizes adaptive learning and closed-loop decision-making, and enhances the generalization ability of the prediction model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121598024B_ABST
    Figure CN121598024B_ABST
Patent Text Reader

Abstract

This invention relates to the field of water quality prediction. To address the problems of declining generalization ability and poor regional applicability of machine learning models, it provides a cross-basin water quality migration prediction method and system based on TCN (Tracking Networking) technology. The TCN-based cross-basin water quality migration prediction method includes training a Seq2Seq model with an encoder-decoder structure using sample sequence windows, and fixing the weight parameters of the Seq2Seq model; judging whether the potential for zero-retraining transfer learning is sufficient based on the autocorrelation of the historical windows of the target domain, to determine whether to directly perform zero-retraining transfer inference or perform dynamic optimization of the target domain input window; obtaining the predicted water quality data sequence for the target domain through zero-retraining transfer inference based on the fixed Seq2Seq model weight parameters and the corresponding target domain input window; and determining whether to recommend deploying the Seq2Seq model based on the acceptance results of the water quality data prediction sequence. This method can improve the generalization ability and regional applicability of the prediction model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of water quality prediction, and in particular to a cross-basin water quality migration prediction method and system based on a TCN (Temporal Convolutional Network). BACKGROUND

[0002] The statements in this section merely provide background information related to the present application and do not necessarily constitute the prior art.

[0003] Traditional water quality prediction uses a physical mechanism model, which is highly dependent on specific hydrological and topographical conditions of the basin and the migration rules of pollutants. When migrating to other basins, it is often necessary to re-determine key basic data such as topography, soil permeability, etc., which not only significantly increases the calculation complexity, but also makes it difficult to accurately represent the spatio-temporal dynamic changes of environmental conditions.

[0004] Using a machine learning model to predict water quality can break away from the mechanism, but the machine learning model has a strong dependence on large-scale and high-quality labeled data. When applied to a target basin with scarce data, due to the significant differences in the statistical distribution of input features (such as flow, nitrogen, and phosphorus concentration) between the source basin and the target basin, the generalization ability of the machine learning model is greatly reduced, which reduces the regional applicability of the prediction model. SUMMARY

[0005] To solve the above technical problems, the present application provides a cross-basin water quality migration prediction method and system based on a TCN, which can effectively improve the generalization ability and regional applicability of the prediction model.

[0006] To achieve the above purpose, the present application adopts the following technical solutions:

[0007] The first aspect of the present application provides a cross-basin water quality migration prediction method based on a TCN.

[0008] In one or more embodiments, a cross-basin water quality migration prediction method based on a TCN is provided, comprising:

[0009] Obtaining source domain water quality data and preprocessing to obtain a preprocessing parameter package and a sample sequence window;

[0010] Training a Seq2Seq model with an encoder-decoder structure using the sample sequence window to solidify the weight parameters of the Seq2Seq model; the encoder and the decoder are both based on a temporal convolutional network;

[0011] Preprocessing target domain water quality data using the preprocessing parameter package to obtain a target domain input window;

[0012] The autocorrelation of the target domain history window is used to determine whether the potential for zero-retraining transfer meets the standard, so as to determine whether to directly execute zero-retraining transfer inference or to execute dynamic optimization operation of the target domain input window.

[0013] Based on the weight parameters of the fixed Seq2Seq model and the corresponding target domain input window, the water quality data prediction sequence of the target domain is obtained through zero-retraining transfer inference. Then, the deployment of the Seq2Seq model is determined based on the acceptance results of the water quality data prediction sequence.

[0014] As one implementation method, when the potential for zero-retraining transfer meets the standard, the zero-retraining transfer inference operation is directly executed based on the fixed Seq2Seq model weight parameters and the target domain input window to obtain the water quality data prediction sequence of the target domain, and then the water quality data prediction sequence is accepted and the site is selected.

[0015] As one implementation method, when the potential for zero-retraining transfer does not meet the standard or the water quality data prediction sequence fails to pass the acceptance test, a dynamic optimization operation of the target domain input window is performed. The process is as follows: the target domain input window is used as a candidate window, and based on the fixed Seq2Seq model weight parameters, the optimal target domain input window length is searched within the candidate window, and the zero-retraining transfer inference and water quality data prediction sequence acceptance test are re-executed.

[0016] As one implementation method, based on the fixed Seq2Seq model weight parameters, if the water quality data prediction sequence of the target domain obtained after zero-retraining transfer inference operation through the optimal target domain input window still fails the acceptance test, a rollback conclusion of "not transferable / not recommended for deployment" is output.

[0017] As one implementation method, the preprocessing of source area water quality data includes outlier handling, missing value imputation, and data partitioning. During missing value imputation, the source area water quality data after outlier handling is imputed using a weighted nearest neighbor method. Centered on the missing point, a preset number of valid time steps of source area water quality data are selected, and the data is partitioned according to the time difference. Calculate the weights and obtain the fill value through a weighted average.

[0018] As one implementation method, the weight calculation formula is: ;

[0019] The fill value is: ;

[0020] in, Index of valid sample points within the neighborhood; For missing moments With effective sample points in the neighborhood Corresponding time The time step difference between them ; is a weight of the effective sample point in the neighborhood; is a preset small positive number; is a preset small positive number; is a time point is a filling value of the time point is an observed value at the effective sample point in the neighborhood is an observed value at the effective sample point in the neighborhood is a set of effective sample points in the neighborhood of the missing point is a set of effective sample points in the neighborhood of the missing point

[0021] As an implementation mode, when there are multiple candidate sites in the target domain, the Nash efficiency coefficient NSE and the normalized root mean square error NRMSE of each candidate site are calculated according to the water quality data prediction sequence and the actual sequence of the water quality data; the migration effect of each candidate site is sorted according to the comprehensive score of each candidate site , and the high-adaptation site is preferentially migrated; wherein, is a constant coefficient and satisfies . .

[0022] As an implementation mode, a loss function with the same caliber as the Nash efficiency coefficient NSE is used as the loss function of the Seq2Seq model of the encoder-decoder structure;

[0023] ;

[0024] ;

[0025] wherein, is a prediction step index; is a prediction step length; is a real water quality index value at the i-th step is a real water quality index value at the i-th step is a real water quality index value at the i-th step is a real water quality index value at the i-th step is a mean value of the real sequence in the prediction interval; is a preset small positive number; is a loss function; NSE is a Nash efficiency coefficient.

[0026] The second aspect of the application provides a TCN-based cross-basin water quality migration prediction system.

[0027] In one or more embodiments, a TCN-based cross-basin water quality migration prediction system comprises:

[0028] A source domain data preprocessing module for obtaining source domain water quality data and preprocessing to obtain a preprocessing parameter package and a sample sequence window;

[0029] a Seq2Seq model training module configured to train a Seq2Seq model of an encoder-decoder structure by using the sample sequence window, and to solidify weight parameters of the Seq2Seq model; the encoder and the decoder are both based on a time convolution network;

[0030] a target domain data preprocessing module configured to preprocess target domain water quality data by using the preprocessing parameter package, to obtain a target domain input window;

[0031] a pre-migration adaptability judging module configured to judge whether the potential of zero-retraining migration meets the requirement according to the autocorrelation of the target domain historical window, to judge whether to directly perform zero-retraining migration reasoning or to perform target domain input window dynamic optimization operation;

[0032] a zero-retraining migration reasoning module configured to obtain a water quality data prediction sequence of the target domain by zero-retraining migration reasoning according to the solidified Seq2Seq model weight parameters and the corresponding target domain input window, and to determine whether to recommend deployment of the Seq2Seq model according to a water quality data prediction sequence acceptance result.

[0033] A third aspect of the present application provides an electronic device.

[0034] An electronic device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the TCN-based cross-basin water quality migration prediction method as described above when executing the program.

[0035] Compared with the prior art, the present application has the following beneficial effects:

[0036] The present application preprocesses the source domain water quality data and the target domain water quality data by using the same preprocessing method, trains a Seq2Seq model of an encoder-decoder structure by using a sample sequence window corresponding to the source domain water quality data to solidify weight parameters of the Seq2Seq model, judges the potential of zero-retraining migration according to the autocorrelation of a target domain historical window before data migration, and finally determines whether to recommend deployment of the Seq2Seq model according to a water quality data prediction sequence acceptance result, thereby realizing a migration and self-adaptive learning model framework on the basis of source basin knowledge, significantly improving the deployment efficiency of cross-basin water quality prediction, and effectively improving the generalization ability and regional applicability of the prediction model.

[0037] The application predicts the sequence acceptance result according to water quality data, judges whether to trigger the target domain input window dynamic optimization operation, takes the target domain input window as a candidate window in the dynamic optimization process, searches for the optimal target domain input window length in the candidate window based on the solidified Seq2Seq model weight parameter, re-executes the zero-retraining migration reasoning and water quality data prediction sequence acceptance, realizes the closed-loop decision mechanism, reduces the invalid migration risk and improves the deployment efficiency and availability. BRIEF DESCRIPTION OF DRAWINGS

[0038] The accompanying drawings, which form a part of this specification, are included to provide a further understanding of the application and are incorporated herein by reference. The embodiments illustrated in the drawings are presented by way of example in explaining the present application and are not intended to limit the present application.

[0039] Figure 1 is a TCN-based cross-basin water quality migration prediction method flowchart of an embodiment of the application;

[0040] Figure 2 is a Seq2Seq model structure diagram of an encoder-decoder structure of an embodiment of the application;

[0041] Figure 3 is a causal convolution structure diagram of an embodiment of the application;

[0042] Figure 4 is an expanded convolution structure diagram of an embodiment of the application;

[0043] Figure 5 is a residual network structure diagram of TCN of an embodiment of the application;

[0044] Figure 6 is a water quality performance index diagram of an embodiment of the application;

[0045] Figure 7 is a TCN-based cross-basin water quality migration prediction system structure schematic diagram of an embodiment of the application;

[0046] Figure 8 is a schematic diagram of an electronic device of an embodiment of the application. DETAILED DESCRIPTION

[0047] The application will be further described below in conjunction with the drawings and embodiments.

[0048] It should be noted that the following detailed description is exemplary and is intended to provide further explanation of the application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as generally understood by those skilled in the art to which the application belongs.

[0049] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0050] Figure 1 A schematic diagram of the principle of the cross-basin water quality migration prediction method based on TCN according to an embodiment of the present invention is provided. Figure 1 The cross-basin water quality migration prediction method based on TCN in this embodiment may include the following steps S101 to S105.

[0051] The specific implementation process of steps S101 to S105 is as follows:

[0052] Step S101: Obtain source area water quality data and perform preprocessing to obtain preprocessing parameter package and sample sequence window.

[0053] For example, water quality data from station A in basin A with abundant data and station B in basin B with scarce data can be selected as the training set and test set of the model, respectively. The training set and test set can be preprocessed to improve the robustness of the data in terms of time series.

[0054] The training set of samples consists of water quality data (including 7 indicators: water temperature WT, pH, dissolved oxygen DO, conductivity EC, turbidity Tur, permanganate index CODMn, and ammonia nitrogen NH3-N) for a specified time period (e.g., August 2021 to March 2025) at station A in watershed A, with a time frequency of 4 hours / time.

[0055] The data in the sample test set is real-time monitoring data of B site in watershed B during a time period (e.g., January 2022 to December 2024) (data missing rate 40%).

[0056] In the specific implementation process, the preprocessing operations for source area water quality data include outlier handling, missing value imputation, and data segmentation.

[0057] The outlier handling process is as follows:

[0058] Calculate the mean independently for each indicator data. with standard deviation Adopting improved The rule determines outliers (those exceeding the limit). The data points are within a certain range. Outliers are removed and replaced with NaN (non-numerical) to avoid time-series breaks caused by direct deletion, while suppressing the interference of extreme values ​​on model training.

[0059] During the missing value imputation process, the source water quality data after outlier processing is imputed using the weighted nearest neighbor method. Centered on the missing point, a preset number of valid time steps of source water quality data are selected, and the imputation is performed based on the time difference. The weights are calculated, and the imputed value is obtained through a weighted average. This method strengthens the weights of nearest time points, ensuring the temporal continuity of the data after imputation.

[0060] Specifically, the weight calculation formula is as follows: ; It is based on the time difference The calculated weights are used to weighted average the missing water quality data. This reflects the influence of water quality data from neighboring time steps on the missing values; here... A very small positive number (e.g.) (), used to prevent division by zero errors during calculation. (Time step difference): Represents the missing time step. With effective sample points in the neighborhood Corresponding time The time step difference between them is usually expressed in units of time step (e.g., 4 hours / step). The meaning is to calculate the time difference between two moments in a time series, which is used to measure time correlation.

[0061] The fill value is: The term "filled value" refers to the water quality data after filling the gap. The filled value is obtained by weighting the data points within the neighborhood according to the weighted average formula.

[0062] in, Index of valid sample points within the neighborhood; For missing moments With effective sample points in the neighborhood Corresponding time The time step difference between them (Unit: time step; if the sampling frequency is 4 hours / sampling, then 1 step = 4 hours). Valid sample points within the neighborhood The weight (dimensionless); Preset small positive numbers (such as ), to prevent division by zero; For a moment The filler value (unit same as index); Valid sample points within the neighborhood Observations (units same as indicators); missing points The set of effective samples in the neighborhood (e.g., 4 effective time steps before and after).

[0063] The data partitioning process is as follows:

[0064] The dataset is strictly divided according to time sequence to avoid future data leakage: training set (60%, covering the early period), validation set (20%, covering the middle period), and test set (20%, covering the recent period). Each metric is divided independently to ensure time sequence consistency.

[0065] Step S102: Train the Seq2Seq model of the encoder-decoder structure using the sample sequence window, and solidify the weight parameters of the Seq2Seq model; both the encoder and decoder are built based on temporal convolutional networks.

[0066] like Figure 2 As shown, both the encoder and decoder are built based on the Temporal Convolutional Network (TCN), replacing the traditional TCN to improve the efficiency of parallel computing of long sequences, while retaining the ability to extract temporal features.

[0067] The model input layer uses seven water quality indicators from the past 72 hours (18 time steps, once every 4 hours) as input data (input dimension = 18 × 7).

[0068] The encoder consists of three stacked TCN networks with 128, 64 and 32 hidden units respectively. Dropout=0.2 is set for each layer to prevent overfitting. The encoder compresses the input sequence into a fixed-length feature vector to capture long-range temporal dependencies.

[0069] The decoder consists of two layers of TCN network with 32 and 64 hidden units respectively. The output layer generates prediction results through a fully connected layer and ReLU activation function. The model outputs predicted values ​​of 7 water quality indicators for the next 168 hours (42 time steps), with an output dimension of 42×7, realizing simultaneous prediction of multiple steps and multiple indicators.

[0070] TCN networks, incorporating causal convolution, dilated convolution, and residual structures, can effectively address the problem of extracting multivariate time series information. Causal convolution, considering that the output information depends only on past input information, effectively avoids interference from future information; therefore, it is a unidirectional structure. For example... Figure 3 As shown, assume the input time series is , Indicates at time step The input feature values ​​at the location (which can be univariate or multivariate vectors) Let be the sequence length. Let the one-dimensional convolution filter be... ,in, This is the filter size (kernel length). For the first Each convolution kernel weight parameter.

[0071] In causal convolution, the output sequence at any given time step depends only on the current and past input information. Taking the output at the location as an example, its calculation formula is:

[0072] ;

[0073] in, Indicates time step Convolutional output features at the location; Represents the first in the convolution kernel Each convolutional kernel contains weights. The weights in each kernel are used to weight the input signal and extract features at different time steps. For convolution kernel index; This represents the index of the time step back from the current time. Through the aforementioned causal constraints, we ensure that the model's output at any given time does not depend on future information, thereby avoiding information leakage problems in time series forecasting.

[0074] Dilated convolution allows for interval sampling of the input during convolution, with a dilation factor of 1. .when When, it means sampling each information point of the input, which is the same as causal convolution; when At this time, sampling is performed every two points. As the number of layers increases, the expansion factor increases, and the receptive field increases, thus ensuring that a large receptive field can be obtained through shallow networks.

[0075] like Figure 4 As shown, assume the input time series is The output after dilation convolution is:

[0076] ;

[0077] in, Indicates time step Dilated convolution output features at the location; Represents the first in the dilated convolution kernel Each dilated convolution kernel contains weights. The weights in each kernel are used to weight the input signal and extract features at different time steps. This is the kernel index. (And...) Figure 3 Similar to causal convolution, dilated convolution performs convolution calculations on the input data, but adds a dilation factor. This means that the convolution kernel skips a set number of time steps during computation. This expands the receptive field. From the formula and description, the implementation and design of dilated convolution align with the goal of expanding the receptive field of convolution, effectively increasing the ability to capture multi-scale temporal dependencies.

[0078] TCN uses a general-purpose residual module, and its design is as follows: Figure 5 As shown, this module consists of two sets of causal dilated convolutional layers, weight normalization layers, ReLU activation functions, and Dropout layers connected sequentially. The input features are passed through the first causal dilated convolutional layer, normalization layer, ReLU activation function layer, and Dropout layer to obtain the output features. The output is then fed into the second causal dilated convolutional layer, and after passing through the second convolutional layer, normalization layer, ReLU activation function layer, and Dropout layer, the final output features are obtained.

[0079] The ReLU function is generally used for nonlinear calculations. ;

[0080] In the formula, It is a time series.

[0081] The Seq2Seq model takes historical multivariate water quality data as input and outputs future multi-step water quality data to achieve multi-step prediction in cross-basin scenarios. Its working process can be divided into the following stages:

[0082] 1) Input sequence construction and sample pair formation;

[0083] With target time As the starting point for prediction, sample pairs are first constructed from the preprocessed multivariate water quality series:

[0084] Encoder input sequence: , indicating the past Each time step Water quality index sequence;

[0085] Predict the target sequence (supervisory label): , indicating the future Each time step Water quality index sequence; among which Input window length, To predict the step size, This refers to the number of water quality indicators (e.g., 7 indicators).

[0086] To satisfy the input interface of the Seq2Seq decoding structure, the decoder input sequence is constructed as follows:

[0087] ; It can be set to the same starting symbol sequence as the output step size, such as an all-zero sequence, to unify the decoder input format and reduce the dependence of the inference stage on the historical output of the target domain.

[0088] 2) Encoder TCN: Historical sequence is encoded as a context representation;

[0089] Encoder input sequence The input encoder TCN consists of several stacked residual modules. Each residual module contains causal convolution and dilated convolution structures to ensure that the convolution depends only on past information and expands the receptive field through the dilation factor, thereby effectively capturing long-range temporal dependencies and multi-scale variation patterns.

[0090] The encoder output is a fixed-length context representation vector (or context feature):

[0091] ;

[0092] in Information such as trends, cycles, and abrupt changes in historical water quality sequences is gathered as conditional inputs for the decoder to generate future sequences; This is a function for the encoder TCN.

[0093] 3) Decoder input enhancement: Distinguishing between contextual conditionalization and prediction step;

[0094] On the decoding side, to enable the model to distinguish between "Step 1 prediction", "Step 2 prediction", and so on up to "Step 3 prediction" during parallel prediction. "Step prediction" enhances the decoder input to form a conditional input sequence:

[0095] Contextual repeating sequence :

[0096] context representation According to the predicted step size Repeating this process, we get: ;in For the context dimension. This repetitive operation ensures that each prediction step generates output under the same context conditions.

[0097] Horizon Embedding:

[0098] Introduction ,in Indicates the first The position / step size information for each prediction step. This position indicates the semantics used to distinguish different prediction steps, avoiding the problem of homogenization of multi-step outputs when the decoder outputs in parallel.

[0099] Start character sequence:

[0100] use As a unified format for decoder input sequences (e.g., all-zero sequences), this ensures that the inference phase does not rely on the actual future output, thus meeting the deployment requirements for zero-retraining migration across watersheds.

[0101] Finally, the above three types of information are concatenated along the feature dimension to obtain the conditional input for the decoder:

[0102] ;

[0103] in .

[0104] 4) Decoder TCN: Generates multi-step prediction sequences for the future;

[0105] Input the decoder conditions The input decoder is TCN. The decoder also employs causal dilated convolution and a residual structure, and is configured to output sequence forms (return sequences) to generate future sequences. The predicted sequence at each time step: ;in, This is the decoding function of the decoder TCN; the final output is then obtained through a time-step linear mapping (e.g., a TimeDistributed fully connected layer). It enables simultaneous prediction of multiple steps and multiple indicators.

[0106] A loss function with the same caliber as the Nash efficiency coefficient (NSE) is adopted as the loss function for the Seq2Seq model of the encoder-decoder structure.

[0107] ;

[0108] ;

[0109] in, For the prediction step index (the first step) (Step prediction), dimensionless; The predicted step size (the number of steps to be predicted in the future, e.g., 42 steps) is dimensionless. For the first Step-by-step actual water quality index values ​​(unit varies with index, such as...) wait); For the first Predict water quality index values ​​step by step; The mean of the true sequence over the prediction interval (unit: same). ); Preset small positive numbers (such as ), used to avoid denominators of 0, units are the same as denominator terms (square units), and stable terms in engineering; The loss function is the unexplained variance percentage (dimensionless), and the smaller the value, the smaller the prediction error is relative to the actual fluctuation; NSE is the Nash efficiency coefficient.

[0110] In other embodiments, a hybrid loss function (MSE+MAE, weight ratio 7:3) is used to balance the sensitivity of mean squared error to large errors and the robustness of mean absolute error to outliers, thereby improving the model's ability to resist interference from outliers.

[0111] In one or more embodiments, the training optimizer is Adam (initial learning rate 0.001, decay rate 1e-5), with 200 iterations and an early stopping mechanism (training is terminated if the validation set loss does not decrease for 10 consecutive iterations); hardware support is NVIDIA GeForce RTX 5080 (16 GB), Intel(R) Graphics (128 MB), and the training time per round is <10 minutes to ensure model training efficiency.

[0112] Step S103: Use the preprocessing parameter package to preprocess the target domain water quality data to obtain the target domain input window.

[0113] The target domain water quality data is preprocessed using the same preprocessing parameter package as in step S101, and the target domain input window is generated according to the same windowing rules to ensure that the input semantics, dimensions and preprocessing methods are consistent, thereby meeting the prerequisite for zero-retraining transfer.

[0114] Step S104: Determine whether the potential for zero-retraining transfer meets the standard based on the autocorrelation of the target domain history window, so as to determine whether to directly execute zero-retraining transfer inference or execute the target domain input window dynamic optimization operation.

[0115] The autocorrelation is calculated based on the historical data of the target site and compared with the threshold. The "high migration potential / low migration potential" label is output to determine whether the potential for zero-retraining migration meets the standard.

[0116] In the same target watershed or the same set of candidate sites Above, calculate a comprehensive autocorrelation strength for each station B. :

[0117] ;

[0118] in, This represents a predefined set of lag orders, used to characterize the correlation of time series under different time delays; The lag order; This represents the autocorrelation of a time series at different time delays. In water quality prediction models, the lag order is used to describe the impact of historical values ​​of water quality indicators (such as dissolved oxygen concentration) on the current prediction. For example, a lag order of 1 indicates that the water quality at the current moment is influenced by the previous moment, while a lag order of 2 indicates that the water quality at the current moment is influenced by the previous two moments.

[0119] This indicates that the historical water quality time series of site B has a lag order of [missing information]. The autocorrelation coefficient at time t is calculated as follows: ;

[0120] in, For station B at time The target water quality index observation values, This represents the mean of the corresponding historical sequence. This represents the sample length.

[0121] Overall autocorrelation strength It reflects the overall temporal dependence of the target site's water quality sequence across multiple time lag scales, and is used to evaluate the temporal structure similarity and transferability potential of the source domain model during zero-retraining transfer to the target domain.

[0122] Then the threshold Let these be the settings. quantiles, such as the upper quartile ( quantile):

[0123] ;in, For site collection;

[0124] Judgment rule: If If it is high, it is marked as having high transfer potential, meaning that the potential for transfer without retraining has been met.

[0125] When the potential for zero-retraining transfer reaches the target, the zero-retraining transfer inference operation is directly executed based on the fixed Seq2Seq model weight parameters and the target domain input window to obtain the water quality data prediction sequence of the target domain, and then the water quality data prediction sequence is accepted and the site is selected.

[0126] In some alternative embodiments, when the normalized root mean square error NRMSE is less than a set threshold (e.g., ...), (This can be set according to actual conditions), and the migration effect is recorded as "excellent"; at the same time, the Nash efficiency coefficient NSE is required to be no less than a preset threshold (e.g., Specifically, the criteria for determining relocation acceptance can be expressed as follows:

[0127] Through migration acceptance ;

[0128] This transforms migration behavior into verifiable engineering admissions, reducing ineffective deployments that are migrated but not usable.

[0129] When multiple candidate sites exist in the target domain, the Nash efficiency coefficient (NSE) and normalized root mean square error (NRMSE) of each candidate site are calculated based on the predicted and actual water quality data sequences. The comprehensive score of each candidate site is then used to determine the optimal solution. The migration performance of each candidate site was ranked, and sites with high compatibility were migrated first; among them, and The coefficients are constant and satisfy the following conditions: .

[0130] NSE is used to characterize the model's ability to fit and explain the fluctuations and trends of the real sequence. It is more relevant to the availability of engineering deployment and is therefore given a higher weight. NRMSE is used to constrain the normalized absolute error level of the prediction and is given a lower weight as an auxiliary indicator. Therefore, in this embodiment, we take... .

[0131] In some specific embodiments, and The value can be obtained by weight optimization on the source domain or a set of historical sites with sufficient annotations:

[0132] For example, let the candidate weight set be... Calculate the comprehensive score for each site one by one on the candidate weight set. , and according to Sort the sites from highest to lowest; use the migration acceptance results (determined by NSE interval value and NRMSE threshold for pass / fail) as the control label, and calculate the proportion of "passed acceptance" (hit rate) among the top K sites. Select the weight combination with the highest hit rate as the final constant coefficient value. K can be any number of candidate sites. Or a preset fixed value.

[0133] This embodiment achieves the following optimization: .

[0134] Step S105: Based on the weight parameters of the fixed Seq2Seq model and the corresponding target domain input window, the water quality data prediction sequence of the target domain is obtained through zero-retraining transfer inference. Then, the Seq2Seq model is recommended to be deployed based on the acceptance results of the water quality data prediction sequence.

[0135] When the potential for zero-retraining transfer does not meet the standard or the water quality data prediction sequence fails the acceptance test, a dynamic optimization operation of the target domain input window is performed. The process is as follows: the target domain input window is used as a candidate window, and based on the fixed Seq2Seq model weight parameters, the optimal target domain input window length is searched within the candidate window. Then, the zero-retraining transfer inference and water quality data prediction sequence acceptance test are re-executed.

[0136] Based on the fixed Seq2Seq model weight parameters, if the water quality data prediction sequence of the target domain obtained after zero-retraining transfer inference operation through the optimal target domain input window still fails the acceptance test, a rollback conclusion of "not transferable / not recommended for deployment" will be output.

[0137] according toFigure 6 Figures (a) and (b) show the water quality performance index diagrams of an embodiment of the present invention. Under the conditions of the same site after migration, the same input step length of 72 hours (18 steps) and the same output step length of 168 hours (42 steps), and the same data preprocessing and training strategies, a comparative experiment was conducted between the TCN-Seq2Seq model of the present invention and the LSTM-Seq2Seq model and the TCN direct multi-step regression model. The meanings of the water quality performance indexes are as follows:

[0138] (1) WT (Water Temperature, unit: °C): Water temperature, used to characterize the temperature state of water bodies, affecting dissolved oxygen saturation and biochemical reaction rate;

[0139] (2) pH (unit: dimensionless) is used to characterize the acidity and alkalinity level of water bodies and affects the form of pollutants and the activity of microorganisms;

[0140] (3) DO (Dissolved Oxygen, unit: mg / L): Dissolved oxygen, used to characterize the oxygen content and self-purification capacity of water bodies;

[0141] (4) EC (Electrical Conductivity, unit: μS / cm): electrical conductivity, used to characterize the total amount of ions and mineralization level in water;

[0142] (5) Tur (Turbidity, unit: NTU): Turbidity, used to characterize the changes in the content and transparency of suspended particulate matter in water;

[0143] (6) CODMn (unit: mg / L): Permanganate index, used to characterize the overall pollution level of oxidizable organic matter and some reducible inorganic matter in water bodies;

[0144] (7) NH3-N (unit: mg / L): ammonia nitrogen, used to characterize the level of nitrogen pollution (ammonia nitrogen), and is related to the input of domestic sewage / industrial wastewater and the risk of eutrophication of water bodies.

[0145] The units mentioned above are commonly used for online / routine water quality monitoring. When the monitoring system uses other units, the dimensions can be standardized or a normalized parameter package can be used for consistency processing during the pretreatment stage.

[0146] The results show that the model of this invention is superior to the above-mentioned control model in terms of NSE improvement and NRMSE reduction, and has higher prediction accuracy, which can better meet the multi-step prediction needs of water quality early warning.

[0147] like Figure 7As shown, the TCN-based cross-basin water quality migration prediction system provided in this embodiment of the invention can be implemented in software. The TCN-based cross-basin water quality migration prediction system includes the following software modules: source domain data preprocessing module 701, Seq2Seq model training module 702, target domain data preprocessing module 703, pre-migration adaptability discrimination module 704, and zero-retraining migration inference module 705.

[0148] The functions of each software module in the TCN-based cross-basin water quality migration prediction system are described below:

[0149] Source domain data preprocessing module 701 is used to acquire source domain water quality data and preprocess it to obtain a preprocessing parameter package and a sample sequence window.

[0150] Seq2Seq model training module 702 is used to train the Seq2Seq model with encoder-decoder structure using the sample sequence window and to solidify the weight parameters of the Seq2Seq model; the encoder and decoder are both built based on temporal convolutional networks.

[0151] The target domain data preprocessing module 703 is used to preprocess the target domain water quality data using the preprocessing parameter package to obtain the target domain input window;

[0152] The pre-migration adaptability discrimination module 704 is used to determine whether the potential of zero-retraining transfer meets the standard based on the autocorrelation of the target domain historical window, so as to determine whether to directly execute zero-retraining transfer inference or execute the target domain input window dynamic optimization operation.

[0153] The zero-retraining transfer inference module 705 is used to obtain the water quality data prediction sequence of the target domain through zero-retraining transfer inference based on the weight parameters of the fixed Seq2Seq model and the corresponding target domain input window, and then determine whether to recommend the deployment of the Seq2Seq model based on the acceptance results of the water quality data prediction sequence.

[0154] It should be noted that each module in the TCN-based cross-basin water quality migration prediction system of this invention corresponds one-to-one with each step in the TCN-based cross-basin water quality migration prediction method in the above embodiments, and their specific implementation processes are the same, so they will not be repeated here.

[0155] The structure of the electronic device according to an embodiment of the present invention will be described in detail below. Figure 8 This is a schematic diagram of the composition structure of an electronic device provided in an embodiment of the present invention. It can be understood that... Figure 8 The diagram shows only an exemplary structure of the electronic device, not the entire structure. Some or all of the structures shown may be implemented as needed.

[0156] The electronic device provided in this embodiment of the invention includes: at least one processor 801, a memory 802, a user interface 803, and at least one network interface 804. The various components in the TCN-based inter-basin water quality migration prediction system are coupled together via a bus system 805. It can be understood that the bus system 805 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 805 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 8 The general labeled all buses as Bus System 805.

[0157] The user interface 803 may include a monitor, keyboard, mouse, trackball, click wheel, buttons, touchpad, or touch screen.

[0158] It is understood that memory 802 can be volatile memory or non-volatile memory, or both. In this embodiment of the invention, memory 802 is capable of storing data to support the operation of the terminal. Examples of this data include any computer programs used to operate on the terminal, such as operating systems and applications. The operating system includes various system programs, such as framework layers, core library layers, driver layers, etc., used to implement various basic services and handle hardware-based tasks. Applications can include various applications.

[0159] In some embodiments, the TCN-based cross-basin water quality migration prediction system provided in this invention can be implemented using a combination of hardware and software. For example, the TCN-based cross-basin water quality migration prediction system provided in this invention can be a processor in the form of a hardware decoding processor, programmed to execute the TCN-based cross-basin water quality migration prediction method provided in this invention. For instance, the hardware decoding processor can employ one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.

[0160] As an example, processor 801 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., wherein the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0161] As an example of the hardware implementation of the TCN-based cross-basin water quality migration prediction system provided in this embodiment of the invention, the device provided in this embodiment of the invention can be directly executed by a processor 801 in the form of a hardware decoding processor. For example, it can be executed by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components to implement the TCN-based cross-basin water quality migration prediction method provided in this embodiment of the invention.

[0162] The memory 802 in this embodiment of the invention is used to store various types of data to support the operation of the TCN-based cross-basin water quality migration prediction system, or to store data for execution. Figure 1 The program code for the method shown. Examples of this data include: any executable instructions for operation on a TCN-based interbasin water quality migration prediction system, such as executable instructions that can be included in the executable instructions to implement the TCN-based interbasin water quality migration prediction method of the embodiments of the present invention.

[0163] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including functions for executing... Figure 1 The program code for the method shown. In such an embodiment, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium. When the computer program is executed by the central processing unit, it performs the various functions defined in the apparatus of this application.

[0164] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0165] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for predicting cross-basin water quality migration based on TCN, characterized in that, include: Source water quality data is acquired and preprocessed to obtain a preprocessing parameter package and sample sequence window; The Seq2Seq model with encoder-decoder structure is trained using the sample sequence window, and the weight parameters of the Seq2Seq model are fixed; both the encoder and decoder are built based on temporal convolutional networks. The target domain water quality data is preprocessed using the aforementioned preprocessing parameter package to obtain the target domain input window; The autocorrelation of the target domain's historical windows is used to determine whether the potential for zero-retraining transfer learning meets the criteria, in order to decide whether to directly execute zero-retraining transfer inference or perform dynamic optimization of the target domain's input windows; this applies within the same target watershed or the same set of candidate sites. Above, calculate a comprehensive autocorrelation strength for each station B. : ; This represents a predefined set of lag orders, used to characterize the correlation of time series under different time delays; The lag order; This indicates the autocorrelation of a time series under different time delays; This indicates that the historical water quality time series of site B has a lag order of [missing information]. The autocorrelation coefficient at time; Based on the weight parameters of the fixed Seq2Seq model and the corresponding target domain input window, the water quality data prediction sequence of the target domain is obtained through zero-retraining transfer inference. Then, the decision on whether to recommend the deployment of the Seq2Seq model is made based on the acceptance results of the water quality data prediction sequence. When the potential for zero-retraining transfer is met, the zero-retraining transfer inference operation is directly executed based on the fixed Seq2Seq model weight parameters and the target domain input window to obtain the water quality data prediction sequence of the target domain, and then the water quality data prediction sequence is accepted and the site is selected. When multiple candidate sites exist in the target domain, the Nash efficiency coefficient (NSE) and normalized root mean square error (NRMSE) of each candidate site are calculated based on the predicted and actual water quality data sequences. The comprehensive score of each candidate site is then used to determine the optimal solution. The migration performance of each candidate site was ranked, and sites with high compatibility were migrated first; among them, and The coefficients are constant and satisfy the following conditions: .

2. The method for predicting cross-basin water quality migration based on TCN as described in claim 1, characterized in that, When the potential for zero-retraining transfer does not meet the standard or the water quality data prediction sequence fails the acceptance test, a dynamic optimization operation of the target domain input window is performed. The process is as follows: the target domain input window is used as a candidate window, and based on the fixed Seq2Seq model weight parameters, the optimal target domain input window length is searched within the candidate window. Then, the zero-retraining transfer inference and water quality data prediction sequence acceptance test are re-executed.

3. The method for predicting cross-basin water quality migration based on TCN as described in claim 2, characterized in that, Based on the fixed Seq2Seq model weight parameters, if the water quality data prediction sequence of the target domain obtained after zero-retraining transfer inference operation through the optimal target domain input window still fails the acceptance test, then the fallback conclusion of "not transferable / not recommended for deployment" is output.

4. The method for predicting cross-basin water quality migration based on TCN as described in claim 1, characterized in that, The preprocessing of source area water quality data includes outlier handling, missing value imputation, and data partitioning. During missing value imputation, the weighted nearest neighbor method is used to impute the outliers in the source area water quality data. Centered on the missing point, a preset number of valid time steps of source area water quality data are selected, and the imputation is performed based on the time difference. Calculate the weights and obtain the fill value through a weighted average.

5. The method for predicting cross-basin water quality migration based on TCN as described in claim 4, characterized in that, The formula for calculating the weight is: ; The fill value is: ; in, Index of valid sample points within the neighborhood; For missing moments With effective sample points in the neighborhood Corresponding time The time step difference between them ; Valid sample points within the neighborhood The weights; Preset to small positive numbers; For a moment The fill value; Valid sample points within the neighborhood Observation value; missing points The set of effective samples in the neighborhood.

6. The method for predicting cross-basin water quality migration based on TCN as described in claim 1, characterized in that, A loss function with the same caliber as the Nash efficiency coefficient (NSE) is adopted as the loss function for the Seq2Seq model of the encoder-decoder structure. ; ; in, For the prediction step index; To predict the step size; For the first Step to the actual water quality index values; For the first Predict water quality index values ​​step by step; This represents the mean of the true sequence within the predicted interval; Preset to small positive numbers; is the loss function; NSE is the Nash efficiency coefficient.

7. A cross-basin water quality migration prediction system based on TCN, characterized in that, The method for predicting cross-basin water quality migration based on TCN as described in any one of claims 1-6 includes: The source domain data preprocessing module is used to acquire source domain water quality data and preprocess it to obtain a preprocessing parameter package and a sample sequence window; The Seq2Seq model training module is used to train the Seq2Seq model with encoder-decoder structure using the sample sequence window, and to solidify the weight parameters of the Seq2Seq model; both the encoder and decoder are built based on temporal convolutional networks. The target domain data preprocessing module is used to preprocess the target domain water quality data using the preprocessing parameter package to obtain the target domain input window; The pre-migration adaptability discrimination module is used to determine whether the potential for zero-retraining transfer meets the standard based on the autocorrelation of the target domain historical window, so as to determine whether to directly execute zero-retraining transfer inference or execute the target domain input window dynamic optimization operation. The zero-retraining transfer inference module is used to obtain the water quality data prediction sequence of the target domain through zero-retraining transfer inference based on the weight parameters of the fixed Seq2Seq model and the corresponding target domain input window. Then, it determines whether to recommend the deployment of the Seq2Seq model based on the acceptance results of the water quality data prediction sequence.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the TCN-based method for predicting cross-basin water quality migration as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Water quality prediction model and prediction method based on spatial-temporal feature fusion and LSTM memory network

    CN120067993A

  • Water quality time sequence prediction method of SSA-VMD-LSTM-XGBoost hybrid model

    CN121260311A