A method and system for identifying changes in water quality at a water plant intake

CN121410216BActive Publication Date: 2026-08-07天津智云水务科技有限公司 +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
天津智云水务科技有限公司
Filing Date
2025-11-03
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

一方面,现有技术难以有效挖掘水质参数间的因果关联关系,仅基于参数间的相关性进行分析,易将虚假相关误认为真实关联,导致对水质变化的诱因判断不准确,进而影响识别结果的可靠性,无法为后续水质调控提供精准的因果依据

Benefits of technology

[0015]Beneficial Effects: This invention proposes a method and system for identifying changes in the influent water quality of water plants. Through a hybrid model based on causal inference, it delves into the causal relationships among multiple water quality parameters, including turbidity, pH, dissolved oxygen content, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration, generating a corresponding causal correlation weight matrix. This effectively avoids misclassifying spurious correlations as genuine correlations, providing accurate causal evidence for determining the causes of water quality changes. Addressing the problems of incomplete feature extraction and unreasonable result fusion in existing technologies, this method combines a bidirectional long short-term memory network with an attention mechanism. This achieves comprehensive extraction of forward and backward temporal features of the water quality parameter sequence while accurately assessing the importance of different feature dimensions. Furthermore, relying on a gradient booster ensemble model, multiple base learners learn the features in parallel, and the local recognition results output by each base learner are dynamically weighted and fused, fully utilizing feature information while significantly improving the reliability of the recognition results. This method and system achieve deep integration of multi-dimensional water quality parameter information, accurately identify the types of changes in influent water quality, provide strong support for timely adjustment of water treatment processes, and ensure the safety of effluent water quality. The units within the system have clear division of labor and work together efficiently, forming a complete and efficient processing flow from water quality parameter collection to final identification result output, significantly improving the efficiency of water plant operation and management, and effectively meeting the actual needs of water plants for high-precision and high-reliability identification of changes in influent water quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121410216B_ABST
    Figure CN121410216B_ABST
Patent Text Reader

Abstract

The application discloses a kind of water plant influent water quality change identification method and system, method collects water plant influent port turbidity, pH value, dissolved oxygen content, COD concentration, ammonia nitrogen concentration, total phosphorus concentration and other parameters and eliminates abnormal value, constructs water quality parameter time series dataset;Through the causal inference-based hybrid model, the causal relationship between parameters is mined and a weight matrix is generated. After fusing the matrix with the time series data, bidirectional long short-term memory network combined with attention mechanism is used to extract bidirectional time features and assign attention weights. The preliminary recognition result is obtained by inputting the integrated model of gradient boosting machine into multiple base learners for parallel learning and dynamically weighting and fusing local results. Finally, the change type is determined by mapping to the water quality change type space. The system includes six units, from water quality parameter collection to final recognition result output, forming a complete and efficient processing flow, which effectively meets the actual needs of water plant for high-precision and high-reliability identification of influent water quality change.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of water quality change identification, and more particularly to a method and system for identifying changes in the influent water quality of a water plant. Background Technology

[0002] During water plant operation, the stability of the influent water quality directly affects the efficiency of subsequent water treatment processes and the safety of the effluent water quality. Water quality parameters at the water plant inlet are affected by various factors such as industrial wastewater discharge, agricultural non-point source pollution, and climate change, often resulting in abnormal fluctuations in parameters such as turbidity, pH value, dissolved oxygen content, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration. Failure to identify these water quality changes in a timely and accurate manner can easily lead to imbalances in the dosage of water treatment chemicals, unstable operation of the treatment process, and even problems with effluent exceeding standards, adversely affecting the safety of residents' drinking water and the normal operation of the water plant. Therefore, achieving efficient identification of changes in the influent water quality is a key requirement in water plant operation and management.

[0003] In existing technologies, the identification of changes in influent water quality at water treatment plants often employs a single model or a simple combination of models. Some technologies rely on traditional statistical analysis methods, using trend analysis and threshold judgments on historical water quality parameter data to determine whether water quality has changed. Other technologies utilize basic machine learning models, such as single long short-term memory networks or gradient boosting machines, to extract features and identify changes in water quality parameter time series data. However, these technologies can only utilize surface-level correlations or single-dimensional features, failing to fully explore the deep correlations between water quality parameters and the complex features over time, and lack effective integration of the advantages of different models.

[0004] Existing technologies have two significant drawbacks. Firstly, they struggle to effectively uncover causal relationships between water quality parameters. Analysis based solely on correlations can easily misinterpret spurious correlations as genuine ones, leading to inaccurate assessments of the causes of water quality changes and consequently affecting the reliability of the identification results. This makes it impossible to provide accurate causal evidence for subsequent water quality control. Secondly, existing technologies have shortcomings in feature extraction and result fusion. They either only extract unidirectional temporal features, ignoring the potential impact of future time dimensions on current water quality changes, or they employ simple averaging or fixed weighting methods when fusing multi-model results, failing to dynamically adjust weights based on model performance. This results in insufficient feature utilization and limited accuracy of the identification results, making it difficult to meet the high-precision identification needs of water plants for changes in influent water quality. Summary of the Invention

[0005] In order to overcome the shortcomings and deficiencies of the existing technology, the present invention provides a method and system for identifying changes in the influent water quality of a water plant.

[0006] The technical solution adopted in this invention is a method for identifying changes in the influent water quality of a water treatment plant, comprising the following steps: Step S1: Collect multiple water quality parameters from the water plant inlet for a continuous preset time period. These parameters include at least turbidity, pH, dissolved oxygen, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration. Outlier removal is performed on the collected data, retaining only those that meet preset data validity standards. Step S2: Divide the water quality parameter screening data into multiple data subsets according to preset time intervals. Each subset corresponds to a time segment, constructing a water quality parameter time series dataset. Step S3: Input the water quality parameter time series dataset into a causal inference-based hybrid model. The model mines the causal relationships between different water quality parameters, determines the causal influence strength of different water quality parameters over time, and outputs a causal association weight matrix corresponding to different water quality parameters. Step S4: Fuse the causal association weight matrix with the water quality parameter time series dataset to obtain a water quality parameter sequence with fused causal information. The input is fed into a model combining a bidirectional long short-term memory network and an attention mechanism. The bidirectional long short-term memory network extracts forward and backward time features from the water quality parameter sequence that integrates causal information, resulting in a bidirectional time feature vector. Then, the attention mechanism evaluates the importance of different feature dimensions in the bidirectional time feature vector and assigns attention weights to different feature dimensions, generating a feature vector with attention weights. Step S5: The attention-weighted feature vector is input into a gradient booster ensemble model. Multiple base learners in the gradient booster ensemble model perform parallel feature learning on the attention-weighted feature vector. Each base learner outputs a corresponding local water quality change feature recognition result. All local water quality change feature recognition results are weighted and fused to obtain a preliminary water quality change recognition result. Step S6: The preliminary water quality change recognition result is processed by feature mapping, mapping it to a preset water quality change type partitioning space to determine the specific change type corresponding to the water quality of the water plant influent, thus completing the water plant influent water quality change recognition process. Furthermore, in step S3, when using the hybrid model based on causal inference to explore the causal relationships between different water quality parameters, a causal relationship strength calculation model is adopted. The expression for the causal relationship strength calculation model is as follows: in, This represents the causal relationship strength between the i-th water quality parameter and the j-th water quality parameter at time t. This indicates that the i-th water quality parameter is in The value at time, This represents the value of the j-th water quality parameter at time t, and n represents the preset time lag window length. The coefficient represents the inherent correlation between the i-th water quality parameter and the j-th water quality parameter, with a value range of [0.1, 0.9]. The water quality parameters include turbidity. pH value Dissolved oxygen content COD concentration ammonia nitrogen concentration Total phosphorus concentration In step S4, when the bidirectional long short-term memory network combined with the attention mechanism generates feature vectors with attention weights, an attention weight calculation model is used. The expression of the attention weight calculation model is as follows: in, This represents the attention weight corresponding to the m-th bidirectional temporal feature vector. This represents the m-th bidirectional time feature vector. Let M represent the average eigenvector of all bidirectional time eigenvectors, and M represent the total number of bidirectional time eigenvectors. This represents the attention score calculation function, which uses cosine similarity as the calculation method.

[0007] Furthermore, in step S5, when the gradient boosting machine ensemble model performs parallel feature learning on the feature vector with attention weights, it adopts a base learner weight allocation model, the expression of which is: in, This represents the weight of the q-th base learner. This represents the feature learning accuracy of the q-th base learner on the validation dataset. The difference between the feature learning results of the q-th base learner and other base learners is represented by Q, where Q represents the total number of base learners. In step S5, when weighting and fusing the local water quality change feature identification results, a fusion result calculation model is used, and the expression for the fusion result calculation model is: ,in, This indicates the preliminary results of water quality change identification. This represents the local water quality change feature recognition result output by the q-th base learner.

[0008] Furthermore, in step S3, when the hybrid model based on causal inference outputs the causal association weight matrix, the weight matrix is ​​used to update the model. The expression for the weight matrix update model is: ,in, express Causal correlation weight matrix under iteration number, This represents the causal correlation weight matrix at iteration number t. This represents the matrix update step size, with a value range of 1. , The loss function L represents the weight matrix at iteration number t. The gradient; in step S4, when the bidirectional long short-term memory network extracts the bidirectional temporal feature vector, a gated update model is adopted, and the expression of the gated update model is: , in, These represent the output values ​​of the input gate, forget gate, and output gate, respectively. This represents the sigmoid activation function. These represent the weight matrices corresponding to different gates. These represent the bias terms corresponding to different gates. express The hidden state at all times This represents the input features at time t. Indicates the state of candidate cells. This represents the cell state at time t. This represents the hidden state at time t. This represents element-wise multiplication.

[0009] Furthermore, in step S5, when the base learner of the gradient boosting machine ensemble model performs feature learning, a loss function is used to optimize the model. The expression for the loss function optimization model is: ,in, This represents the value of the loss function. Let K represent the set of parameters for the base learner, and K represent the number of training samples. This represents the true label of the k-th training sample. This represents the predicted output value of the base learner for the k-th training sample; in step S6, when performing feature mapping processing on the preliminary water quality change identification results, a mapping model is used, and the expression of the mapping model is: in, This represents the mapped water quality change type identifier value. This represents the minimum value indicating the initial water quality change identification result. This represents the maximum value of the preliminary water quality change identification results. This represents the minimum identifier value in the spatial classification of water quality change types. This represents the maximum identifier value in the spatial classification of water quality change types.

[0010] Furthermore, before mining causal relationships using the hybrid model based on causal inference in step S3, a causal relationship initialization model is used. The expression for the causal relationship initialization model is: ,in, This represents the initial value indicating the causal relationship between the i-th and j-th water quality parameters. This represents the covariance between the i-th and j-th water quality parameters. This represents the variance of the i-th water quality parameter. Let j represent the variance of the j-th water quality parameter. This represents the initial adjustment coefficient, with a value range of [value range missing]. In step S4, when the attention mechanism evaluates the importance of feature dimensions, a feature importance calculation model is used. The expression for the feature importance calculation model is as follows: ,in, This represents the importance index of the m-th feature dimension. This represents the value of the m-th feature dimension in the k-th sample. This represents the average value of the m-th feature dimension. This represents the attention weight of the m-th feature dimension in the k-th sample, where K represents the number of training samples.

[0011] Further, step S3 specifically includes the following sub-steps: S31: The water quality parameter time series dataset is split into multiple single-parameter time series according to the water quality parameter type. Each single-parameter time series corresponds to the change data of a water quality parameter within a preset time period. Each single-parameter time series is segmented in the time dimension to obtain multiple single-parameter time segment sequences. Each single-parameter time segment sequence contains a preset number of time point data. S32: Different single-parameter time segment sequences are input into the causal detection module of the hybrid model based on causal inference. The causal detection module calculates the lag correlation coefficient between the single-parameter time segment sequences corresponding to any two water quality parameters. Based on the lag correlation coefficient, the possible causal relationship between the two water quality parameters is determined. S33: Based on the preliminary causal relationship direction information, construct a preliminary causal relationship graph. In the preliminary causal relationship graph, each node represents a water quality parameter, and each edge represents the preliminary causal relationship between two water quality parameters. Verify the causal strength of each edge in the preliminary causal relationship graph, and remove edges with causal strength lower than a preset strength threshold to obtain an optimized causal relationship graph. S34: According to the optimized causal relationship graph, extract the causal association information corresponding to different water quality parameters, convert the causal association information into a matrix form, and generate a causal association weight matrix corresponding to different water quality parameters. The value of each element in the causal association weight matrix represents the strength of the causal association between the corresponding two water quality parameters.

[0012] Further, step S4 specifically includes the following sub-steps: S41: Multiply each element in the causal association weight matrix with the corresponding water quality parameter data at the same time point in the water quality parameter time series dataset to obtain water quality parameter data with causal weights. Arrange all water quality parameter data with causal weights in chronological order to form a water quality parameter sequence that integrates causal information. The water quality parameter sequence that integrates causal information retains the chronological order of the original water quality parameter time series. S42: Divide the water quality parameter sequence that integrates causal information into multiple input sub-sequences according to a preset sequence length. Each input sub-sequence serves as input data for a bidirectional long short-term memory network. Input the input sub-sequences into the forward propagation layer and the backward propagation layer of the bidirectional long short-term memory network. The forward propagation layer processes the input sub-sequences from the start time to the end time. Feature extraction is performed. The backpropagation layer extracts features from the input subsequence from the end of time to the beginning of time. S43: The local feature vectors output by the forward and backpropagation layers at each time point are obtained respectively. The forward and back local feature vectors at the same time point are concatenated to obtain the bidirectional time feature vector corresponding to that time point. The bidirectional time feature vectors of all time points are combined in chronological order to form a set of bidirectional time feature vectors. S44: The set of bidirectional time feature vectors is input into the attention mechanism module. The attention mechanism module calculates the similarity between each bidirectional time feature vector and the preset reference vector. The attention weight corresponding to each bidirectional time feature vector is determined according to the similarity. Each bidirectional time feature vector is multiplied by the corresponding attention weight to obtain a feature vector with attention weight.

[0013] Further, step S5 specifically includes the following sub-steps: S51: The feature vector with attention weights is divided into multiple feature sub-vectors, each containing a preset number of feature dimensions. Each feature sub-vector corresponds to a base learner in the gradient boosting machine ensemble model. Different feature sub-vectors are input into their respective base learners; S52: Each base learner performs feature transformation processing on the input feature sub-vectors, mapping them to a high-dimensional feature space through a preset feature transformation function to obtain high-dimensional feature vectors. Decision trees are constructed from these high-dimensional feature vectors by recursively dividing the high-dimensional feature space to generate decision tree structures. Each decision tree... Each leaf node corresponds to a local water quality change feature recognition result; S53: The validity of the local water quality change feature recognition result output by each base learner is checked. The local water quality change feature recognition result is compared with the corresponding real feature result in the validation set. The error value of the local water quality change feature recognition result is calculated, and the local water quality change feature recognition result with an error value lower than the preset error threshold is retained; S54: Based on the performance indicators of different base learners during the training process, the weight coefficient corresponding to each base learner is determined. The different local water quality change feature recognition results are multiplied with the corresponding weight coefficients, and then all multiplication results are summed to obtain the preliminary water quality change recognition result.

[0014] A water quality change identification system for a water treatment plant influent includes: The system comprises several components: a multi-dimensional water quality parameter acquisition unit (MMG unit, CE unit, COD unit, ammonia nitrogen unit, and total phosphorus unit), a time series dataset construction unit, a time series dataset construction unit, a causal correlation mining and weight matrix generation unit, a causal correlation weight matrix, and a feature extraction unit that integrates causal information. The MMG unit collects data on turbidity, pH, dissolved oxygen, COD, ammonia nitrogen, and total phosphorus concentration at the water plant inlet for a preset duration, removes outliers, and outputs screening data. The MMG unit receives the screening data, divides the data into subsets according to preset time intervals, and constructs the time series dataset. The CE unit receives the time series dataset, mines causal correlations between water quality parameters using a hybrid model based on causal inference, and outputs the causal correlation weight matrix. The system comprises the following units: a feature extraction unit (connected to the causal association mining and weight matrix generation unit and the time series dataset construction unit), a gradient boosting ensemble recognition unit (connected to the gradient boosting ensemble recognition unit), a gradient boosting ensemble model ... and a gradient boosting ensemble model (connected to the gradient boosting ensemble recognition unit).

[0015] Beneficial Effects: This invention proposes a method and system for identifying changes in the influent water quality of water plants. Through a hybrid model based on causal inference, it delves into the causal relationships among multiple water quality parameters, including turbidity, pH, dissolved oxygen content, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration, generating a corresponding causal correlation weight matrix. This effectively avoids misclassifying spurious correlations as genuine correlations, providing accurate causal evidence for determining the causes of water quality changes. Addressing the problems of incomplete feature extraction and unreasonable result fusion in existing technologies, this method combines a bidirectional long short-term memory network with an attention mechanism. This achieves comprehensive extraction of forward and backward temporal features of the water quality parameter sequence while accurately assessing the importance of different feature dimensions. Furthermore, relying on a gradient booster ensemble model, multiple base learners learn the features in parallel, and the local recognition results output by each base learner are dynamically weighted and fused, fully utilizing feature information while significantly improving the reliability of the recognition results. This method and system achieve deep integration of multi-dimensional water quality parameter information, accurately identify the types of changes in influent water quality, provide strong support for timely adjustment of water treatment processes, and ensure the safety of effluent water quality. The units within the system have clear division of labor and work together efficiently, forming a complete and efficient processing flow from water quality parameter collection to final identification result output, significantly improving the efficiency of water plant operation and management, and effectively meeting the actual needs of water plants for high-precision and high-reliability identification of changes in influent water quality. Attached Figure Description

[0016] Figure 1 This is a flowchart of the method steps of the present invention; Figure 2 This is a diagram showing the system unit composition of the present invention. Detailed Implementation

[0017] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. The application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0018] like Figure 1 As shown, a method for identifying changes in the influent water quality of a water treatment plant includes the following steps: Step S1: Collect multiple water quality parameters from the water plant inlet for a continuous preset time period. The water quality parameters include at least turbidity, pH value, dissolved oxygen content, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration. Perform outlier removal on the collected water quality parameter data and retain the water quality parameter screening data that meets the preset data validity standards. Specifically, step S1 is the basic data preparation stage for identifying changes in the water quality of the water plant's influent. Its core function is to acquire high-quality water quality parameter data that meets the requirements of subsequent model analysis, providing reliable data support for the entire identification process. This step directly determines the accuracy and reliability of all subsequent model calculation results. If the collected data contains a large number of outliers or invalid data, it will lead to deviations in subsequent causal correlation mining and distorted feature extraction, ultimately affecting the accuracy of the water quality change identification results. Through outlier removal, unreasonable data caused by factors such as sensor malfunctions and transient interference can be eliminated, such as a sudden surge in turbidity to values ​​far exceeding the normal range or pH values ​​exceeding the conventional water quality monitoring range. This ensures that the retained valid water quality parameter data can truly reflect the actual water quality status at the water plant's influent, laying the foundation for constructing a high-quality water quality parameter time series dataset.

[0019] In the specific implementation process, the types of water quality parameters to be collected were first determined, specifically including six core parameters: turbidity, pH value, dissolved oxygen content, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration. These parameters are key indicators reflecting the degree of water pollution and physicochemical properties, and can comprehensively characterize the influent water quality. High-precision online monitoring sensors were selected for data collection and installed on the inner wall of the water plant's inlet pipe, 5 meters from the pipe opening. At this location, the water flow is stable, minimizing the impact of water flow disturbance on the monitoring data. The collection period was set to 30 consecutive days, with a collection interval of 5 minutes per session, ensuring that subtle changes in water quality parameters at different times could be captured. The 30-day continuous collection covers water quality conditions under different scenarios, such as weekdays and weekends, sunny days and rainy days, making the data more representative. After data collection, outlier removal was performed using the 3σ criterion. First, the average value and standard deviation of each water quality parameter were calculated. Data exceeding ±3 times the average value and standard deviation were identified as outliers. For example, if the average turbidity value was 15 NTU and the standard deviation was 5 NTU, turbidity data below 0 NTU or above 30 NTU were removed; if the average pH value was 7.2 and the standard deviation was 0.5, pH data below 5.7 or above 8.7 were removed. After outlier removal, the remaining data underwent a completeness check to ensure that the amount of valid data for each parameter within the 30-day collection period was not less than 85%. If the amount of valid data for a parameter was less than 85%, the data acquisition equipment was restarted for supplementary collection until the requirement was met, ultimately forming valid water quality parameter data.

[0020] Step S2: Divide the water quality parameter screening data into multiple data subsets according to a preset time interval, with each data subset corresponding to a time segment, and construct a water quality parameter time series dataset; Specifically, step S2 involves structuring the water quality parameters obtained in step S1 to construct a time-series dataset suitable for subsequent model input. This step serves as a crucial bridge connecting the original data with model analysis. Water quality parameters exhibit significant temporal correlations, with inherent relationships between parameter changes at different time points. By dividing the data into subsets based on time intervals and constructing a time-series dataset, discrete water quality parameter data can be transformed into a data format with temporal dimensions, enabling the subsequent model to uncover the evolution patterns and potential correlations of water quality parameters from a temporal perspective. A reasonable time interval setting directly impacts the quality of the time-series dataset. Too short an interval leads to data redundancy and increases model computation; too long an interval may lose crucial water quality change information. Therefore, this step requires considering both the rate of change of water quality parameters and model computational efficiency to determine the optimal time interval, ensuring that the constructed dataset fully preserves the characteristics of water quality changes while meeting the needs of efficient model computation.

[0021] In practice, the effective water quality parameter data obtained in step S1 are first sorted by timestamp to ensure that all data are arranged in chronological order of collection time, avoiding disruption of the time series due to disordered data order. Next, a preset time interval is determined. Considering the changing characteristics of the water quality parameters at the water plant influent and the computational requirements of subsequent hybrid models based on causal inference and bidirectional long short-term memory networks combined with attention mechanisms, the time interval is set to 30 minutes. This interval avoids the problem of excessive data volume due to too short an interval while effectively capturing the changing trends of water quality parameters within each 30-minute interval. Based on the 30-minute time interval, the sorted effective water quality parameter data is divided into multiple data subsets. Each data subset corresponds to a 30-minute time segment, and each data subset contains all collected data on turbidity, pH, dissolved oxygen, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration within that time segment. For example, if 6 sets of data are collected within a 30-minute period (with a collection interval of 5 minutes), then the data subset corresponding to that time segment contains all 6 sets of complete data for the six parameters. During the partitioning process, if the amount of data in a certain time segment is less than 90% of the theoretical collection volume for that time period, the data in that time segment is merged with the data in adjacent time segments to form a data subset with a longer time segment. The merged time segment shall not exceed 60 minutes to avoid data feature ambiguity due to excessive time span. After partitioning, a corresponding time segment identifier is added to each data subset, including the start and end times of the time segment. Then, all data subsets with time identifiers are integrated in chronological order to form a water quality parameter time series dataset. At the same time, the dataset is standardized to ensure that the data format of each parameter is consistent, facilitating subsequent model reading and processing.

[0022] Step S3: Input the water quality parameter time series dataset into the hybrid model based on causal inference, and use the hybrid model based on causal inference to mine the causal relationship between different water quality parameters, determine the causal influence strength of different water quality parameters in the time dimension, and output the causal relationship weight matrix corresponding to different water quality parameters. Specifically, step S3 is one of the core analytical steps in the water quality change identification process. By using a hybrid model based on causal inference to mine the causal relationships between water quality parameters, it breaks through the limitations of traditional techniques that rely solely on parameter correlation for analysis, providing a deeper causal basis for subsequent feature extraction and identification results. The various water quality parameters at the water plant inlet are not isolated but interact and influence each other. For example, an increase in ammonia nitrogen concentration may lead to a decrease in dissolved oxygen content, and changes in COD concentration may have an inherent causal relationship with turbidity. Correlation analysis alone cannot distinguish between causal relationships and spurious correlations, while mining causal relationships can clarify the direction and intensity of influence between different parameters. This allows the subsequent model to accurately locate the key parameters causing changes when analyzing water quality changes, improving the interpretability and reliability of the identification results. The generated causal relationship weight matrix transforms the abstract causal relationships into a quantitative matrix form, facilitating subsequent fusion processing with the water quality parameter time series dataset, providing a convenient data carrier for integrating causal information.

[0023] In the specific implementation process, the constructed water quality parameter time series dataset was first divided into a training set and a validation set in a 7:3 ratio. The training set was used to train the hybrid model based on causal inference, while the validation set was used to verify the accuracy of the model in uncovering causal relationships. Next, the parameters of the hybrid model based on causal inference were configured. The number of iterations was set to 100, the learning rate for each iteration was set to 0.01, and the causal strength threshold was set to 0.3, which is used to determine whether there is a significant causal relationship between two parameters. After inputting the training set into the model, the model first performs a stationarity test on the time series of each water quality parameter using the ADF test. If a parameter's time series is non-stationary, it is transformed into a stationary series through differencing to ensure the effectiveness of subsequent causal relationship analysis. Subsequently, the model uses a causal discovery algorithm to calculate the causal impact value of any two water quality parameters under different time lag windows. The time lag window is set to 1-5 time segments (i.e., 30 minutes to 150 minutes) to cover short-term and medium-term causal impacts. By comparing the causal impact values ​​under different lag windows, the optimal lag window and corresponding causal impact strength of each parameter on other parameters are determined. The preliminary causal relationships are then validated using a validation set. Relationships with causal impact strength below a threshold of 0.3 are removed from the validation set, retaining only significant causal relationships. Finally, the significant causal relationships are transformed into a matrix form according to parameter correspondences. The rows and columns of the matrix represent different water quality parameters, and the element values ​​represent the causal relationship strength between corresponding two parameters, generating a causal relationship weight matrix for each water quality parameter. The accuracy of the weight matrix is ​​then verified using a validation set. If the causal relationship accuracy of the matrix is ​​below 80%, the model parameters are readjusted and iterative training is performed until the accuracy reaches above 80%.

[0024] Step S4: The causal association weight matrix is ​​fused with the water quality parameter time series dataset to obtain a water quality parameter sequence with fused causal information. The water quality parameter sequence with fused causal information is input into a model with a bidirectional long short-term memory network combined with an attention mechanism. The bidirectional long short-term memory network extracts forward and backward time features from the water quality parameter sequence with fused causal information to obtain a bidirectional time feature vector. Then, the importance of different feature dimensions in the bidirectional time feature vector is evaluated by the attention mechanism, and attention weights are assigned to different feature dimensions to generate a feature vector with attention weights.

[0025] Specifically, step S4 is a crucial step in achieving deep integration of causal information and temporal features. By fusing the causal correlation weight matrix with the water quality parameter time series dataset, the subsequent feature extraction process can simultaneously consider the causal correlation and temporal variation characteristics of water quality parameters, avoiding the information loss problem caused by traditional techniques focusing only on a single feature. The application of a model combining a bidirectional long short-term memory network (BSSN) with an attention mechanism leverages the forward and backward propagation capabilities of the BSSN to comprehensively capture the variation characteristics of water quality parameter sequences in the past and future time dimensions, overcoming the limitations of unidirectional temporal feature extraction. Furthermore, the attention mechanism evaluates the importance of different feature dimensions, enabling the model to focus on features that play a key role in identifying water quality changes, improving feature utilization efficiency and the accuracy of subsequent identification results. The attention-weighted feature vector generated in this step integrates causal correlation information, bidirectional temporal features, and feature importance weights, providing high-quality feature input for the accurate learning of the subsequent gradient boosting machine ensemble model.

[0026] In practice, the causal correlation weight matrix and the water quality parameter time series dataset are first fused. Each element in the causal correlation weight matrix is ​​weighted and calculated with the corresponding two parameters in the water quality parameter time series dataset for the same time segment. For example, if the correlation strength between turbidity and COD concentration in the causal correlation weight matrix is ​​0.6, the turbidity data in each time segment is multiplied by 0.6 and added to the COD concentration data in that time segment to obtain the COD concentration data with fused turbidity causal influence. The causal fusion of all parameters is completed in the same way to form a water quality parameter sequence with fused causal information. During the fusion process, the temporal order of the data is kept consistent with the original time series. Next, the parameters of the bidirectional long short-term memory network combined with the attention mechanism model are configured. The number of hidden layers in the network is set to 3, the number of hidden units in each layer is set to 128, and the dropout probability is set to 0.2 to avoid model overfitting. The computation window of the attention mechanism is set to 3 time segments to evaluate the importance of features in adjacent time segments. The water quality parameter sequence, incorporating causal information, is input into the model chronologically. The forward propagation layer of the bidirectional long short-term memory network extracts features sequentially from the first time segment to the last, while the backward propagation layer extracts features in reverse order from the last time segment to the first. Each layer uses a gating mechanism to control information transmission and forgetting, ensuring the retention of effective features. After obtaining the bidirectional temporal feature vector for each time segment, the attention mechanism module calculates the similarity between each bidirectional temporal feature vector and the average of all bidirectional temporal feature vectors. An attention weight is assigned to each feature vector based on the similarity; higher similarity results in a larger weight, with the weight value ranging from 0.1 to 0.9. Finally, each bidirectional temporal feature vector is multiplied by its corresponding attention weight to obtain a feature vector with attention weights. Simultaneously, the feature vector is normalized to ensure that the values ​​of each element are uniformly between 0 and 1, facilitating subsequent model processing.

[0027] Step S5: Input the attention-weighted feature vector into the gradient booster ensemble model. Perform parallel feature learning on the attention-weighted feature vector through multiple base learners in the gradient booster ensemble model. Each base learner outputs the corresponding local water quality change feature recognition result. Perform weighted fusion on all local water quality change feature recognition results to obtain the preliminary water quality change recognition result. Specifically, step S5 utilizes a gradient booster ensemble model to perform deep learning and result fusion on the attention-weighted feature vectors, transforming features into preliminary water quality change identification results. This step fully leverages the advantages of the ensemble model, improving the stability and accuracy of the identification results. Compared to a single model, the gradient booster ensemble model, through parallel learning and result fusion of multiple base learners, effectively reduces the bias and variance of a single model, avoiding identification errors caused by the limitations of a single model. The attention-weighted feature vectors integrate causal information and key temporal features. By learning these high-quality features in parallel, the gradient booster ensemble model can explore the correlation between features and water quality changes from different perspectives. Each base learner focuses on learning a certain dimension or type of feature, outputting corresponding local identification results. Then, through a reasonable weighted fusion strategy, the advantages of each base learner are integrated to obtain more comprehensive and reliable preliminary water quality change identification results, laying the foundation for finally determining the type of water quality change.

[0028] In the specific implementation process, the attention-weighted feature vectors are first divided into training and testing subsets in an 8:2 ratio. The training subset is used to train the gradient booster ensemble model, while the testing subset is used to evaluate the model's learning performance. Next, the parameters of the gradient booster ensemble model are configured: the number of base learners is set to 50, decision trees are selected as the base learners, the maximum depth of each decision tree is set to 8 layers, the minimum number of sample splits is set to 20, and the learning rate is set to 0.05 to balance the model's learning and generalization abilities. After the training subset is input into the model, the 50 base learners simultaneously perform parallel feature learning. Each base learner extracts local features related to water quality changes from the attention-weighted feature vectors according to its own learning strategy. For example, some base learners focus on learning causal relationship features, while others focus on learning time trend features. Each base learner recursively partitions the feature space, generates a corresponding decision tree model, and outputs the local water quality change feature recognition results for the training subset. After all base learners have completed training, the performance of each base learner is evaluated using a test subset. Precision and recall are used as evaluation metrics, and a comprehensive performance score is calculated for each base learner on the test subset. The performance score is calculated as (precision × 0.6 + recall × 0.4). Weight coefficients for each base learner are determined based on the comprehensive performance score; the higher the performance score, the larger the weight coefficient, with a total weight coefficient of 1. Finally, the local water quality change feature recognition result output by each base learner is multiplied by its corresponding weight coefficient to obtain a weighted local result. All weighted local results are then summed to obtain the preliminary water quality change recognition result. Simultaneously, the accuracy of the preliminary recognition result on the test subset is calculated. If the accuracy is below 85%, the number of base learners is increased to 60, and retraining and fusion are performed until the accuracy reaches above 85%.

[0029] Step S6: Perform feature mapping processing on the preliminary water quality change identification results, map them to the preset water quality change type division space, determine the specific change type corresponding to the water quality of the water plant influent, and complete the water quality change identification process of the water plant influent. Specifically, step S6 is the final stage of water quality change identification. By performing feature mapping processing on the preliminary water quality change identification results, the abstract identification results are transformed into specific and categorizable water quality change types. This realizes the transformation from data calculation to practical application conclusions, providing water plant operation and management personnel with intuitive and clear decision-making basis. Preliminary water quality change identification results are usually presented in numerical form and cannot directly reflect the specific category of water quality change, such as whether the change is caused by organic pollution, inorganic pollution, or physical factors. Feature mapping processing establishes a correspondence between the preliminary identification results and water quality change types. By pre-defined water quality change type division space, the preliminary results are accurately located to specific change types, ensuring that the identification results have practical application value. This helps water plant operation and management personnel quickly grasp the nature of influent water quality changes and take timely and targeted water treatment process adjustment measures.

[0030] In practice, the first step is to construct a pre-defined space for classifying water quality change types. Based on the common causes and characteristics of changes in the influent water quality of the water plant, water quality change types are divided into five categories: organic pollution type, inorganic pollution type, physical disturbance type, biological impact type, and complex factor type. Each type of change corresponds to a specific identifier range, with the value range set from 0 to 10. Specifically, organic pollution type corresponds to 0-2, inorganic pollution type corresponds to 2-4, physical disturbance type corresponds to 4-6, biological impact type corresponds to 6-8, and complex factor type corresponds to 8-10. Next, the preliminary water quality change identification results obtained in step S5 are statistically analyzed to determine the minimum and maximum values ​​of the preliminary identification results. For example, the minimum value of the preliminary identification results is 0.3, and the maximum value is 9.7. Then, a linear mapping method is used to map the preliminary identification results to a preset water quality change type classification space. During the mapping process, based on the numerical value of the preliminary identification result, its corresponding position within the marked interval is calculated. For example, if the value of a preliminary identification result is 1.5, after mapping, it falls within the marked interval of 0-2 and is identified as an organic pollution type change; if the value of a preliminary identification result is 5.2, after mapping, it falls within the marked interval of 4-6 and is identified as a physical disturbance type change. During the mapping process, if the value of a preliminary identification result exceeds the range of the preset marked interval (i.e., less than 0 or greater than 10), it is adjusted to the nearest marked interval boundary value. For example, a value of -0.2 is adjusted to 0, and a value of 10.5 is adjusted to 10 before type determination is performed. Finally, a consistency check is performed on the water quality change types obtained from the mapping. 10% of the preliminary identification results and their corresponding mapping types are randomly selected and manually verified by professional water quality analysts. If the accuracy rate of the manual verification is less than 90%, the identification range of the water quality change type division space is readjusted until the verification accuracy rate reaches more than 90%. Finally, the specific change type corresponding to the water quality of the water plant influent is determined, and the entire water quality change identification process is completed.

[0031] Preferably, in step S3, when using the hybrid model based on causal inference to explore the causal relationships between different water quality parameters, a causal relationship strength calculation model is adopted, and the expression of the causal relationship strength calculation model is: in, This represents the causal relationship strength between the i-th water quality parameter and the j-th water quality parameter at time t. Indicates that the i-th water quality parameter is in The value at time, This represents the value of the j-th water quality parameter at time t, and n represents the preset time lag window length. This represents the inherent correlation coefficient between the i-th and j-th water quality parameters, with a value range of [0.1, 0.9]. The water quality parameters include turbidity. pH value Dissolved oxygen content COD concentration ammonia nitrogen concentration Total phosphorus concentration In step S4, when the bidirectional long short-term memory network combined with the attention mechanism generates feature vectors with attention weights, an attention weight calculation model is used. The expression of the attention weight calculation model is as follows: in, This represents the attention weight corresponding to the m-th bidirectional temporal feature vector. This represents the m-th bidirectional time feature vector. Let M represent the average eigenvector of all bidirectional time eigenvectors, and M represent the total number of bidirectional time eigenvectors. This represents the attention score calculation function, which uses cosine similarity as the calculation method.

[0032] Specifically, the causal correlation strength calculation in step S3 and the attention weight calculation in step S4 improve the accuracy of causal analysis of water quality parameters and the rationality of feature weight allocation by clarifying model parameters and operational logic. In the causal correlation strength calculation stage, the time lag window length is set to 8. This value is based on the fact that the water quality parameters of the water plant influent (such as turbidity and ammonia nitrogen concentration) usually show a significant trend of change every 4 hours. Eight time units (each time unit is 30 minutes, corresponding to the data subset interval) can cover the short-term causal effects between parameters, avoiding the omission of correlations due to an excessively short window or the data redundancy due to an excessively long window. The inherent correlation coefficient ranges from 0.1 to 0.9. Among them, the inherent correlation coefficient between turbidity and COD concentration is set to 0.7 because they are often affected by the same pollution source, and the correlation between pH value and total phosphorus concentration is relatively weak, so it is set to 0.2. This coefficient is used to correct the deviation of pure data calculation and reduce the interference of random fluctuations. In the attention weight calculation stage, the total number of bidirectional time feature vectors is set to 180, which is calculated from a 30-day collection period and a 30-minute data subset interval (30 days × 24 hours × 2 = 1440 time points, and 180 are calculated by forming 1 feature vector with 8 time points). Using cosine similarity calculation can effectively measure the correlation of vector direction, which is not affected by the numerical scale, and ensures that the weight allocation focuses on key features. During implementation, parameter pairs are first determined according to the type of water quality parameter, and the corresponding inherent correlation coefficients are input. Then, parameter data within 8 time lag windows are extracted, and the causal correlation strength is calculated through the model. The calculation result error is required to be controlled within ±4%. Subsequently, in the attention weight calculation, 180 feature vectors are first generated through a bidirectional long short-term memory network. After calculating the average feature vector, the cosine similarity between each individual vector and the average vector is calculated. After normalization, the weights are obtained (weight values ​​range from 0.02 to 0.15). The entire process needs to be verified through 3 rounds of iterations, adjusting the time lag window and inherent correlation coefficients to ensure that the causal correlation strength matches the actual water quality change pattern, and that the attention weights can highlight the feature vectors corresponding to abnormal parameters.

[0033] Preferably, in step S5, when the gradient boosting machine ensemble model performs parallel feature learning on the feature vector with attention weights, it adopts a base learner weight allocation model, the expression of which is: in, This represents the weight of the q-th base learner. This represents the feature learning accuracy of the q-th base learner on the validation dataset. The difference between the feature learning results of the q-th base learner and other base learners is represented by Q, where Q represents the total number of base learners. In step S5, when weighting and fusing the local water quality change feature identification results, a fusion result calculation model is used, and the expression for the fusion result calculation model is: ,in, This indicates the preliminary results of water quality change identification. This represents the local water quality change feature recognition result output by the q-th base learner.

[0034] Specifically, in step S5, the weight allocation of the base learners and the fusion of local results in the gradient booster ensemble model are clarified, defining the technical parameters and computational process to address the issues of fixed weights and insufficient accuracy in traditional ensemble models. The total number of base learners is set to 35. This number is determined by considering the complexity of the water quality data from the water plant (6 core parameters, 30-day collection period) and computational efficiency. 35 base learners can cover multi-dimensional features while avoiding training time exceeding 8 hours (training a single base learner takes about 12 minutes). The feature learning accuracy is required to be no less than 78%, calculated using the validation set (accounting for 30% of the total data). Base learners with an accuracy lower than this value need to be retrained. The difference is calculated using the Euclidean distance method, with a value range of 0.12-0.75. Base learners with a difference below 0.12 (indicating repeated feature learning) need to have their decision tree depth adjusted (from the default 6 layers to 8 layers) or the minimum number of sample splits adjusted (from 15 to 20). In the fusion of local results, the weight calculation must ensure that the sum of all weights is 1. For example, the weight of a base learner with an accuracy of 92% and a difference of 0.65 is about 0.08, and the weight of a base learner with an accuracy of 80% and a difference of 0.4 is about 0.03. The base learner with better performance has a higher weight. In implementation, the feature vectors with attention weights are first divided into training and validation sets in a 7:3 ratio. The base learner parameters are configured (maximum decision tree depth of 7 layers, learning rate of 0.04, and regularization coefficient of 0.01), and 35 base learners are trained in parallel. After training, the accuracy and variance of each base learner are calculated, and base learners that do not meet the requirements are removed (if there are fewer than 30 base learners after removal, additional training is conducted). Then, the weights are calculated based on the accuracy (60% weighting) and variance (40% weighting), and the preliminary recognition results are obtained by weighted summation. The accuracy of the results on the validation set is required to be no less than 86%. If the target is not met, the base learner parameters and weights are readjusted and the weighting ratios are calculated until the requirements are met. At the same time, the performance indicators (accuracy, variance, and weights) of each base learner are recorded for subsequent troubleshooting.

[0035] Preferably, in step S3, when the hybrid model based on causal inference outputs the causal association weight matrix, the weight matrix is ​​used to update the model. The expression for the weight matrix update model is: ,in, express Causal correlation weight matrix under iteration number, This represents the causal correlation weight matrix at iteration number t. This represents the matrix update step size, with a value range of 1. , The loss function L represents the weight matrix at iteration number t. The gradient; in step S4, when the bidirectional long short-term memory network extracts the bidirectional temporal feature vector, a gated update model is adopted, and the expression of the gated update model is: , in, These represent the output values ​​of the input gate, forget gate, and output gate, respectively. This represents the sigmoid activation function. These represent the weight matrices corresponding to different gates. These represent the bias terms corresponding to different gates. express The hidden state at all times This represents the input features at time t. Indicates the state of candidate cells. This represents the cell state at time t. This represents the hidden state at time t. This represents element-wise multiplication.

[0036] Specifically, the causal association weight matrix update in step S3 and the bidirectional long short-term memory network gating mechanism in step S4 clearly define parameter settings and operational logic, ensuring dynamic optimization of causal analysis and efficient extraction of temporal features. In the weight matrix update, the number of iterations is set to 120, determined through model convergence testing (after 120 iterations, the loss function value stabilizes below 0.25, and further iterations reduce the loss by no more than 0.01), avoiding insufficient iterations leading to bias or excessive resource waste. The matrix update step size is set to 0.006; a step size that is too large can easily cause parameter oscillations (tests show that the loss function fluctuates by 15% with a step size of 0.01), while a step size that is too small results in training time exceeding 10 hours. 0.006 balances convergence speed and stability. The loss function uses mean squared error, calculating the error between the predicted causal association strength and the manually labeled true value (based on 5 years of historical water quality causal relationship data), requiring a loss reduction of no less than 0.02 in each iteration. In the bidirectional long short-term memory network gating mechanism, the weight matrix dimensions of the input gate, forget gate, and output gate are set to 128×224 (128 is the number of hidden layer units, and 224 is the input feature dimension, which is calculated from 6 parameters × 8 time windows × 4 feature dimensions). The bias term ranges from -0.4 to 0.4 and is optimized during training after random initialization. The candidate cell state adopts the tanh activation function (output range -1 to 1) to ensure numerical stability. The cell state update is controlled collaboratively by the forget gate (retaining historical information weight 0.3-0.8) and the input gate (adding new information weight 0.2-0.7). During implementation, a 6×6 causal correlation weight matrix is ​​first initialized (initial value 0.15-0.25). The training set data is input to start iterative updates. The gradient is calculated in each iteration and the matrix is ​​adjusted according to the step size. If the loss decreases below 0.02 for 8 consecutive iterations, the process stops. In the training of the bidirectional long short-term memory network, the dropout probability is set to 0.2 (to prevent overfitting). The water quality parameter sequence with causal information is input into the network, and bidirectional features are extracted through a gating mechanism. The feature extraction accuracy of the model on the validation set is required to be no less than 82%. If the target is not met, the number of hidden layer units (128±16) or the dropout probability (0.2±0.05) is adjusted, and the training is repeated. Throughout the process, parameter changes need to be monitored to avoid numerical overflow (gradient clipping is used to limit the gradient value to -5 to 5).

[0037] Preferably, in step S5, when the base learner of the gradient boosting machine ensemble model performs feature learning, a loss function optimization model is used, and the expression of the loss function optimization model is: ,in, This represents the value of the loss function. Let K represent the set of parameters for the base learner, and K represent the number of training samples. This represents the true label of the k-th training sample. This represents the predicted output value of the base learner for the k-th training sample; in step S6, when performing feature mapping processing on the preliminary water quality change identification results, a mapping model is used, and the expression of the mapping model is: ,in, This represents the mapped water quality change type identifier value. This represents the minimum value indicating the initial water quality change identification result. This represents the maximum value of the preliminary water quality change identification results. This represents the minimum identifier value in the spatial classification of water quality change types. This represents the maximum identifier value in the spatial classification of water quality change types.

[0038] Specifically, the optimization of the base learner loss function in step S5 and the feature mapping in step S6 are defined, with clear calculation methods and parameter ranges to ensure efficient training of the base learner and accurate mapping of water quality change types. In the loss function optimization, the number of training samples is set to 4800 sets, covering water quality data from the water plant over the past two years for different seasons (1200 sets each for spring, summer, autumn, and winter) and different pollution types (1600 sets each for organic, inorganic, and compound pollution) to ensure sample representativeness. The loss function uses logarithmic loss, calculating the logarithmic loss between the predicted output and the true label (5 types of water quality change). The requirement is that the average sample loss value after training should be ≤0.28. If this value is exceeded, the base learner regularization coefficient (adjusted from 0.01 to 0.02) or learning rate (adjusted from 0.04 to 0.03) needs to be adjusted. In the feature mapping, the range of the preliminary water quality change identification result is determined to be 0.3-9.7 by statistically analyzing 5000 historical prediction results. The minimum identifier value is 1 and the maximum identifier value is 5 (corresponding to 5 types of change) for water quality change type classification space. The mapping adopts linear transformation to ensure that the results are evenly distributed. For example, the preliminary result of 0.3 corresponds to the identifier value 1, and 9.7 corresponds to the identifier value 5. The intermediate values ​​are converted proportionally. During implementation, the 4800 training samples were first cleaned (outliers were removed, and more than 4600 valid samples were retained). The base learner loss function parameters were configured (regularization coefficient 0.015, learning rate 0.045). Training was started and the average sample loss value was monitored in real time. The process was stopped when the loss value was stable at ≤0.28 and did not decrease for 12 consecutive iterations. In the feature mapping stage, the maximum and minimum values ​​of the preliminary identification results of the current batch were first calculated. If the result was <0.3, it was treated as 0.3, and if it was >9.7, it was treated as 9.7. Then, the values ​​were converted into label values ​​using a linear formula (retaining integers and rounding off the decimal part). Subsequently, the mapping accuracy was tested using 1000 manually labeled validation samples. The accuracy was required to be ≥89%. If the accuracy was not met, the range of the spatial label values ​​was adjusted (e.g., 1-5 was adjusted to 1.2-4.8) or the mapping formula coefficients were adjusted until the requirements were met. At the same time, the mapping parameters and accuracy were recorded to form a standardized mapping process.

[0039] Preferably, before mining causal relationships using the hybrid model based on causal inference in step S3, a causal relationship initialization model is used, and the expression for the causal relationship initialization model is: ,in, This represents the initial value indicating the causal relationship between the i-th and j-th water quality parameters. This represents the covariance between the i-th and j-th water quality parameters. This represents the variance of the i-th water quality parameter. Let j represent the variance of the j-th water quality parameter. This represents the initial adjustment coefficient, with a value range of [value range missing]. In step S4, when the attention mechanism evaluates the importance of feature dimensions, a feature importance calculation model is used. The expression for the feature importance calculation model is as follows: ,in, This represents the importance index of the m-th feature dimension. This represents the value of the m-th feature dimension in the k-th sample. This represents the average value of the m-th feature dimension. This represents the attention weight of the m-th feature dimension in the k-th sample, where K represents the number of training samples.

[0040] Specifically, step S3, causal relationship initialization, and step S4, feature importance assessment, clearly define calculation methods and parameter standards to ensure the initial rationality of causal analysis and the accuracy of feature importance judgment. In causal relationship initialization, the data sample size is set at 3200 sets, covering monitoring data from different locations at the water plant inlet (approximately 1060 sets each at distances of 3 meters, 5 meters, and 7 meters from the pipe opening), avoiding statistical bias caused by a single monitoring location. Covariance and variance are calculated using these 3200 sets of data, with initialization adjustment coefficients ranging from 0.55 to 1.45. The covariance calculation results for turbidity and dissolved oxygen content are typically large (approximately 0.58), so the adjustment coefficient is set at 0.85 to keep the initial value at 0.49, avoiding excessively high initial values. The initial value range is required to be 0.12-0.88; if it exceeds this range, the data calculation process is re-checked (e.g., for missing data or outliers). In the feature importance evaluation, the total number of samples is set to 2100 groups (randomly drawn from the dataset, covering all time segments), the total number of feature dimensions is 224, and the average attention weight of each feature dimension is required to be ≥0.06. Feature dimensions with a value lower than this (such as some redundant time features) need to be marked and their weight ratio is reduced in subsequent model training (from the default 10% to 5%). During implementation, 3200 sets of historical data were first collected and their completeness was verified (effective data rate ≥ 95%). The covariance and variance of each pair of parameters were calculated and substituted into the model to obtain initial values. If the initial values ​​were outside the range, they were recalculated. The initial values ​​were then input into a hybrid model based on causal inference as initial parameters. Training was started and the deviation between the initial values ​​and the final converged values ​​was recorded (the deviation was required to be ≤ 15%). If the deviation was too large, the adjustment coefficient was adjusted. In the feature importance assessment, the mean and attention weight of each feature dimension in 2100 sets of samples were first calculated and substituted into the model to obtain the importance index. The average value of the index was required to be ≥ 0.11. Subsequently, the 12% of features with the lowest importance were removed, and the change in the model's recognition accuracy was examined (the decrease was required to be ≤ 2.5%). If the decrease was too large, the importance calculation logic was re-evaluated. All calculation data must be saved throughout the entire process for subsequent model optimization and auditing.

[0041] Preferably, step S3 specifically includes the following sub-steps: S31: The water quality parameter time series dataset is split into multiple single-parameter time series according to the water quality parameter type. Each single-parameter time series corresponds to the change data of a water quality parameter within a preset time period. Each single-parameter time series is segmented in the time dimension to obtain multiple single-parameter time segment sequences. Each single-parameter time segment sequence contains a preset number of time point data. S32: Different single-parameter time segment sequences are input into the causal detection module of the hybrid model based on causal inference. The causal detection module calculates the lag correlation coefficient between the single-parameter time segment sequences corresponding to any two water quality parameters. Based on the lag correlation coefficient, the possible causal relationship between the two water quality parameters is determined. S33: Based on the preliminary causal relationship direction information, construct a preliminary causal relationship graph. In the preliminary causal relationship graph, each node represents a water quality parameter, and each edge represents the preliminary causal relationship between two water quality parameters. Verify the causal strength of each edge in the preliminary causal relationship graph, and remove edges with causal strength lower than a preset strength threshold to obtain an optimized causal relationship graph. S34: According to the optimized causal relationship graph, extract the causal association information corresponding to different water quality parameters, convert the causal association information into a matrix form, and generate a causal association weight matrix corresponding to different water quality parameters. The value of each element in the causal association weight matrix represents the strength of the causal association between the corresponding two water quality parameters.

[0042] Specifically, step S3 (mining causal relationships of water quality parameters using a hybrid model based on causal inference) is divided into several steps. By clarifying the technical parameters and operational standards for each step, the systematic and accurate nature of causal relationship mining is ensured. In step S31, the segmented processing of single-parameter time series requires dividing the 30-day continuous data of each water quality parameter (collected at 5 minutes / time, totaling 30×24×12=8640 data points) into 144 single-parameter time segment sequences. Each segment contains 60 data points (corresponding to a 5-hour duration, determined based on the tendency of water quality parameters to show continuous change trends within 5 hours). The number and duration of segments need to balance feature integrity and computational efficiency, avoiding feature fragmentation due to excessively short segments or information redundancy due to excessively long segments. In step S32, when the causal detection module calculates the lag correlation coefficient, the time lag step is set to 10 (corresponding to 50 minutes, referencing the common lag time from change in water quality parameters to their impact), and the correlation coefficient threshold is set to 0.35. Values ​​above this threshold indicate a potential causal relationship. Preliminary causal relationship direction information needs to record the order of influence between parameters, providing a foundation for subsequent causal graph construction. In step S33, the node diameter of the preliminary causal graph is set to 10mm (a visual parameter for easy manual verification). The edge thickness is proportional to the preliminary correlation coefficient. Causal strength verification uses the bootstrap sampling method (1000 samplings, 95% confidence interval), with an intensity threshold set to 0.4. Edges below this threshold are removed to ensure that the optimized causal graph retains only significant associations. In step S34, when the causal relationship information is converted into a matrix, the matrix dimension is 6×6 (corresponding to 6 water quality parameters), the element values ​​range from 0 to 1, and the values ​​are accurate to 4 decimal places. The generated causal relationship weight matrix must pass a consistency test (test sample size 500 groups, consistency coefficient ≥ 0.85). If it fails to meet the standard, return to S32 to readjust the lag step size and correlation coefficient threshold. During implementation, first, the parameter sequence is split and segmented according to S31, then the correlation coefficient and direction information are calculated through S32, then the causal relationship graph is constructed and optimized, and finally the weight matrix is ​​generated. After each sub-step is completed, intermediate results need to be verified. For example, the correlation coefficient calculation error in S32 must be ≤ 5%, the optimized causal graph in S33 must be independently reviewed and approved by 2 water quality experts, and the weight matrix in S34 must meet the requirement that the row sum is 1 (normalization requirement) to ensure smooth connection between each link and reliable results, providing high-quality causal weight data for subsequent feature fusion.

[0043] Preferably, step S4 specifically includes the following sub-steps: S41: Multiply each element in the causal association weight matrix with the corresponding water quality parameter data at the same time point in the water quality parameter time series dataset to obtain water quality parameter data with causal weights. Arrange all water quality parameter data with causal weights in chronological order to form a water quality parameter sequence that integrates causal information. The water quality parameter sequence that integrates causal information retains the chronological order of the original water quality parameter time series. S42: Divide the water quality parameter sequence that integrates causal information into multiple input sub-sequences according to a preset sequence length. Each input sub-sequence serves as input data for a bidirectional long short-term memory network. Input the input sub-sequences into the forward propagation layer and the backward propagation layer of the bidirectional long short-term memory network. The forward propagation layer processes the input sub-sequences from the start time to the end time. Feature extraction is performed. The backpropagation layer extracts features from the input subsequence from the end of time to the beginning of time. S43: The local feature vectors output by the forward and backpropagation layers at each time point are obtained respectively. The forward and back local feature vectors at the same time point are concatenated to obtain the bidirectional time feature vector corresponding to that time point. The bidirectional time feature vectors of all time points are combined in chronological order to form a set of bidirectional time feature vectors. S44: The set of bidirectional time feature vectors is input into the attention mechanism module. The attention mechanism module calculates the similarity between each bidirectional time feature vector and the preset reference vector. The attention weight corresponding to each bidirectional time feature vector is determined according to the similarity. Each bidirectional time feature vector is multiplied by the corresponding attention weight to obtain a feature vector with attention weight.

[0044] Specifically, step S4 (feature extraction by fusing causal information with a bidirectional long short-term memory network and attention mechanism) is divided into steps, clearly defining the parameter settings and operation procedures for each stage to ensure the comprehensiveness and relevance of feature extraction. In step S41, the product operation between the causal correlation weight matrix and the water quality parameter data must correspond element by element, with the calculation precision retained to 6 decimal places. The fused data needs to be range-validated (value range 0-1000; values ​​exceeding this range are truncated using the clip function to avoid numerical overflow). The time sequence of the fused sequence must be completely consistent with the original data, with a timestamp error ≤1 second, ensuring accurate matching of causal information and parameter data and preventing time misalignment issues. In step S42, the length of the input subsequence is set to 20 (corresponding to a 10-hour duration, determined based on the bidirectional long short-term memory network's ability to process long sequences and the continuity of water quality changes over 10 hours). The learning rate of the forward propagation layer is set to 0.008, and the learning rate of the backpropagation layer is set to 0.007 (to improve stability as gradient vanishing is prone to occur during backpropagation). The number of hidden units in both layers is set to 128 to ensure a balance in forward and backward feature extraction capabilities. In step S43, the dimension of the local feature vector is set to 256 (128 forward features + 128 backward features). The concatenation adopts a horizontal stacking method, and the dimension verification error of the concatenated vector must be ≤0. The bidirectional time feature vector set must be sorted in chronological order, and the set size is consistent with the number of input subsequences (approximately 144, corresponding to 30 days × 24 hours / 10 hours) to avoid the vector order disorder affecting the subsequent attention mechanism operation. In step S44, the reference vector of the attention mechanism module is the mean vector of all bidirectional feature vectors (the sample size is all vectors, and the mean error is ≤0.001). The similarity calculation uses the Pearson correlation coefficient (the value range is -1 to 1). The attention weights need to be normalized by the softmax function (the sum of the weights is 1, and the value of a single weight is 0.005-0.1). The feature vector with attention weights needs to be dimensionally compressed (from 256 dimensions to 128 dimensions, using principal component analysis, with a variance contribution rate ≥90%) to reduce the computational load of the subsequent model.During implementation, S41 requires first verifying the dimensionality consistency between the matrix and the data (both are N×6, where N is the number of data entries), and then performing product operations and range control; S42 requires dividing the input subsequences and configuring network parameters to ensure synchronous training of the forward and backward propagation layers (training iterations of 500 times, loss function value ≤0.2); S43 requires accurately concatenating and sorting the feature vectors, and saving the intermediate results in CSV format for easy traceability; S44 requires calculating similarity and weights, and after completing vector compression, performing a validity test on the final feature vectors (the test metric is feature variance, variance ≥0.01, ensuring the features have discriminative power). If the standard is not met, return to S42 to adjust the subsequence length or the number of hidden units. For example, the subsequence length can be adjusted between 15 and 25, and the number of hidden units can be optimized between 100 and 150, until the feature vectors meet the requirements, providing high-quality input features for the gradient booster ensemble model.

[0045] Preferably, step S5 specifically includes the following sub-steps: S51: Divide the feature vector with attention weights into multiple feature sub-vectors, each feature sub-vector containing a preset number of feature dimensions, and each feature sub-vector corresponding to a base learner in the gradient boosting machine ensemble model. Input different feature sub-vectors into their respective base learners; S52: Each base learner performs feature transformation processing on the input feature sub-vectors, mapping the feature sub-vectors to a high-dimensional feature space through a preset feature transformation function to obtain high-dimensional feature vectors. Construct a decision tree from the high-dimensional feature vectors by recursively dividing the high-dimensional feature space to generate a decision tree structure. Each decision tree... Each leaf node corresponds to a local water quality change feature recognition result; S53: The validity of the local water quality change feature recognition result output by each base learner is checked. The local water quality change feature recognition result is compared with the corresponding real feature result in the validation set. The error value of the local water quality change feature recognition result is calculated, and the local water quality change feature recognition result with an error value lower than the preset error threshold is retained; S54: Based on the performance indicators of different base learners during the training process, the weight coefficient corresponding to each base learner is determined. The different local water quality change feature recognition results are multiplied with the corresponding weight coefficients, and then all multiplication results are summed to obtain the preliminary water quality change recognition result.

[0046] Specifically, step S5 (parallel learning and result fusion of the gradient booster integrated model) is divided into steps, clarifying the technical parameters and implementation standards of each stage to improve the reliability and accuracy of the preliminary results of water quality change identification. In step S51, the feature vector with attention weights is divided into 4 feature sub-vectors (each sub-vector is 32-dimensional, determined based on 4 core features of 6 water quality parameters—trend features, fluctuation features, correlation features, and mutation features). The correspondence between sub-vectors and base learners must be fixed (e.g., sub-vector 1 corresponds to base learner 1). The number of base learners is set to 4 (consistent with the number of sub-vectors to ensure one-to-one learning and avoid feature cross-interference). Before input, the feature sub-vectors need to be standardized (mean 0, standard deviation 1, standardization error ≤ 0.005) to ensure that the data volume of each sub-vector is consistent and to avoid affecting the training effect of the base learners. In step S52, the feature transformation function adopts a polynomial kernel function (kernel function degree=3, regularization parameter C=1.0), the high-dimensional feature space dimension is set to 1024 (calculated based on the dimension of 32-dimensional sub-vectors after 3 polynomial transformations), the maximum depth of decision tree construction is set to 8 (to avoid overfitting, based on the accuracy test of the validation set, the accuracy is highest at a depth of 8), the minimum number of sample splits is set to 20 (to ensure that the split nodes have statistical significance), the local recognition results of leaf nodes are in the form of probability values ​​(value range 0-1, accurate to 4 decimal places), and the training time of each decision tree must be controlled within 30 minutes (due to the limitation of computing resources for a single tree). In step S53, the error calculation for the validity test uses absolute error (|predicted value - true value|), and the error threshold is set to 0.15. Local results exceeding this threshold need to be marked as invalid. The true feature results are derived from manual annotation (annotated sample size of 1000 groups, annotation accuracy ≥98%). The proportion of invalid results must be ≤10%. If it exceeds this, return to S52 to adjust the decision tree depth or the minimum number of sample splits. For example, the depth can be adjusted to 7-9, and the number of splits can be adjusted to 15-25. In step S54, the performance metric for the base learner is the F1 score (the harmonic mean of precision and recall, each weighted 50%). The weight coefficient for base learners with an F1 score ≥ 0.85 is set to 0.3, for those between 0.75 and 0.85 it is set to 0.2, and for those below 0.75 it is set to 0.1 (the weights sum to 1). The weighted arithmetic mean method is used for weighted fusion, and the calculation precision is retained to 6 decimal places. The preliminary identification results need to be tested for distribution (normal distribution test, P value ≥ 0.05) to ensure that the distribution of results is reasonable.In implementation, S51 first divides and standardizes feature sub-vectors, then assigns them to the corresponding base learners; S52 starts the training of base learners, monitors the decision tree construction process in real time, and avoids over- or under-pruning; S53 checks the validity of local results, counts the proportion of invalid results, and adjusts parameters; S54 calculates weight coefficients and fusion results. Each sub-step needs to record key parameters and results, such as the decision tree depth and training time in S52, the error distribution in S53, and the weight coefficients and F1 score in S54. After the fusion result is completed, it needs to be compared with the validation set (accuracy ≥ 88%). If it does not meet the standard, the performance index weights or fusion algorithm are readjusted. For example, the weight of the F1 score can be adjusted to 60%, and the accuracy can be adjusted to 40% to ensure that the preliminary water quality change identification results can accurately reflect the actual water quality situation and provide a reliable foundation for subsequent type mapping.

[0047] The hybrid model based on causal inference in this invention is specifically designed to uncover causal relationships among water quality parameters in water plant influent. It does not simply rely on parameter correlation for analysis, but rather uses multi-stage data processing and verification to accurately identify the causal influence strength of different water quality parameters over time, providing in-depth causal evidence for subsequent water quality change identification. The model's implementation closely integrates the characteristics of water quality parameter data with practical application needs. First, it requires acquiring data on six core water quality parameters, including turbidity and pH, collected continuously for 30 days at 5-minute intervals from the water plant influent. The 8640 data points for each parameter are divided into 144 single-parameter time segments containing 60 data points each (corresponding to 5 hours), ensuring the data retains both continuous variation characteristics and computational feasibility. Then, a causal detection module calculates the lag correlation between parameters with a time lag step of 10 (corresponding to 50 minutes). The model employs a threshold of 0.35 to filter potential causal relationships and record the direction of influence. A preliminary causal relationship graph is then constructed, and bootstrap sampling (1000 samples, 95% confidence interval) is used to verify the causal strength, eliminating associations with a strength below 0.4 to obtain an optimized causal relationship graph. Finally, the association information in the graph is transformed into a 6×6 causal association weight matrix, with elements ranging from 0 to 1 and accurate to four decimal places. The matrix's reliability is ensured through a consistency test of 500 samples (consistency coefficient ≥ 0.85). This model overcomes the limitations of traditional techniques that misjudge spurious correlations as genuine associations, clarifying the true impact relationships between water quality parameters. For example, it accurately identifies the causal effect of ammonia nitrogen concentration changes on dissolved oxygen content, providing quantitative causal weights for subsequent feature fusion. This upgrades water quality change identification from "surface correlation analysis" to "deep causal tracing," not only improving the reliability of the identification results but also providing a scientific basis for water plants to trace the root causes of water quality changes and formulate targeted control measures. This avoids deviations in water treatment process adjustments due to causal misjudgments, ensuring the accuracy of water plant operation decisions.

[0048] The bidirectional long short-term memory network combined with an attention mechanism in this invention is a model that integrates causal information, comprehensively extracts the temporal features of water quality parameters, and focuses on key information. It is composed of a bidirectional long short-term memory network and an attention mechanism module; the former is responsible for capturing features in both forward and backward time dimensions, while the latter is responsible for evaluating feature importance and assigning weights. The implementation of this model requires multiple refined steps. First, the causal association weight matrix generated by the hybrid model based on causal inference is multiplied element-wise with the water quality parameter time series data, with the calculation precision retained to 6 decimal places. Simultaneously, the fused data is validated within the range of 0-1000; data exceeding this range is truncated to ensure accurate matching between causal information and parameter data without temporal misalignment (timestamp error ≤ 1 second). Next, the fused data is divided into input subsequences of length 20 (corresponding to 10 hours), which are input into the bidirectional long short-term memory network. The forward and backward propagation layers are trained simultaneously with learning rates of 0.008 and 0.007, respectively, and 128 hidden units. The loss function is refined through 500 iterations. For values ​​≤ 0.2, a 256-dimensional (128 dimensions each in the forward and backward directions) bidirectional temporal feature vector is extracted and sorted by time. Subsequently, the attention mechanism module calculates the mean vector of all feature vectors (mean error ≤ 0.001), uses the Pearson correlation coefficient to measure the similarity between a single vector and the mean vector, and converts the similarity into a normalized weight of 0.005-0.1 using the softmax function. Finally, the weighted feature vectors are reduced from 256 dimensions to 128 dimensions using principal component analysis to ensure that the variance contribution rate is ≥ 90%, and the validity is verified by the feature variance ≥ 0.01 test. If the standard is not met, the subsequence length (15-25) or the number of hidden units (100-150) is adjusted. The model addresses the shortcomings of traditional unidirectional feature extraction, such as incompleteness and the easy omission of key information. It can fully capture the past and future trends of water quality parameters and highlight features during abnormal periods (such as increased feature vector weights during sudden pollution events). It provides high-quality and targeted feature inputs for subsequent gradient boosting machine integrated models, significantly improving feature utilization efficiency and avoiding insufficient recognition accuracy due to feature redundancy or missing key information. This lays a feature foundation for high accuracy in water quality change recognition and provides a referable technical path for feature extraction of complex time series data by fusing causal and attention mechanisms.

[0049] The gradient booster ensemble model in this invention is an ensemble learning model that achieves deep learning and preliminary change recognition of water quality parameter features through parallel learning by multiple base learners and dynamic weighted fusion of results. Its core lies in leveraging the complementary advantages of multiple base learners to improve recognition reliability. The implementation process of this model requires strict control over parameter configuration and result verification. First, the 128-dimensional feature vector output by the bidirectional long short-term memory network combined with the attention mechanism is divided into four 32-dimensional feature sub-vectors according to four core features: trend, fluctuation, correlation, and mutation. Each sub-vector is standardized with a mean of 0 and a standard deviation of 1 (error ≤ 0.005) and assigned to the four corresponding base learners. Next, each base learner uses a polynomial kernel function with degree=3 and C=1.0 to map the sub-vectors to a 1024-dimensional high-dimensional space, constructing a decision tree with a maximum depth of 8 and a minimum number of sample splits of 20. Training is completed within 30 minutes, outputting local recognition probability values ​​in the range of 0-1 accurate to four decimal places. Then, 1000 sets of manually labeled... For each sample (accuracy ≥ 98%), local results are tested. Invalid results are marked with an absolute error threshold of 0.15, ensuring that the invalid percentage is ≤ 10%. If it exceeds this threshold, the decision tree depth (7-9) or the number of splits (15-25) is adjusted. Finally, the F1 score (with precision and recall each accounting for 50% of the weight) is used as the performance indicator. Base learners with F1 ≥ 0.85 are assigned a weight of 0.3, those with F1 between 0.75 and 0.85 are assigned a weight of 0.2, and those below 0.75 are assigned a weight of 0.1 (totaling 1). The weighted arithmetic mean method is used to fuse local results. The calculation precision is retained to 6 decimal places. The results are tested for normality with a p-value ≥ 0.05 and for validation set accuracy ≥ 88%. If the criteria are not met, the indicator weights are adjusted (e.g., F1 percentage 60%) or the fusion algorithm is adjusted. The model integrates multi-dimensional feature learning results, reduces the bias and variance of a single model, avoids recognition errors caused by the limitations of a single base learner, and outputs stable and reliable preliminary water quality change recognition results. As the core decision model for water quality change recognition, it transforms the causal information and temporal features processed in the early stages into preliminary results that can be directly used for type mapping. This not only ensures the high accuracy and reliability of the recognition results, but also achieves optimal utilization of the base learner performance through dynamic weight allocation. It provides an efficient and robust integrated learning solution for water plant influent water quality change recognition, and also provides a practical reference for multi-model collaborative processing of complex environmental data.

[0050] like Figure 2 As shown, a water quality change identification system for water treatment plant influent includes: The system comprises several components: a multi-dimensional water quality parameter acquisition unit (MMG unit, CE unit, COD unit, ammonia nitrogen unit, and total phosphorus unit), a time series dataset construction unit, a time series dataset construction unit, a causal correlation mining and weight matrix generation unit, a causal correlation weight matrix, and a feature extraction unit that integrates causal information. The MMG unit collects data on turbidity, pH, dissolved oxygen, COD, ammonia nitrogen, and total phosphorus concentration at the water plant inlet for a preset duration, removes outliers, and outputs screening data. The MMG unit receives the screening data, divides the data into subsets according to preset time intervals, and constructs the time series dataset. The CE unit receives the time series dataset, mines causal correlations between water quality parameters using a hybrid model based on causal inference, and outputs the causal correlation weight matrix. The system comprises the following units: a feature extraction unit (connected to the causal association mining and weight matrix generation unit and the time series dataset construction unit), a gradient boosting ensemble recognition unit (connected to the gradient boosting ensemble recognition unit), a gradient boosting ensemble model ... and a gradient boosting ensemble model (connected to the gradient boosting ensemble recognition unit).

[0051] A method and system for identifying changes in influent water quality at water treatment plants are disclosed. This method utilizes a hybrid model based on causal inference to conduct in-depth analysis of multiple water quality parameters, including turbidity, pH, dissolved oxygen content, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration. It meticulously explores the causal influence strength of different parameters over time, generating a precise causal correlation weight matrix. This process not only clearly distinguishes between true and false correlations but also provides reliable causal evidence for subsequent water quality change identification, making the identification results more convincing. It also provides strong support for water treatment plants to trace the root causes of water quality changes, addressing the weakness of existing causal analysis techniques. This method first extracts features from the water quality parameter sequence comprehensively from both time directions using a bidirectional long short-term memory network combined with an attention mechanism. Simultaneously, it accurately assesses the importance of each feature dimension, assigning higher weights to key features to ensure comprehensive and targeted feature extraction. Then, through a gradient boosting machine ensemble model, multiple base learners perform feature learning in parallel. Instead of simply summing the local recognition results from each base learner, the results are dynamically weighted based on their performance and fused, significantly improving the reliability and accuracy of the recognition results and effectively compensating for the shortcomings of existing technologies in feature utilization and result integration. Furthermore, this method and system possess the advantages of overall high efficiency and strong adaptability. From water quality parameter acquisition to final recognition result output, each step is closely integrated. Multiple units within the system, such as the multi-dimensional water quality parameter acquisition unit and the time-series dataset construction unit, have clearly defined roles and work collaboratively to form a complete and efficient recognition process. This allows for rapid response to water quality changes, saving valuable time for adjusting water treatment processes. Meanwhile, this method can flexibly respond to the fluctuation characteristics of water quality parameters at the inlet of different water plants. Whether it is a change in the type of parameter or a difference in the amplitude of fluctuation, it can achieve accurate identification through dynamic adjustment of the internal model, effectively meeting the diverse needs of different water plants for identifying changes in influent water quality, and further highlighting its superiority over existing technologies.

[0052] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various equivalent changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for identifying changes in the influent water quality of a water treatment plant, characterized in that, Includes the following steps: Step S1: Collect multiple water quality parameters from the water plant inlet for a continuous preset time period. The water quality parameters include at least turbidity, pH value, dissolved oxygen content, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration. Perform outlier removal on the collected water quality parameter data and retain the water quality parameter screening data that meets the preset data validity standards. Step S2: Divide the water quality parameter screening data into multiple data subsets according to a preset time interval, with each data subset corresponding to a time segment, and construct a water quality parameter time series dataset; Step S3: Input the water quality parameter time series dataset into the hybrid model based on causal inference, and use the hybrid model based on causal inference to mine the causal relationship between different water quality parameters, determine the causal influence strength of different water quality parameters in the time dimension, and output the causal relationship weight matrix corresponding to different water quality parameters. Step S4: The causal association weight matrix is ​​fused with the water quality parameter time series dataset to obtain a water quality parameter sequence with fused causal information. The water quality parameter sequence with fused causal information is input into a model with a bidirectional long short-term memory network combined with an attention mechanism. The bidirectional long short-term memory network extracts forward and backward time features from the water quality parameter sequence with fused causal information to obtain a bidirectional time feature vector. Then, the importance of different feature dimensions in the bidirectional time feature vector is evaluated by the attention mechanism, and attention weights are assigned to different feature dimensions to generate a feature vector with attention weights. Step S5: Input the attention-weighted feature vector into the gradient booster ensemble model. Perform parallel feature learning on the attention-weighted feature vector through multiple base learners in the gradient booster ensemble model. Each base learner outputs the corresponding local water quality change feature recognition result. Perform weighted fusion on all local water quality change feature recognition results to obtain the preliminary water quality change recognition result. Step S6: Perform feature mapping processing on the preliminary water quality change identification results, map them to the preset water quality change type division space, determine the specific change type corresponding to the water quality of the water plant influent, and complete the water quality change identification process of the water plant influent. When using the hybrid model based on causal inference to explore the causal relationships among different water quality parameters in step S3, a causal relationship strength calculation model is adopted. The expression of the causal relationship strength calculation model is as follows: in, This represents the causal relationship strength between the i-th water quality parameter and the j-th water quality parameter at time t. Indicates that the i-th water quality parameter is in The value at time, This represents the value of the j-th water quality parameter at time t, and n represents the preset time lag window length. The coefficient represents the inherent correlation between the i-th water quality parameter and the j-th water quality parameter, with a value range of [0.1, 0.9]. The water quality parameters include turbidity. pH value Dissolved oxygen content COD concentration ammonia nitrogen concentration Total phosphorus concentration In step S4, when the bidirectional long short-term memory network combined with the attention mechanism generates feature vectors with attention weights, an attention weight calculation model is used. The expression of the attention weight calculation model is as follows: in, This represents the attention weight corresponding to the m-th bidirectional temporal feature vector. This represents the m-th bidirectional time feature vector. Let M represent the average eigenvector of all bidirectional time eigenvectors, and M represent the total number of bidirectional time eigenvectors. This represents the attention score calculation function, which uses cosine similarity as the calculation method. In step S5, when the gradient boosting machine ensemble model performs parallel feature learning on the feature vectors with attention weights, it adopts a base learner weight allocation model, the expression of which is: in, This represents the weight of the q-th base learner. This represents the feature learning accuracy of the q-th base learner on the validation dataset. The difference between the feature learning results of the q-th base learner and other base learners is represented by Q, where Q represents the total number of base learners. In step S5, when weighting and fusing the local water quality change feature identification results, a fusion result calculation model is used, and the expression for the fusion result calculation model is: ,in, This indicates the preliminary results of water quality change identification. This represents the local water quality change feature recognition result output by the q-th base learner.

2. The method for identifying changes in influent water quality at a water plant according to claim 1, characterized in that, In step S3, when the hybrid model based on causal inference outputs the causal association weight matrix, the weight matrix is ​​used to update the model. The expression for the weight matrix update model is: ,in, express Causal correlation weight matrix under iteration number, This represents the causal correlation weight matrix at iteration number t. This represents the matrix update step size, with a value range of 1. , The loss function L represents the weight matrix at iteration number t. The gradient; in step S4, when the bidirectional long short-term memory network extracts the bidirectional temporal feature vector, a gated update model is adopted, and the expression of the gated update model is: , in, These represent the output values ​​of the input gate, forget gate, and output gate, respectively. This represents the sigmoid activation function. These represent the weight matrices corresponding to different gates. These represent the bias terms corresponding to different gates. express The hidden state at all times This represents the input features at time t. Indicates the state of candidate cells. This represents the cell state at time t. This represents the hidden state at time t. This represents element-wise multiplication.

3. The method for identifying changes in influent water quality at a water plant according to claim 2, characterized in that, In step S5, when the base learner of the gradient boosting machine ensemble model performs feature learning, a loss function is used to optimize the model. The expression for the loss function optimization model is: ,in, This represents the value of the loss function. Let K represent the set of parameters for the base learner, and K represent the number of training samples. This represents the true label of the k-th training sample. This represents the predicted output value of the base learner for the k-th training sample; in step S6, when performing feature mapping processing on the preliminary water quality change identification results, a mapping model is used, and the expression of the mapping model is: in, This represents the mapped water quality change type identifier value. This represents the minimum value indicating the initial water quality change identification result. This represents the maximum value of the preliminary water quality change identification results. This represents the minimum identifier value in the spatial classification of water quality change types. This represents the maximum identifier value in the spatial classification of water quality change types.

4. The method for identifying changes in the influent water quality of a water plant according to claim 1, characterized in that, Before mining causal relationships using the hybrid model based on causal inference in step S3, a causal relationship initialization model is used. The expression for the causal relationship initialization model is as follows: in, This represents the initial value indicating the causal relationship between the i-th and j-th water quality parameters. This represents the covariance between the i-th and j-th water quality parameters. This represents the variance of the i-th water quality parameter. Let j represent the variance of the j-th water quality parameter. This represents the initial adjustment coefficient, with a value range of [value range missing]. In step S4, when the attention mechanism evaluates the importance of feature dimensions, a feature importance calculation model is used. The expression for the feature importance calculation model is as follows: in, This represents the importance index of the m-th feature dimension. This represents the value of the m-th feature dimension in the k-th sample. This represents the average value of the m-th feature dimension. This represents the attention weight of the m-th feature dimension in the k-th sample, where K represents the number of training samples.

5. The method for identifying changes in influent water quality at a water plant according to claim 1, characterized in that, Step S3 specifically includes the following sub-steps: S31: The water quality parameter time series dataset is split into multiple single-parameter time series according to the water quality parameter type. Each single-parameter time series corresponds to the change data of a water quality parameter within a preset time period. Each single-parameter time series is segmented in the time dimension to obtain multiple single-parameter time segment sequences. Each single-parameter time segment sequence contains a preset number of time point data. S32: The different single-parameter time segment sequences are input into the causal detection module of the hybrid model based on causal inference. The causal detection module calculates the lag correlation coefficient between the single-parameter time segment sequences corresponding to any two water quality parameters. Based on the lag correlation coefficient, the possible causal relationship between the two water quality parameters is determined. S33: Based on the preliminary causal relationship direction information, construct a preliminary causal relationship graph. In the preliminary causal relationship graph, each node represents a water quality parameter, and each edge represents the preliminary causal relationship between two water quality parameters. Verify the causal strength of each edge in the preliminary causal relationship graph, and remove edges with causal strength lower than a preset strength threshold to obtain an optimized causal relationship graph. S34: According to the optimized causal relationship graph, extract the causal association information corresponding to different water quality parameters, convert the causal association information into a matrix form, and generate a causal association weight matrix corresponding to different water quality parameters. The value of each element in the causal association weight matrix represents the strength of the causal association between the corresponding two water quality parameters.

6. The method for identifying changes in the influent water quality of a water plant according to claim 1, characterized in that, Step S4 specifically includes the following sub-steps: S41: Multiply each element in the causal association weight matrix with the corresponding water quality parameter data at the same time point in the water quality parameter time series dataset to obtain water quality parameter data with causal weights. Arrange all water quality parameter data with causal weights in chronological order to form a water quality parameter sequence that integrates causal information. The water quality parameter sequence that integrates causal information retains the chronological order of the original water quality parameter time series. S42: Divide the water quality parameter sequence that integrates causal information into multiple input sub-sequences according to a preset sequence length. Each input sub-sequence serves as input data for a bidirectional long short-term memory network. Input the input sub-sequences into the forward propagation layer and the backward propagation layer of the bidirectional long short-term memory network. The forward propagation layer extracts features from the input sub-sequence from the start time to the end time, and the backward propagation layer extracts features from the input sub-sequence from the end time to the start time. S4 3: Obtain the local feature vectors output by the forward propagation layer and the backward propagation layer at each time point. Concatenate the forward local feature vectors and backward local feature vectors at the same time point to obtain the bidirectional time feature vector corresponding to that time point. Combine the bidirectional time feature vectors of all time points in chronological order to form a set of bidirectional time feature vectors. S44: Input the set of bidirectional time feature vectors into the attention mechanism module. The attention mechanism module calculates the similarity between each bidirectional time feature vector and the preset reference vector. Determine the attention weight corresponding to each bidirectional time feature vector based on the similarity. Multiply each bidirectional time feature vector with its corresponding attention weight to obtain a feature vector with attention weight.

7. The method for identifying changes in influent water quality at a water plant according to claim 1, characterized in that, Step S5 specifically includes the following sub-steps: S51: Divide the feature vector with attention weights into multiple feature sub-vectors, each feature sub-vector containing a preset number of feature dimensions, and each feature sub-vector corresponding to a base learner in the gradient boosting machine ensemble model. Input different feature sub-vectors into the corresponding base learners respectively; S52: Each base learner performs feature transformation processing on the input feature sub-vectors, mapping the feature sub-vectors to a high-dimensional feature space through a preset feature transformation function to obtain high-dimensional feature vectors. Construct a decision tree for the high-dimensional feature vectors by recursively dividing the high-dimensional feature space to generate a decision tree structure. Each leaf node of the decision tree corresponds to a local water quality change feature recognition result; S53: Perform validity verification on the local water quality change feature recognition results output by each base learner, comparing the local water quality change feature recognition results with the corresponding real feature results in the validation set, calculating the error value of the local water quality change feature recognition results, and retaining the local water quality change feature recognition results with error values ​​lower than a preset error threshold; S54: Based on the performance indicators of different base learners during the training process, determine the weight coefficients corresponding to each base learner, multiply the identification results of different local water quality change features with the corresponding weight coefficients, and then sum all the product results to obtain the preliminary water quality change identification results.

8. A water quality change identification system for water plant influent, characterized in that, This system is applied to the water quality change identification method for water plant influent as described in claim 1, comprising: The multi-dimensional water quality parameter acquisition unit is used to collect data on turbidity, pH value, dissolved oxygen content, COD concentration, ammonia nitrogen concentration, and total phosphorus concentration at the water plant inlet for a continuous preset time. It removes outliers from the collected data and outputs water quality parameter screening data. The time series dataset construction unit is connected to the water quality parameter multi-dimensional acquisition unit. It receives the water quality parameter screening data output by the water quality parameter multi-dimensional acquisition unit, divides the data subsets according to the preset time interval, and constructs the water quality parameter time series dataset. The causal association mining and weight matrix generation unit is connected to the time series dataset construction unit. It receives the water quality parameter time series dataset, mines the causal association between water quality parameters through a hybrid model based on causal inference, and outputs the causal association weight matrix. The feature extraction unit that integrates causal information is connected to the causal association mining and weight matrix generation unit and the time series dataset construction unit. It receives the causal association weight matrix and the water quality parameter time series dataset, and integrates them to obtain the water quality parameter sequence with integrated causal information. It generates a feature vector with attention weights through a model that combines a bidirectional long short-term memory network with an attention mechanism. The gradient boosting integrated identification unit is connected to the feature extraction unit that integrates causal information. It receives feature vectors with attention weights, performs parallel feature learning and result fusion through the gradient boosting machine integrated model, and outputs preliminary water quality change identification results. The water quality change type mapping and output unit is connected to the gradient enhancement integrated recognition unit. It receives the preliminary water quality change recognition results, performs feature mapping and determines the water quality change type, and outputs the water quality change recognition results.

Citation Information

Patent Citations

  • Pollution type identification method and device, electronic equipment and storage medium

    CN115510891A

  • Water pollution composite treatment method and system based on water quality pollution real-time monitoring

    CN120181299A