Coupling causal discovery and deep learning water quality prediction method and system

By combining causal discovery and deep learning, we screened causal dynamic covariates and conducted multi-scale analysis, which solved the problem of water quality prediction models relying on spurious correlations. This enabled high-precision and transparent prediction of water quality indicators, making it suitable for water environment management.

CN121880781APending Publication Date: 2026-04-17HUAZHONG UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-25
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing water quality prediction models rely on spurious correlations, resulting in poor generalization ability, inability to accurately predict dynamic changes in water quality indicators, and lack of transparent and interpretable prediction processes.

Method used

A neural network-based causal discovery algorithm is used to screen causal dynamic covariates. Combined with multi-scale analysis and probabilistic time series prediction models, redundant variables are eliminated by Spearman correlation coefficient and variance inflation factor. The neural Granger causality algorithm is used to identify causal relationships, and wavelet decomposition is used to handle non-stationarity. The time series fusion Transformer model is used for multi-site training and interpretability analysis.

Benefits of technology

It achieves high-precision prediction of water quality indicators, can quantify uncertainty, improves the model's generalization ability and transparency, and is suitable for water environment risk management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121880781A_ABST
    Figure CN121880781A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of water environment monitoring and water quality prediction, and particularly discloses a causal discovery and deep learning coupled water quality prediction method and system, and the method comprises the steps: carrying out the causal screening of dynamic covariables through employing a causal discovery algorithm based on a neural network, and recognizing causal dynamic covariables; and inputting the causal dynamic covariable, the multi-scale water quality index characteristics and the static covariable data into a trained probability time sequence prediction model, and outputting a probabilistic prediction result of the water quality index concentration of the target water area in a plurality of time steps in the future. According to the method, pseudo-correlation variables are eliminated, the non-stationarity is processed through multi-scale analysis, purer and richer multi-scale information is provided for the probability time sequence prediction model, and the accuracy of point prediction is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of water environment monitoring and water quality prediction, and more specifically, relates to a water quality prediction method and system that couples causal discovery with deep learning. Background Technology

[0002] Water quality indicators (such as dissolved oxygen DO) are among the most critical comprehensive indicators for assessing the health of aquatic ecosystems. The concentration of this indicator is the net result of complex interactions between physical and biogeochemical processes, and accurate prediction of its dynamic changes is essential for proactive environmental management and the prevention of ecological disasters.

[0003] However, water quality forecasting faces significant challenges. First, water quality time series are influenced by both climate change and human activities, exhibiting complex non-stationary dynamics. Second, traditional water quality forecasting models typically provide deterministic point predictions, failing to quantify the inherent uncertainty in the forecasts, which is insufficient for risk management and decision support. Third, while deep learning models (such as recurrent neural networks) perform well in time series forecasting, their "black box" nature hinders their practical application; the lack of transparency makes it difficult for decision-makers to understand the basis of their predictions, and the models may rely on spurious correlations in the data rather than genuine causal drivers, resulting in poor generalization ability. Therefore, there is an urgent need for a new forecasting paradigm that can simultaneously achieve high-precision forecasts, reliable uncertainty quantification, and a transparent and interpretable forecasting process. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this application aims to provide a water quality prediction method and system that couples causal discovery with deep learning, thereby solving the problem that the prediction of existing water quality indicators relies on spurious correlations, resulting in poor generalization ability of the prediction model.

[0005] The first aspect of this application relates to a water quality prediction method that couples causal discovery with deep learning, specifically including the following steps: Step 1: Use a neural network-based causal discovery algorithm to perform causal screening on dynamic covariates and identify causal dynamic covariates; Step 2: Input the causal dynamic covariates, multi-scale water quality index characteristics, and static covariate data into the trained probabilistic time series prediction model, and output the probabilistic prediction results of the water quality index concentrations of the target water area at multiple future time steps.

[0006] In some implementations, step one specifically includes: By calculating the Spearman correlation coefficient and variance inflation factor of dynamic covariate data, dynamic covariates with correlation exceeding the preset value are removed. The neuro-Granger causality algorithm is used to perform causal screening on the remaining dynamic covariates and identify causal dynamic covariates.

[0007] In some implementation methods, the methods for obtaining multi-scale water quality index characteristics are as follows: Historical water quality index time series data are decomposed into multiple subsequences of different frequencies using wavelet decomposition, and the highest frequency noise component is eliminated to construct multi-scale water quality index features.

[0008] In some implementations, the neural Granger causality algorithm employs a component-based long short-term memory network and identifies causal relationships by imposing a sparsity penalty.

[0009] In some implementations, the probabilistic time series prediction model employs a TFT model, which includes a static processing path for processing static covariates and a dynamic processing path for processing dynamic time series; the static processing path encodes the static covariate data into a set of context vectors, and uses the context vectors to adjust the dynamic processing path by controlling the dynamic time series.

[0010] In some implementations, causal dynamic covariates, multi-scale water quality index characteristics, static covariate data, and water quality index concentrations from different monitoring stations are combined and input into a probabilistic time series prediction model for training. In this model, static covariates are encoded as context vectors to adjust the dynamic time series of different stations, enabling probabilistic predictions of water quality index concentrations at different stations at different times.

[0011] In some implementations, the probabilistic time series prediction model incorporates a variable selection network to automatically learn and output the global importance scores of all input variables to the probabilistic prediction results, and incorporates an interpretable self-attention mechanism to dynamically assign attention to input variable data at different historical time points.

[0012] In some implementations, the probabilistic prediction results include multiple quantiles, and the prediction interval is constructed using the quantiles to quantify the prediction uncertainty.

[0013] The second aspect of this application relates to a water quality prediction system that couples causal discovery with deep learning, comprising: The causal screening module is used to perform causal screening on dynamic covariates using a neural network-based causal discovery algorithm to identify causal dynamic covariates. The prediction model module is used to input causal dynamic covariates, multi-scale water quality index characteristics, and static covariate data into the trained probabilistic time series prediction model, and output the probabilistic prediction results of water quality index concentrations at multiple future time steps in the target water area.

[0014] In some implementations, the water quality prediction system also includes a feature engineering module, which decomposes historical water quality index time series data into multiple subsequences of different frequencies using wavelet decomposition, eliminates the highest frequency noise component, and constructs multi-scale water quality index features.

[0015] In some implementations, the causal screening module includes a primary screening unit and a second screening unit; The primary screening unit is used to remove dynamic covariates whose correlation exceeds a preset value by calculating the Spearman correlation coefficient and variance inflation factor of the dynamic covariate data. The second screening unit is used to perform causal screening on the remaining dynamic covariates using the neural Granger causality algorithm to identify causal dynamic covariates.

[0016] In some implementations, the prediction model module includes a static processing unit and a dynamic processing unit. The static processing unit is used to execute a static processing path, encode static covariate data into a set of context vectors, and process dynamic time series from different sites. The dynamic processing unit is used to execute a dynamic processing path for processing dynamic time series.

[0017] Thirdly, this application provides an electronic device, comprising: at least one memory for storing a program; and at least one processor for executing the program stored in the memory, wherein when the program stored in the memory is executed, the processor is configured to execute the method described in the first aspect or any possible implementation thereof.

[0018] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when run on a processor, causes the processor to perform the method described in the first aspect or any possible implementation thereof.

[0019] Fifthly, this application provides a computer program product that, when run on a processor, causes the processor to perform the method described in the first aspect or any possible implementation thereof.

[0020] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.

[0021] Overall, the technical solutions conceived in this application have the following beneficial effects compared with the prior art: High accuracy and robustness: Redundant and pseudo-correlated variables are eliminated through a two-stage screening method (including multicollinearity analysis and NGC algorithm), and non-stationarity is handled through multi-scale analysis (such as WD decomposition), providing the model with purer and richer multi-scale information, which significantly improves the accuracy of point prediction (such as reducing MAPE and improving NSE).

[0022] Uncertainty Quantification: The method provided in this application uses a probabilistic time series prediction model (such as the TFT model) to directly output probabilistic prediction results (prediction intervals) instead of a single point prediction. This method can reliably quantify the uncertainty of the prediction (such as providing reliable AQL and CR indicators), providing a key basis for water environment risk management.

[0023] Explainability and Transparency: This application overcomes the black-box limitations of traditional deep learning models. First, it clarifies the causal driving factors on which the probabilistic time series prediction model depends through NGC. Second, through the built-in interpretability tools of TFT (variable importance ranking and attention weight distribution), the prediction process of the probabilistic time series prediction model is made transparent and auditable, enhancing decision-makers' trust in the model.

[0024] Strong generalization ability: By combining static covariates and multi-site training methods, the probabilistic time series prediction model of this application can effectively learn the spatial heterogeneity between different sites, giving it good transferability and wide applicability. Attached Figure Description

[0025] Figure 1 This is a flowchart of the prediction method provided in the embodiments of this application.

[0026] Figure 2 This is a coupled architecture diagram of the hybrid prediction framework provided in the embodiments of this application.

[0027] Figure 3 This is a schematic diagram of the Neural Granger Causality (NGG) module provided in the embodiments of this application.

[0028] Figure 4 This is a schematic diagram of the wavelet decomposition (WD) module provided in the embodiments of this application.

[0029] Figure 5 This is a schematic diagram of the internal structure of the TFT provided in the embodiments of this application.

[0030] Figure 6(a) is a graph showing the results of the importance analysis of dynamic covariates by the TFT model provided in the embodiments of this application.

[0031] Figure 6(b) is a graph showing the results of the importance analysis of static covariates using the TFT model provided in the embodiments of this application.

[0032] Figure 7(a) is an analysis diagram of the time attention mechanism of the TFT model provided in the embodiment of this application.

[0033] Figure 7(b) is a graph showing the change in attention distance when the water quality index sequence provided in the embodiments of this application undergoes abrupt changes or abnormal fluctuations.

[0034] Figure 8 This is an architecture diagram of the prediction system provided in the embodiments of this application.

[0035] Figure 9 This is an architectural diagram of the electronic device provided in the embodiments of this application. Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0037] In this application, the term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A existing alone, A and B existing simultaneously, and B existing alone. In this application, the symbol " / " indicates that the related objects are in an "or" relationship, for example, A / B means A or B.

[0038] In this application, the terms “first” and “second” are used to distinguish different objects, rather than to describe a specific order of objects.

[0039] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0040] In the description of the embodiments in this application, unless otherwise stated, "multiple" means two or more.

[0041] To facilitate understanding, some of the technical terms used in the embodiments of this application will be introduced first: Neural Granger Causality (NGC) refers to a neural network-based causal discovery algorithm used to identify complex, non-linear causal relationships between time series, rather than just correlations. Wavelet Decomposition (WD) is a multi-scale analysis method used to decompose a time series (especially a non-stationary series) into multiple components (subsequences) at different scales (frequency), including low-frequency approximate components and high-frequency detail components. Temporal Fusion Transformer (TFT): refers to a deep learning architecture designed specifically for multi-step time series prediction. Based on the attention mechanism, it can effectively fuse different types of inputs (such as dynamic time series and static covariates) and has a built-in interpretability mechanism.

[0042] The embodiments of this application are described below with reference to the accompanying drawings.

[0043] This application provides a water quality prediction method that couples causal discovery with deep learning, specifically including the following steps: Step S1: Obtain historical water quality index time series data for the target water area, a set of dynamic covariate data and a set of static covariate data corresponding to the target water area; Step S2: A two-stage screening method is used to screen dynamic covariates. First, multicollinearity analysis is performed, and then a causal discovery algorithm based on neural networks is used to screen the dynamic covariates after the initial screening to identify causal dynamic covariates. Step S3: Use a multi-scale analysis method (e.g., wavelet decomposition WD) to decompose the historical water quality index time series data into multiple subsequences of different frequencies and construct multi-scale water quality index features. Step S4: Input the causal dynamic covariates, multi-scale water quality index characteristics, and static covariate data into a probabilistic time series prediction model (e.g., Time Series Fusion Transformer, TFT). Step S5: Train the probabilistic time series prediction model to output probabilistic predictions of water quality index concentrations for multiple future time steps in the target water area.

[0044] In some implementations, multicollinearity analysis in step S2 may, for example, involve calculating the Spearman correlation coefficient and variance inflation factor (VIF) to initially eliminate variables with high correlation or excessively high VIF values; the neural network-based causal discovery algorithm is preferably a neural Granger causality (NGC) algorithm, for example, using a component long short-term memory network (cLSTM) and identifying causal relationships by applying group sparsity penalties; In some implementations, the multi-scale analysis method in step S3 can preferably be wavelet decomposition (WD), and the multi-scale water quality index characteristics include at least one low-frequency approximation component (e.g., Components (representing trends) and multiple mid-to-high frequency detail components (such as...) Components, representing fluctuations at different scales), and can eliminate one or more of the highest frequency noise components (such as...). (Quantity); In some implementations, the probabilistic prediction result in step S5 includes multiple quantiles, and a prediction interval is constructed by using multiple quantiles to quantify the prediction uncertainty.

[0045] In some implementations, the probabilistic time series prediction model in step S4 may preferably be a TFT model, which includes a static processing path for processing static covariates and a dynamic processing path for processing dynamic time series; the static processing path includes a static encoder for encoding static covariate data into a set of context vectors; the context vectors are used to adjust the behavior of the dynamic processing path, so that the model can use static background information to adjust its processing of dynamic time patterns. In some implementations, the water quality prediction method coupled with causal discovery and deep learning provided in this application also employs a multi-site training method, which merges data from multiple different monitoring stations to train a global TFT model. In this method, static covariates (such as latitude and elevation) play a key role, and they are encoded into context vectors by the TFT to adjust the TFT model's processing of dynamic time series from different stations. In some implementations, the TFT model in this application adopts a unique architecture to achieve the inherent interpretability of the model. On the one hand, the variable selection network built into the TFT model can automatically learn and output the global importance score of all input variables to the prediction result. On the other hand, the interpretable self-attention mechanism built into the TFT model can reveal how the model dynamically allocates its attention to different points in the past when making predictions.

[0046] Example like Figure 1 As shown, this application provides a water quality prediction method that couples causal discovery with deep learning, specifically including the following steps: Step S101: Obtain historical time series data of the target water quality indicators of the target water area, a corresponding set of dynamic covariate data, and a set of static covariate data; More specifically, the data source is as follows: This embodiment takes a large watershed as the study area. In order to capture the spatial heterogeneity of the watershed, three representative automatic monitoring stations located in the upper, middle and lower reaches of the watershed were selected and named US, MS and DS, respectively. Target data: Target water quality indicators refer to any physical, chemical, or biological parameters used to characterize the water quality status; target water quality indicators may include, but are not limited to, dissolved oxygen (DO), permanganate index (DO), etc. ), ammonia nitrogen ( ), total phosphorus (TP), total nitrogen (TN), pH value, turbidity or chlorophyll concentration, etc.; In this embodiment, the target water quality indicator is preferably dissolved oxygen (DO), with the unit being mg / L; its historical time series data is obtained, with a data sampling frequency of once every 4 hours, and a time span from November 2020 to June 2024; Data preprocessing: For missing values ​​in the original DO data caused by sensor maintenance or data transmission failure, cubic spline interpolation is preferably used to fill in the missing values ​​to create a complete time series for model training. Covariate definition: Covariates preferably refer to various auxiliary variables used to describe information about the target water area and its surrounding environment. These variables can be used to help the model predict the target water quality indicators more accurately. In this embodiment, covariates can be further divided into dynamic covariates and static covariates; Dynamic covariates may include, but are not limited to, meteorological data, hydrological data, and / or air quality data that change over time; Static covariates may include, but are not limited to, geographical, topographic, land use, and socioeconomic indicators describing the sub-basin where each monitoring station is located, which are typically or assumed to remain unchanged over the prediction timescale. To fully disclose this application, Table 1 lists a set of combinations of dynamic and static covariates that can be used in this application by way of non-limiting examples, but this application is not limited to this.

[0047] Table 1

[0048] Step S102: Using a causal discovery algorithm based on neural networks, causal dynamic covariates that have a non-linear causal relationship with historical water quality index time series data are screened from the dynamic covariate data; More specifically, traditional deep learning models may rely on spurious correlations in the data rather than real causal drivers, resulting in poor model generalization ability; for example, two variables may be strongly correlated by a third (unobserved) variable, but there is no direct causal relationship between them; step S102 aims to retain only covariates that have a real nonlinear causal driving effect on the target water quality index (DO) through rigorous screening. More specifically, this application employs a two-stage screening method, as follows: Phase 1: Multicollinearity Analysis. Before conducting complex causal discovery, it is necessary to address the multicollinearity problem among dynamic covariates (as shown in Table 1). For example, air quality indicators such as PM2.5, PM10, and AQI are often highly correlated. If left unaddressed, this multicollinearity will interfere with the stability of subsequent causal algorithms. In this embodiment, the Spearman correlation coefficient is first calculated to identify highly correlated variable pairs. Then, the variance inflation factor (VIF) is calculated, and variables with VIF values ​​greater than 10 are iteratively removed until the VIF values ​​of all retained variables are below 10. The second stage: causal discovery. For the covariates initially screened in the first stage, a neural network-based causal discovery algorithm is used. The algorithm implementation is as follows: Figure 3 As shown, the Neural Granger Causality (NGC) algorithm is used to capture non-linear dependencies; Furthermore, the NGC algorithm employs a component long short-term memory network (cLSTM). Working principle as follows Figure 3 As shown, this method identifies nonlinear causal relationships by solving a penalized optimization problem; specifically, a cLSTM model is trained for the target sequence (e.g., DO), based on historical data of the underlying driving factors (e.g., SSR, TP, WT, etc.). The model uses a "group lasso penalty" term in its objective function to predict the value of DO at time t. The key to this model is that it applies this penalty to the weights of the input to the hidden layer of the cLSTM model. )superior; This penalty (mathematically represented as) What makes it unique is that it is designed for use with the first All input weights associated with a covariate (i.e., a "group") are penalized; if past values ​​of a covariate (e.g., TP) do not significantly contribute to the prediction of DO, the penalty term will force the entire weighted group corresponding to it to regroup. The L2 norm of the result approaches zero, thus making all relevant weights zero as a whole; unlike the traditional L1 penalty (which may only make some weights zero), it provides a clear "variable-level" causal relationship judgment. By solving this optimization problem, only those covariates whose weights are not penalized to zero (i.e., variables that make a significant contribution to the prediction) are identified as “causal dynamic covariates” with nonlinear Granger causality and are retained for input into the subsequent TFT model. Implementation results: To demonstrate the effectiveness of step S102 and the interpretability it provides, Table 2 shows the causal drivers of DOs finally identified after screening by the NGC algorithm at the three monitoring sites in this embodiment. Table 2

[0049] Note: A causal strength of 0 indicates that the variable failed the screening and was considered a non-causal variable; Analysis: The results in Table 2 clearly demonstrate the beneficial effect of the proposed method on interpretability: 1. Identifying Spatial Heterogeneity: The algorithm revealed simple differences in driving mechanisms across different sites. Surface solar radiation (SSR) was identified as a causal driver at all three sites (causal strength > 0), which aligns with scientific understanding (SSR is the primary energy source for oxygen production through photosynthesis in aquatic plants). However, water temperature (WT) was identified as a strong causal driver only at the downstream station (causal strength = 0.1893), while it was not causal at the upstream and midstream stations. This may be because the downstream river flow is slower, water exchange is slower, and it is more susceptible to human activities (such as thermal pollution), making water temperature the dominant factor in controlling DO solubility and biological metabolic rate. 2. Elimination of spurious correlations: Many variables that were retained after the first stage (VIF screening) (such as TP, PM2.5, etc.) were identified as having a causal strength of 0 in the second stage (NGC screening), which indicates that their relationship with DO may be indirect or spurious, and their historical information does not contribute significantly to the prediction of future DO. Step S103: Use a multi-scale analysis method (e.g., wavelet decomposition WD method) to decompose the historical water quality index time series data into at least one low-frequency approximate component and multiple high-frequency detail components to construct multi-scale water quality index features. In some specific methods, step S103 specifically includes: Water quality index time series data (such as DO) are the result of complex superposition of multiple physical and biogeochemical processes (such as diurnal cycles, weather disturbances and seasonal cycles), exhibiting highly non-stationary dynamics; this non-stationarity (i.e. the statistical properties of the series change over time) makes it difficult for traditional models to capture its complex patterns. Solutions such as Figure 4 As shown, Figure 4 This is a flowchart of the wavelet decomposition (WD) method in the embodiments of this application. This step uses the WD method to decompose a complex, non-stationary original water quality index sequence (e.g., DO) into multiple relatively stationary subsequences of different frequencies (scales). This is like decomposing a complex beam of light into monochromatic light of different colors, making it easier for the model to learn the patterns of each component (e.g., long-term trends, periodic fluctuations, and short-term noise). Mother wavelet selection: Preferably, the embodiments of this application use the Daubechies-4 (db4) mother wavelet, which performs well in analyzing environmental signals with transient characteristics due to its good orthogonality and compact support properties; Decomposition configuration: The number of decomposition layers and the specific components used as features are crucial to model performance. This application provides a preferred configuration that aims to balance the representation of effective signals with the removal of high-frequency noise. In a preferred embodiment, the optimal decomposition configuration was determined through a series of comparative experiments, such as Figure 4 As shown, the original DO signal was decomposed into 8 layers; Multi-scale water quality indicators include: At least one low-frequency approximation component, preferably Quantity, such as Figure 4 As shown, The components represent the long-term trend of a water quality indicator series (such as dissolved oxygen). Multiple mid-to-high frequency detail components, preferably Quantity, such as Figure 4 As shown, these represent fluctuations and periodicity at different scales; And exclude one or more high-frequency noise components, preferably Quantity, such as Figure 4 As shown, and The components are usually high-frequency, irregular random noise, and using them as feature inputs to the model will actually reduce performance. Implementation results: To prove this specific configuration (i.e. ,exclude The superiority and non-obviousness of TFT models are shown in Table 3, which presents a performance comparison of TFT models when using different wavelet decomposition feature sets. Table 3

[0050] It should be pointed out here that This indicates that the detail components from layers n to m and the approximate components from layer m are used as features; the lower the evaluation metrics (such as MAPE, AQL), ​​the better, and the closer the NSE is to 1, the better. The data in Table 3 clearly demonstrates the inventiveness of the preferred configuration in this application; (1) Comparison ( (AQL=0.1278) and ( (AQL=0.1241), it can be seen that, excluding After removing the noise component, the model's probabilistic prediction performance (AQL) and point prediction performance (MAPE and NSE) were both improved. (2) Comparison ( (AQL=0.1241) and ( (AQL=0.1339), it can be seen that if additional exclusions are made... The component will significantly reduce performance, indicating The components carry valuable information that is crucial for prediction. therefore, It represents a preferred balance between noise removal and retention of useful information, and is a non-obvious beneficial configuration obtained through technical experiments and optimizations in this application.

[0051] Step S104: Input the causal dynamic covariates, multi-scale water quality index characteristics and static covariate data into a probabilistic time series prediction model (e.g., TFT model). Step S105: Train the TFT model to output probabilistic predictions of water quality index concentrations for multiple future time steps in the target water area.

[0052] The following provides a detailed explanation of steps S104 and S105, such as... Figure 5 As shown, Figure 5 This is a schematic diagram of the internal structure of the TFT in the embodiment of this application; in the embodiment of this application, the timing fusion Transformer (TFT) model is preferably used as a specific example of the timing prediction model, which is used to fuse all the information generated in steps S101, S102 and S103 and output the final prediction result; Model Input: As in step S104, input the following three types of data into the TFT model together: (1) Causal dynamic covariates (from step S102, such as SSR and WT as shown in Table 2); (2) Multi-scale water quality index characteristics (from step S103, as shown in Table 3) , (Quantity); (3) Static covariate data (from S101, such as Elev, Slope, Lat, etc. as shown in Table 1). Prediction task settings: In one specific embodiment, to meet the need for early warning in water environment management (e.g., responding 3 days in advance), the model is configured as a multi-step prediction task: Input: Using the past 42 time steps (i.e., 42...) All historical data (4 hours = 168 hours, approximately 7 days) are used as the "review window" for TFT; Output: Predict the next 18 time steps (i.e., 18...) Water quality index concentrations (e.g., DO concentration) within 4 hours (approximately 72 hours, or 3 days). Predicting task output: One of the beneficial effects of this application is the quantification of uncertainty; The probabilistic prediction result is not a single point prediction value, but preferably includes multiple quantiles; in this embodiment, the model is trained to simultaneously output the 10th, 50th (median) and 90th percentiles. Constructing prediction intervals using multiple quantiles; for example, using the 10th and 90th percentiles to construct a 90% prediction interval, provides decision-makers with a confidence range for the prediction, such as a 90% probability that the concentration of a water quality indicator (e.g., DO concentration) falls within this range, which is crucial for risk assessment. In some implementations, the TFT model utilizes its unique architecture to handle both static and dynamic data, such as Figure 5 As shown, the TFT model includes a static processing path for processing static covariates, such as a static encoder. The static encoder encodes static covariate data (such as Elev, Slope, and Lat in Table 1) into a set of context vectors. The context vectors are used to regulate the TFT model's processing of dynamic time series data. These context vectors are used to regulate the behavior of the gated recurrent unit (GRU) and attention layer within the TFT. Regarding the training method, this application adopts a multi-site training method, which merges data from multiple monitoring stations (upstream, midstream and downstream) to train a global model (e.g., a global TFT model). Traditionally, training a "global model" for the upstream, midstream and downstream of a watershed (whose physical characteristics, hydrological conditions and pollution sources are very different) is usually ineffective because the model cannot distinguish their respective characteristics. Therefore, this application uses a combination of multi-site training and static covariate adjustment of dynamic data items to train the model. More specifically, multi-site training forces the global model to learn the physical laws common to all sites (e.g., the day-night response pattern of DO to SSR); static covariates act as background signals; the static encoder of the TFT encodes the static features of the sites (such as those of upstream or downstream sites) into "context vectors"; these context vectors adjust the processing of dynamic data within the TFT. When the model processes data from upstream sites, the context vectors with [Elev=high] cause the internal networks of the TFT (such as attention mechanisms) to operate in a specific mode (e.g., high turbulence, high reoxygenation rate mode); when the model switches to processing downstream data, the context vectors with [Elev=low] switch it to another mode (e.g., low flow rate, WT-dominated mode). This architecture enables a single global model to learn shared patterns and distinguish the heterogeneity of specific sites simultaneously, greatly improving the model's generalization ability and data utilization efficiency. In some implementations, to ensure that those skilled in the art can reproduce the model, the core hyperparameters of the TFT model are set as follows: Hidden layer dimension (Hidden_size): 64; Number of network layers (Num_layers): 2; Multi-head attention count (Num_heads_attention): 8; Random dropout rate: 0.3; Optimizer: Adam; Learning rate: 0.001; Maximum training epochs (Max_epochs): 100; Patience (stop early): 10.

[0053] Explainable Implementation Examples: Another key effect of this application lies in interpretability and transparency, overcoming the black-box limitations of deep learning models; this embodiment achieves interpretability through a unique mechanism built into the time series prediction model (e.g., the TFT model); specifically: Firstly, the importance of global variables. As shown in Figures 6(a) and 6(b), these figures represent the variable importance analysis results of the time series prediction model (TFT model) in this embodiment of the application. The specific mechanism is as follows: through the variable selection network built into the time series prediction model (TFT model), this network automatically learns and outputs the global importance ranking of all input variables (including the causal dynamic covariates of S102, the multi-scale water quality index characteristics of S103, and the static covariates of S101) to the prediction results during the training process. Analysis of Figures 6(a) and 6(b) shows that (1) the characteristics of multi-scale water quality indicators (e.g.) (1) The components showed the highest importance at all sites, which in turn verified the extreme importance of step S103 (WD feature engineering), that is, the model confirmed that the decomposed subsequence is the most relied-upon prediction basis; (2) The importance ranking of static covariates (especially Slope and Elev) was very high, even exceeding that of some dynamic covariates (such as SSR or WT). The high importance ranking of static variables (such as slope) proves that the model relies heavily on the basic physical environment characteristics of the site when making predictions; the model learns not a simple statistical relationship of DO(t-1)D->O(t), but a deeper physical mechanism (e.g.: river slope -> water flow turbulence degree -> atmospheric reoxygenation rate -> water quality index concentration (DO concentration)); this proves that the TFT model provided in this application is trustworthy and transparent, and its prediction logic conforms to the basic principles of water environment science.

[0054] The second aspect: Time attention mechanism As shown in Figures 7(a) and 7(b), this application provides an analysis diagram of the time attention mechanism of a time series prediction model (TFT model). The mechanism principle is as follows: through the interpretable self-attention mechanism built into the time series prediction model (e.g., TFT model), this mechanism allows for how to dynamically allocate attention to different past time points when making predictions. Analysis 1: Long-term pattern dependence. As shown in Figure 7(a), the average attention weight distribution of the model at all time steps was analyzed. It was found that when the model was predicting, its attention peak did not appear at the most recent time point (such as -1 or -2 steps, i.e. 4 to 8 hours ago), but was unconsciously concentrated at about -35 time steps (i.e. about 5 to 7 days ago). Analysis revealed that the concentration of water quality index (DO concentration) is affected not only by the day's sunshine (SSR), but also by the algal biomass (the basis of photosynthesis) and organic matter (the basis of oxygen consumption) accumulated over the past week. The model autonomously learned this biogeochemical lag of about 7 days, which once again proves that it has learned the dynamics of the real aquatic ecosystem, rather than a simple statistical fit.

[0055] Analysis 2: Anomaly detection. As shown in Figure 7(b), this application embodiment analyzes attention distance; the specific mechanism is as follows: attention distance is a quantitative indicator used to measure the instantaneous attention pattern of the model at a specific time t. Its average attention pattern across the entire dataset Deviation between; As can be seen from Figure 7(b), when the water quality index series (DO) is stable, the distance remains low (see the left subplot); however, when the water quality index series (e.g., DO) experiences abrupt changes or abnormal fluctuations (e.g., possible pollution events, extreme weather, or reservoir releases), the attention distance surges (see the right subplot). This demonstrates that the time-series prediction model is not only a predictor but also an unsupervised anomaly detector. It can automatically mark the moment when non-standard changes (i.e., abnormal events) occur in the system dynamics by using the peak of the attention distance, providing a brand-new early warning tool for water environment early warning systems based on the internal state of the model, far exceeding traditional threshold-based alarms.

[0056] Quantitatively verify the effectiveness of the implementation examples In order to fully verify the technical solution provided in this application (i.e., the combination of S101 to S105), the embodiments of this application have undergone a series of rigorous component contribution analyses.

[0057] Experimental setup: To quantify the contribution of each key step (S102, S103, and S104) in this application, the embodiments of this application compared the following five model configurations: First configuration: TFT (baseline model): Autoregressive prediction using only historical DO data; Second configuration: D-TFT: baseline + dynamic covariates of all preliminary screening (VIF) (i.e., the traditional method without causal screening); Third configuration: NGC-TFT: baseline + S102-screened causal covariates to verify the contribution of S102; Fourth configuration: NGC-WD-TFT: baseline + S102 covariates + S103 multi-scale features; verify the contribution of S103, but still train on a single site; Fifth configuration: NGC-WD-S-TFT (preferred scheme in this application): Based on the fourth configuration, S104 static covariates are added and the multi-site training method of S104 is adopted to verify the contribution of S104 and the multi-site method; The model performance was evaluated using standard metrics: Point prediction: MAPE (mean absolute percentage error, the lower the better) and NSE (Nash efficiency coefficient, the closer to 1 the better); Probability prediction: AQL (mean quantile loss, the lower the better, comprehensive evaluation of the prediction range).

[0058] Implementation Results: Table 4 shows the performance comparison of the above five model configurations on the test sets of three monitoring stations (upstream, midstream and downstream); Table 4

[0059] Table 4 provides irrefutable quantitative data demonstrating the necessity and advancement of each key step in this application, as well as the synergistic benefits they bring when combined: (1) Prove the necessity of S102 (causal screening): Comparing the baseline TFT and the D-TFT (with all covariates included), the performance of the D-TFT (e.g., AQL) was inferior to that of the baseline TFT at all three stations; for example, at the downstream station, the AQL deteriorated from 0.0849 to 0.1049. This shows that simply adding covariates introduces noise and spurious correlations, contaminates the model, and leads to performance degradation. Comparing D-TFT (AQL=0.1049) and NGC-TFT (AQL=0.0828), the model performance was significantly improved after the S102 causal screening, and it was better than the baseline. This shows that the S102 causal screening step is necessary and non-obvious. It significantly improves the model performance and robustness by eliminating harmful spurious variables. (2) Prove the necessity of S103 (multiscale analysis). Comparing NGC-TFT (downstream AQL=0.0828) and NGC-WD-TFT (downstream AQL=0.0704), the addition of S103 multi-scale features ( , After that, the performance of all stations was further significantly improved; it can be seen that the multi-scale analysis step S103 effectively solved the non-stationarity problem of water quality index series (such as DO).

[0060] (3) Prove the necessity of S104 (static covariates + multiple sites): Comparing NGC-WD-TFT (downstream AQL=0.0704) and NGC-WD-S-TFT (downstream AQL=0.0596), the model performance reached its best after adding the static covariates in step S104 and adopting the multi-site training method. This shows that the static covariate processing in step S104 and the multi-site training method (implemented through context vectors) are the key to achieving the highest accuracy. The preferred embodiment of this application (NGC-WD-S-TFT) achieves optimal performance at all three sites, for example, at the downstream site, it achieves a MAPE of 2.955%, an NSE as high as 0.9659, and an AQL as low as 0.0596; demonstrating that each technical step in S102, S103, and S104 of this application is inventive, and that together they produce a synergistic gain effect of 1+1+1>3.

[0061] Example 2 Figure 8 This is a structural diagram of the prediction system provided in the embodiments of this application, as shown below. Figure 8 As shown, a water quality index interpretability probabilistic prediction system is used to perform the method in Example 1. The system includes: Data acquisition module 810: used to execute step S101 in embodiment 1, and acquire historical time series data of target water quality indicators of target water area, a set of dynamic covariate data and a set of static covariate data; Causal screening module 820: used to execute step S102 in embodiment 1, using a neural network-based causal discovery algorithm (preferably NGC) to screen out causal dynamic covariates that have a non-linear causal relationship with historical water quality index time series data from dynamic covariate data; Feature engineering module 830: Used to perform step S103 in Example 1, employing a multi-scale analysis method (e.g., wavelet decomposition WD method) to decompose historical water quality index time series data into multiple components of different scales (preferably... , ), construct multi-scale water quality indicator characteristics; Prediction model module 840: used to execute steps S104 and S105 in Example 1. This module integrates a time series prediction model (preferably a time series fusion Transformer, TFT) to receive causal dynamic covariates, multi-scale water quality index characteristics and static covariate data, and outputs probabilistic prediction results of water quality index concentrations of the target water area at multiple future time steps through the time series prediction model (e.g., TFT model).

[0062] It should be understood that the above system is used to execute the method in Embodiment 1 above. The corresponding program modules in the system are similar in implementation principle and technical effect to those described in the above method. The working process of the system can be referred to the corresponding process in the above method, and will not be repeated here.

[0063] In summary, this application has the following advantages compared with the prior art: High accuracy and robustness: Redundant and pseudo-correlated variables are eliminated through a two-stage screening method (including multicollinearity analysis and NGC algorithm), and non-stationarity is handled through multi-scale analysis (such as WD decomposition), providing the model with purer and richer multi-scale information, which significantly improves the accuracy of point prediction (such as reducing MAPE and improving NSE).

[0064] Uncertainty Quantification: The method provided in this application uses a probabilistic time series prediction model (such as the TFT model) to directly output probabilistic prediction results (prediction intervals) instead of a single point prediction. This method can reliably quantify the uncertainty of the prediction (such as providing reliable AQL and CR indicators), providing a key basis for water environment risk management.

[0065] Explainability and Transparency: This application overcomes the black-box limitations of traditional deep learning models. First, NGC clarifies the causal drivers upon which the model relies; second, TFT's built-in interpretability tools (variable importance ranking and attention weight distribution) make the model's prediction process transparent and auditable, enhancing decision-makers' trust in the model.

[0066] Strong generalization ability: By combining static covariates and multi-site training methods, the model in this application can effectively learn the spatial heterogeneity between different sites, giving it good transferability and wide applicability.

[0067] Example 3 Figure 9 This is an architectural diagram of the electronic device provided in an embodiment of this application. For example... Figure 9 As shown, this application embodiment provides an electronic device (such as a server, workstation, or dedicated water monitoring terminal), which may include: a processor 910, a memory 920, and a communication bus 930.

[0068] Communication bus 930: Used to enable communication between processor 910 and memory 920.

[0069] Memory 920: Used to store computer programs. The memory may include high-speed random access memory (RAM) or non-volatile memory (ROM), such as at least one disk storage device. The computer program includes instructions for performing the method described in Embodiment 1 (S101-S105).

[0070] Processor 910: Used to execute a program stored in memory 920. When the program stored in memory is executed, processor 910 is used to perform the method as described in any one of claims 1 to 8.

[0071] It is understood that the processor 910 in the embodiments of this application may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices.

[0072] It is understood that the various numerical designations used in the embodiments of this application are merely for the convenience of description and are not intended to limit the scope of the embodiments of this application.

[0073] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A water quality prediction method coupling causal discovery and deep learning, characterized in that, Includes the following steps: Step 1: Use a neural network-based causal discovery algorithm to perform causal screening on dynamic covariates and identify causal dynamic covariates; Step 2: Input the causal dynamic covariates, multi-scale water quality index characteristics, and static covariate data into the trained probabilistic time series prediction model, and output the probabilistic prediction results of the water quality index concentrations of the target water area at multiple future time steps.

2. The water quality prediction method according to claim 1, characterized in that, Step one is as follows: By calculating the Spearman correlation coefficient and variance inflation factor of dynamic covariate data, dynamic covariates with correlation exceeding the preset value are removed. The neuro-Granger causality algorithm is used to perform causal screening on the remaining dynamic covariates and identify causal dynamic covariates.

3. The water quality prediction method according to claim 1 or 2, characterized in that, The method for obtaining multi-scale water quality index characteristics is as follows: Historical water quality index time series data are decomposed into multiple subsequences of different frequencies using wavelet decomposition, and the highest frequency noise component is eliminated to construct multi-scale water quality index features.

4. The water quality prediction method according to claim 2, characterized in that, The Neural Granger Causality Algorithm employs a component-based Long Short-Term Memory network and identifies causal relationships by imposing a sparsity penalty.

5. The water quality prediction method according to claim 1, characterized in that, The probabilistic time series prediction model adopts the TFT model, which includes a static processing path for processing static covariates and a dynamic processing path for processing dynamic time series. The static processing path encodes the static covariate data into a set of context vectors, and uses the context vectors to adjust the dynamic processing path by controlling the dynamic time series.

6. The water quality prediction method according to claim 1 or 5, characterized in that, The causal dynamic covariates, multi-scale water quality index characteristics, static covariate data, and water quality index concentrations from different monitoring stations are combined and input into a probabilistic time series prediction model for training. The static covariates are encoded as context vectors to adjust the dynamic time series of different stations, enabling probabilistic prediction of water quality index concentrations at different stations at different times.

7. The water quality prediction method according to claim 1 or 5, characterized in that, The probabilistic time series prediction model has a built-in variable selection network to automatically learn and output the global importance score of all input variables to the probabilistic prediction result, and has a built-in interpretable self-attention mechanism to dynamically assign attention to input variable data at different historical time points.

8. A water quality prediction system coupling causal discovery and deep learning, characterized in that, include: The causal screening module is used to perform causal screening on dynamic covariates using a neural network-based causal discovery algorithm to identify causal dynamic covariates. The prediction model module is used to input causal dynamic covariates, multi-scale water quality index characteristics, and static covariate data into the trained probabilistic time series prediction model, and output the probabilistic prediction results of water quality index concentrations at multiple future time steps in the target water area.

9. The water quality prediction system according to claim 8, characterized in that, The causal screening module includes a primary screening unit and a secondary screening unit; The initial screening unit is used to remove dynamic covariates whose correlation exceeds a preset value by calculating the Spearman correlation coefficient and variance inflation factor of the dynamic covariate data. The second screening unit is used to perform causal screening on the remaining dynamic covariates using the neural Granger causality algorithm to identify causal dynamic covariates.

10. The water quality prediction system according to claim 8 or 9, characterized in that, The prediction model module includes a static processing unit and a dynamic processing unit. The static processing unit encodes static covariate data into a set of context vectors to process dynamic time series from different sites. The dynamic processing unit executes the dynamic processing path for processing dynamic time series.