A method and system for quickly constructing a wastewater treatment plant water quality fingerprint early warning model

By constructing and migrating a water quality fingerprint early warning model in newly built wastewater treatment plants, the problem of lack of historical data in new plants has been solved, enabling rapid and accurate water quality safety monitoring and reducing costs.

CN122173882APending Publication Date: 2026-06-09GUIZHOU UNIVERSITY OF FINANCE AND ECONOMICS +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUIZHOU UNIVERSITY OF FINANCE AND ECONOMICS
Filing Date
2026-01-27
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Newly built wastewater treatment plants lack sufficient historical data, making it impossible to quickly establish accurate water quality fingerprint early warning models, resulting in insufficient water quality safety monitoring capabilities and increased operating costs.

Method used

A basic model is built using water quality fingerprint data and abnormal event labels from wastewater treatment plants in the source region. This model is then transferred to the target domain using a domain adaptation method, including feature extraction and reconstruction of the classifier network. An adaptive early warning model for the target domain is then quickly constructed using the existing model.

Benefits of technology

Rapidly building water quality fingerprint early warning models in newly built wastewater treatment plants shortens the deployment cycle, reduces data collection costs, and improves water quality safety monitoring capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122173882A_ABST
    Figure CN122173882A_ABST
Patent Text Reader

Abstract

The application provides a wastewater treatment plant water quality fingerprint early warning model rapid construction method and system, comprising: acquiring water quality fingerprint data and abnormal event labels of a source domain wastewater treatment plant, and constructing a source domain early warning base model; collecting short-term water quality data in a target domain, reducing the feature distribution difference between the source domain and the target domain through a domain self-adaptation technology to obtain a domain self-adaptation feature extractor; reconstructing a classifier network based on the feature extractor and training the classifier network using target domain data; and finally, performing performance evaluation and integrating the model meeting the requirements into an online monitoring system. The application realizes effective migration of knowledge from a data-rich source domain to a data-limited target domain, greatly shortens the model construction period, improves the accuracy and timeliness of water quality abnormality early warning, and provides technical support for ensuring the safe and stable operation of the wastewater treatment plant.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of wastewater treatment technology, specifically to a method and system for rapidly constructing a water quality fingerprint early warning model for wastewater treatment plants, which solves the problem that newly built wastewater treatment plants lack sufficient historical data to quickly establish an accurate water quality fingerprint early warning model. Background Technology

[0002] The safe and stable operation of wastewater treatment plants is of great significance for ensuring environmental safety and public health. Water fingerprint analysis technology, as a novel water quality monitoring method, can rapidly and comprehensively reflect the overall characteristics of water bodies through spectral features, and has gradually become an important technical means for wastewater treatment plants to provide early warning of water quality anomalies.

[0003] Traditional wastewater treatment plant water quality monitoring mainly relies on the detection of discrete physicochemical indicators, such as COD, BOD, pH, and ammonia nitrogen. For example, automatic online monitoring systems collect these indicator data in real time through specific sensors and use threshold judgments to issue alarms for abnormalities; or they use statistical models based on historical data, such as the ARIMA time series model, to predict water quality change trends and identify potential anomalies.

[0004] Water fingerprinting technology, which has been developed in recent years, obtains the "fingerprint characteristics" of water bodies through spectral analysis (ultraviolet, visible light, near-infrared, etc.), which can more comprehensively reflect the overall water quality status. Currently, the construction of early warning models based on water fingerprinting usually adopts deep learning methods. This method first collects spectral data of water bodies as water fingerprints using spectrometers, and then combines them with historical abnormal event labels to train a deep neural network model (such as CNN or LSTM network) to identify potential water quality anomalies.

[0005] However, this method requires a large amount of historical data as training samples, typically 1-2 years of data accumulation to build an accurate early warning model, resulting in a long training and deployment cycle. For newly built wastewater treatment plants, the lack of sufficient historical data makes it impossible to quickly establish an accurate water quality fingerprint early warning model. This leads to insufficient water quality safety risk monitoring capabilities during the initial operation phase of new plants. Furthermore, extending the model deployment cycle to obtain sufficient training data increases the operating costs and risks for enterprises. In addition, differences in influent characteristics, treatment processes, and operating parameters between different wastewater treatment plants often result in a significant decline in model performance when directly applying existing models to new plants. Summary of the Invention

[0006] The purpose of this invention is to provide a method and system for rapidly constructing a water quality fingerprint early warning model for wastewater treatment plants, aiming to solve the problem that newly built wastewater treatment plants cannot quickly establish an accurate water quality fingerprint early warning model due to a lack of sufficient historical data.

[0007] To achieve the above objectives, the present invention provides a method for rapidly constructing a water quality fingerprint early warning model for wastewater treatment plants, comprising: The raw water quality fingerprint data and water quality anomaly event label data of the source wastewater treatment plant are obtained. The raw water quality fingerprint data and the water quality anomaly event label data are associated and labeled and then preprocessed to obtain the source training dataset. Based on the source domain training dataset, a source domain early warning basic model including a feature extraction network and a classifier network is constructed. The source domain early warning basic model is trained to obtain the trained source domain early warning basic model. Short-term water quality fingerprint data is collected from wastewater treatment plants in the target domain, and the short-term water quality fingerprint data is processed according to the preprocessing procedure to obtain the target domain adaptation dataset. The feature extraction network in the trained source domain early warning base model is used as a feature extractor. The feature extractor is used to process the source domain training dataset and the target domain adaptation dataset to obtain the source domain feature distribution representation and the target domain feature distribution representation. The difference between the source domain feature distribution representation and the target domain feature distribution representation is reduced by the domain adaptation method to obtain the domain-adaptive feature extractor. The classifier network is reconstructed based on the domain-adaptive feature extractor, and the reconstructed classifier network is trained using the target domain adaptation dataset to obtain the target domain adaptation early warning model. The target domain adaptation early warning model is evaluated using the test set in the target domain adaptation dataset. When the performance evaluation result reaches a predetermined threshold, the target domain adaptation early warning model is integrated into the online monitoring system.

[0008] Further, the process of associating and labeling the original water quality fingerprint data with the water quality anomaly event label data, followed by preprocessing, yields a source domain training dataset, including: Ultraviolet-visible spectrometers and near-infrared spectrometers were installed at the inlet, outlet, and effluent of the Yuanyu wastewater treatment plant. Water quality spectral data were collected at 15-minute intervals, and the sampling time and location were recorded to obtain the original water quality fingerprint data. Collect abnormal events such as toxic shocks, process fluctuations, and equipment failures from the historical operation records of the wastewater treatment plants in the source area, along with their corresponding occurrence times, and establish an event tag library to obtain the water quality abnormal event tag data; Align the original water quality fingerprint data with the water quality abnormal event label data according to the timestamp, determine the event status corresponding to each water quality fingerprint sample, and obtain a time-aligned labeled dataset; Baseline correction, scattering correction, and noise filtering are performed on the spectral data in the time-aligned labeled dataset to improve the signal-to-noise ratio. Spectral normalization is then performed to eliminate system differences between different batches of data to obtain standardized spectral data. Based on the standardized spectral data, a synthetic minority class oversampling technique is used to increase the number of anomalous event samples, thereby obtaining class-balanced training data. The class-balanced training data is divided into a training set, a validation set, and a test set according to time order to obtain the source domain training dataset.

[0009] Furthermore, the construction of a source domain early warning basic model including a feature extraction network and a classifier network, and the training of the source domain early warning basic model to obtain the trained source domain early warning basic model, includes: A multi-layer convolutional neural network with a combination of 3 to 5 convolutional and pooling layers was designed as a feature extraction network to extract high-level feature representations from water fingerprint spectra, resulting in the feature extraction network structure. Design a classifier network consisting of fully connected layers. The classifier network receives the output of the feature extraction network structure and outputs the water quality state prediction result through the softmax activation function, thus obtaining the source domain early warning basic model architecture. The source domain early warning basic model architecture is trained using the training set in the source domain training dataset. The cross-entropy loss function and Adam optimizer are used, and the learning rate and batch size are set to perform an iterative training process to obtain the initial training model. The performance of the initial trained model is evaluated using the validation set in the source domain training dataset. The learning rate, number of network layers, and regularization strength are adjusted to obtain the model with optimized parameters. The optimized model is evaluated using the test set in the source domain training dataset. Accuracy, precision, recall, and F1 score are calculated to obtain the trained source domain early warning basic model.

[0010] Further, the step of processing the short-term water quality fingerprint data according to the preprocessing procedure to obtain the target domain adaptation dataset includes: By deploying ultraviolet-visible spectrometers and near-infrared spectrometers of the same specifications as those used in the source wastewater treatment plant at key monitoring points in the target wastewater treatment plant, a target domain monitoring system is obtained. The target domain monitoring system collects water quality fingerprint data during the initial 1 to 3 months of operation, and records abnormal events and their corresponding tags to obtain a short-term dataset of the target domain. Using the same preprocessing procedure as the source domain training dataset, the spectral data in the target domain short-term dataset are processed through baseline correction, scattering correction, noise filtering, and normalization to obtain standardized target domain data. The standardized target domain data is divided into an adaptation training set and a test set to obtain the target domain adaptation dataset.

[0011] Further, the step of using the feature extraction network in the trained source domain early warning base model as a feature extractor, and using the feature extractor to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation; reducing the difference between the source domain feature distribution representation and the target domain feature distribution representation through a domain adaptation method to obtain a domain-adaptive feature extractor includes: Using the feature extraction network in the trained source domain early warning basic model as a feature extractor, the parameters of the bottom convolutional layer of the feature extractor are frozen to obtain the decoupled feature extractor. The decoupled feature extractor is used to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature representation and the target domain feature representation. The mean, variance and covariance matrix are calculated for the source domain feature representation and the target domain feature representation respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation. Based on the decoupled feature extractor, a label predictor for predicting sample labels and a domain classifier for determining the domain to which a sample belongs are added to obtain the domain adversarial network architecture. The domain adversarial network architecture is adversarially trained using the source domain training dataset and the target domain adaptation dataset. The feature extractor is then adversarially trained by using a gradient inversion layer to simultaneously minimize the classification error of the label predictor and maximize the discrimination error of the domain classifier. Based on the features extracted by the adversarial-trained feature extractor, the maximum average difference between the source domain feature distribution representation and the target domain feature distribution representation is calculated in the feature space. The adversarial-trained feature extractor is further fine-tuned by minimizing the maximum average difference to obtain a feature extractor with aligned feature distributions. Source domain validation data is extracted from the validation set of the source domain training dataset, and target domain validation data is extracted from the test set of the target domain adaptation dataset. The source domain validation data and the target domain validation data are processed respectively using the feature extractor aligned with the feature distribution. The alignment effect of the feature distribution is verified by t-SNE visualization and maximum mean difference metric to obtain the domain-adaptive feature extractor.

[0012] Further, the step of using the decoupled feature extractor to process the source domain training dataset and the target domain adaptation dataset respectively to obtain source domain feature representations and target domain feature representations, and calculating the mean, variance, and covariance matrices of the source domain feature representations and the target domain feature representations respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation, includes: A Monte Carlo dropout layer is added to the decoupled feature extractor so that the decoupled feature extractor can output the prediction result and its uncertainty estimate, thus obtaining the uncertainty quantification model; The uncertainty quantification model is used to process the source domain training dataset and the target domain adaptation dataset respectively, and the source domain feature representation and the target domain feature representation are extracted. For each feature of the source domain feature representation and the target domain feature representation, the coefficient of variation of its contribution to the prediction result is calculated through 10 to 20 Monte Carlo samplings to obtain the feature contribution uncertainty. The backpropagation algorithm is used to calculate the absolute gradient of each feature dimension in the source domain feature representation and the target domain feature representation with respect to the classification loss function. The absolute gradient value is then normalized and used as the feature importance score. The feature importance score is combined with the feature contribution uncertainty to obtain the feature importance-uncertainty matrix; Based on the feature importance-uncertainty matrix, features with feature importance scores greater than a preset importance threshold and feature contribution uncertainty less than a preset uncertainty threshold are sorted to obtain the key feature sorting results; Based on the ranking results of the key features, the weights of different feature channels in the uncertainty quantification model are dynamically adjusted to obtain an uncertainty-aware feature selection strategy. Based on the uncertainty-aware feature selection strategy, the uncertainty quantification model is used to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation.

[0013] Furthermore, the classifier network reconstructed based on the domain-adaptive feature extractor, and the reconstructed classifier network is trained using the target domain-adaptive dataset to obtain a target domain-adaptive early warning model, including: Based on the domain-adaptive feature extractor, the classifier network is reconstructed while keeping the parameters of the domain-adaptive feature extractor unchanged. Only the parameters of the classifier network are initialized to obtain the reconstructed model architecture. The classifier network in the reconstructed model architecture is trained under supervision using the adaptation training set in the target domain adaptation dataset with a learning rate of 0.0001 to 0.001 to obtain the model parameters for preliminary fine-tuning. A progressive learning rate decay strategy is implemented on the reconstructed model architecture, reducing the learning rate to 0.5 to 0.8 times the original learning rate after each preset number of training rounds, thereby obtaining an optimized training process; During the optimized training process, L1 regularization coefficients, L2 regularization coefficients, and Dropout ratios are introduced into the classifier network of the reconstructed model architecture to prevent the reconstructed model architecture from overfitting on the target domain adaptation dataset, thus obtaining a classifier network with regularization constraint parameters. The domain-adaptive feature extractor is combined with the classifier network with regularization constraint parameters to obtain a target domain model with regularization constraint parameters. The target domain model with regularization constraint parameters is used to predict the unlabeled data in the target domain adaptation dataset. The prediction results with a prediction confidence greater than 0.9 are selected as pseudo-labels to expand the adaptation training set for semi-supervised learning, and the pseudo-label-enhanced model is obtained. The Bagging ensemble method is used to train the reconstructed model architecture with 5 to 10 different initialization parameters and different learning rates and regularization coefficients. The prediction results of the 5 to 10 trained models are then integrated by weighted averaging to obtain the target domain adaptive early warning model.

[0014] Furthermore, the reconstructed model architecture is subjected to a progressive learning rate decay strategy, reducing the learning rate to 0.5 to 0.8 times the original learning rate after a preset number of training epochs, resulting in an optimized training process, including: A multi-objective optimization function is defined, which includes prediction accuracy, minimization of domain differences, and control of model complexity, thus obtaining a multi-objective evaluation system; Based on the labeled data in the target domain adaptation dataset and the multi-objective evaluation system, a Pareto optimal solution set for learning rate and regularization strength is constructed to obtain the Pareto front. Calculate the prediction uncertainty under each set of hyperparameter configurations on the Pareto front, and perform a double sorting based on the position on the Pareto front to obtain the double sorting result; Based on the double ranking results, an uncertainty threshold is set. When the prediction uncertainty of the reconstructed model architecture on the validation set is greater than the uncertainty threshold, it is defined as a high uncertainty stage. When the prediction uncertainty of the reconstructed model architecture on the validation set is less than or equal to the uncertainty threshold, it is defined as a low uncertainty stage. In the high uncertainty phase, the learning rate is kept in the range of 0.0005 to 0.001 to enhance exploratory behavior, and in the low uncertainty phase, the learning rate is reduced to the range of 0.0001 to 0.0005 to accelerate convergence, thus obtaining an adaptive parameter scheduling scheme. The reconstructed model architecture is trained based on the adaptive parameter scheduling scheme. Each training epoch lasts for 10 to 20 training epochs and is considered a training cycle. At the end of each training cycle, the accuracy and prediction uncertainty of the reconstructed model architecture on the validation set are evaluated. Based on the accuracy improvement and prediction uncertainty reduction of the current training cycle compared to the previous training cycle, the learning rate decay strategy for subsequent training is automatically adjusted to obtain the optimized training process.

[0015] Further, the unlabeled data in the target domain adaptation dataset is predicted using the target domain model with regularization constraint parameters. Prediction results with a confidence level greater than 0.9 are selected as pseudo-labels to expand the adaptation training set for semi-supervised learning, resulting in a pseudo-label-enhanced model, including: For each sample of unlabeled data in the target domain adaptation dataset that fits the training set, the target domain model with regularization constraint parameters is used to perform 10 to 30 Monte Carlo predictions. The mean of the predicted class probability for each sample is calculated as the prediction confidence, and the standard deviation of the predicted class probability is calculated as the prediction uncertainty, so as to obtain the sample prediction evaluation result. The prediction confidence and prediction uncertainty in the sample prediction evaluation results are constructed into a two-dimensional evaluation space. Pareto ranking is used to identify samples located on the Pareto front to obtain a candidate sample set. Based on the accuracy of the target domain model with regularization constraint parameters on the validation set, the confidence threshold is set to 0.95 to 1.05 times the accuracy, and the uncertainty threshold is set to 0.8 to 1.2 times the median of the prediction uncertainty of all samples in the sample prediction evaluation results, thus obtaining the dynamic confidence threshold and the dynamic uncertainty threshold. Calculate the gradient norm of each sample in the candidate sample set with respect to the classifier network parameters in the target domain model with regularization constraint parameters, normalize the gradient norm and use it as the gradient contribution score, and sort the samples in the candidate sample set according to the gradient contribution score to obtain the gradient contribution ranking result. Based on the gradient contribution ranking results, samples with prediction confidence greater than the dynamic confidence threshold and prediction uncertainty less than the dynamic uncertainty threshold are selected. The predicted category of the sample is added as a pseudo-label to the adaptation training set for training to obtain the pseudo-label-enhanced model.

[0016] Furthermore, the design includes a multi-layer convolutional neural network with a combination of 3 to 5 convolutional and pooling layers as a feature extraction network, used to extract high-level feature representations from water fingerprint spectra, resulting in a feature extraction network structure including: A mathematical model of a quadratic integral firing neuron is constructed, wherein the membrane potential dynamics of the mathematical model are derived from the quadratic differential equation dV / dt=V²+I(t)-υ. reset Description, where V is the membrane potential, I(t) is the input current, and υ reset To reset the potential parameters, a quadratic integral firing neuron model was obtained; The step pulse firing function in the quadratic integral firing neuron model is replaced with the sigmoid approximation function to ensure the continuity and differentiability of the gradient, resulting in a differentiable neuron firing model. Based on the differentiable neuron firing model, a feature extraction network consisting of 3 to 5 convolutional layers is constructed. Each convolutional layer is followed by a batch normalization layer and the differentiable neuron firing model as the activation function, and then by a max pooling layer to obtain a convolutional network based on quadratic integral firing neurons. In each convolutional layer of the convolutional network based on quadratic integral firing neurons, the convolutional kernel parameters are initialized to follow a Gaussian distribution with a mean of 0 and a standard deviation of 0.01. The reset potential parameter υ of the quadratic integral firing neuron model is then... reset Initialize the parameters to values ​​in the range of -0.1 to -0.5 to obtain the convolutional network after parameter initialization; The output of the convolutional network after parameter initialization is flattened into a one-dimensional feature vector through a global average pooling layer to obtain the feature extraction network structure.

[0017] Further, the step of training the source domain early warning basic model architecture using the training set in the source domain training dataset, employing the cross-entropy loss function and the Adam optimizer, and setting the learning rate and batch size to perform an iterative training process to obtain an initial training model, includes: Based on the differentiable neuron firing model in the feature extraction network structure, the gradient of the loss function with respect to the parameters of the quadratic integral firing neuron model is calculated using the chain rule, thus obtaining the gradient calculation scheme. Construct a joint loss function that includes both classification cross-entropy loss and neuron average firing rate regularization term to obtain the joint optimization objective; In the gradient calculation scheme, when the absolute value of the gradient of the quadratic integral firing neuron model is greater than a preset threshold, the gradient is clipped to the range of the preset threshold to obtain a gradient clipping strategy. Based on the gradient calculation scheme, the joint optimization objective, and the gradient pruning strategy, the source domain early warning basic model architecture is trained using the training set in the source domain training dataset, employing the Adam optimizer and an initial learning rate of 0.0001 to 0.001 to obtain the initial training model.

[0018] Further, the performance of the initially trained model is evaluated using the validation set in the source domain training dataset, and the learning rate, number of network layers, and regularization strength are adjusted to obtain a parameter-optimized model, including: The anomaly detection rate, early warning time, and false alarm rate of the initial training model are defined as performance evaluation indicators. The score of the initial training model on each performance evaluation indicator is calculated using the validation set in the source domain training dataset to obtain the initial performance evaluation result. Based on the initial performance evaluation results, the learning rate search range is set to 0.00001 to 0.01, the network layer search range is 3 to 5 layers, the L1 regularization coefficient search range is 0 to 0.01, and the L2 regularization coefficient search range is 0 to 0.1, thus obtaining the hyperparameter search space; A grid search method is used in the hyperparameter search space to generate 20 to 50 sets of hyperparameter configuration combinations. The initial training model is retrained for each set of hyperparameter configuration combinations to obtain multiple candidate models. The performance of the multiple candidate models on three metrics—anomaly detection rate, early warning time, and false alarm rate—is evaluated using the validation set in the source domain training dataset. The comprehensive performance score of each candidate model is calculated to obtain the candidate model performance evaluation results. From the performance evaluation results of the candidate models, the candidate model with the highest comprehensive performance score is selected, and the corresponding learning rate, number of network layers and regularization strength parameters are extracted to obtain the optimal hyperparameter configuration. The initial training model is retrained using the optimal hyperparameter configuration to obtain the model with optimized parameters.

[0019] Further, the step of using the test set in the target domain adaptation dataset to perform performance evaluation on the target domain adaptation early warning model, and integrating the target domain adaptation early warning model into the online monitoring system when the performance evaluation result reaches a predetermined threshold, includes: The target domain adaptation warning model is comprehensively evaluated using the test set in the target domain adaptation dataset. The accuracy, precision, recall and F1 score are calculated and compared with a predetermined threshold to obtain a performance evaluation report. The detection performance and reliability of the target domain adaptive early warning model on different types of abnormal events are evaluated by confidence analysis, confusion matrix and ROC curve, potential weaknesses are identified and a reliability analysis report is obtained; The target domain adaptive early warning model is encapsulated into a standardized software module that includes data preprocessing, feature extraction, and anomaly prediction functions. A model interface specification is designed to obtain a deployable early warning model software package. The deployable early warning model software package is integrated into the online monitoring system of the wastewater treatment plant, and data access, early warning thresholds and alarm methods are configured to obtain a complete early warning system; Develop a visual interface to display water quality fingerprint data, anomaly warning results and confidence levels in real time, support historical data backtracking and trend analysis, and obtain a warning result visualization module; The design incorporates a continuous update mechanism for the target domain adaptive early warning model. This mechanism involves periodically collecting new water quality data and feedback information, and employing an incremental learning method to update the parameters of the target domain adaptive early warning model, thereby achieving continuous improvement in its performance.

[0020] This invention also provides a rapid construction system for a water quality fingerprint early warning model of a wastewater treatment plant, comprising: The source domain data acquisition and preprocessing module is used to acquire the original water quality fingerprint data and water quality abnormal event label data of the source domain sewage treatment plant. After associating and labeling the original water quality fingerprint data and the water quality abnormal event label data, it is preprocessed to obtain the source domain training dataset. The source domain early warning basic model training module is used to construct a source domain early warning basic model containing a feature extraction network and a classifier network based on the source domain training dataset, and to train the source domain early warning basic model to obtain the trained source domain early warning basic model. The target domain data acquisition and processing module is used to collect short-term water quality fingerprint data from the wastewater treatment plant in the target domain, process the short-term water quality fingerprint data according to the preprocessing process, and obtain the target domain adapted dataset. The domain-adaptive feature extraction module is used to use the feature extraction network in the trained source domain early warning base model as a feature extractor, and to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation; the difference between the source domain feature distribution representation and the target domain feature distribution representation is reduced by the domain-adaptive method to obtain the domain-adaptive feature extractor; The target domain model training module is used to reconstruct the classifier network based on the domain-adaptive feature extractor, and train the reconstructed classifier network using the target domain adaptation dataset to obtain the target domain adaptive early warning model. The model deployment and integration module is used to evaluate the performance of the target domain adaptation early warning model using the test set in the target domain adaptation dataset. When the performance evaluation result reaches a predetermined threshold, the target domain adaptation early warning model is integrated into the online monitoring system.

[0021] The technical solution provided by this invention utilizes water quality fingerprint data and anomaly tags from existing wastewater treatment plants to construct a source-domain early warning model. This model is then rapidly migrated to newly built wastewater treatment plants using a domain-adaptive method, enabling the rapid construction of a water quality fingerprint early warning model. This invention requires only 1-3 months of short-term data from newly built wastewater treatment plants, significantly shortening the deployment cycle of the early warning model, reducing data acquisition costs, while ensuring the model's accuracy in the new environment and improving water quality safety monitoring capabilities. Attached Figure Description

[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0023] Figure 1 This is a flowchart illustrating the rapid construction method for a wastewater treatment plant water quality fingerprint early warning model according to the present invention. Figure 2 This is a flowchart illustrating the training method of the source domain early warning basic model of the present invention; Figure 3 This is a schematic diagram of the structure of the wastewater treatment plant water quality fingerprint early warning model rapid construction system of the present invention. Detailed Implementation

[0024] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0025] like Figure 1 As shown, this invention provides a method for rapidly constructing a water quality fingerprint early warning model for wastewater treatment plants, comprising: Step S1: Obtain the original water quality fingerprint data and water quality abnormal event label data of the source wastewater treatment plant. After associating and labeling the original water quality fingerprint data and the water quality abnormal event label data, perform preprocessing to obtain the source training dataset. Step S2: Based on the source domain training dataset, construct a source domain early warning basic model that includes a feature extraction network and a classifier network, and train the source domain early warning basic model to obtain the trained source domain early warning basic model. Step S3: Collect short-term water quality fingerprint data at the wastewater treatment plant in the target domain, process the short-term water quality fingerprint data according to the preprocessing procedure, and obtain the target domain adaptation dataset. Step S4: Use the feature extraction network in the trained source domain early warning basic model as a feature extractor, and use the feature extractor to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation; reduce the difference between the source domain feature distribution representation and the target domain feature distribution representation through a domain adaptation method to obtain a domain-adaptive feature extractor; Step S5: Reconstruct the classifier network based on the domain-adaptive feature extractor, and train the reconstructed classifier network using the target domain adaptation dataset to obtain the target domain adaptation early warning model; Step S6: Use the test set in the target domain adaptation dataset to evaluate the performance of the target domain adaptation early warning model. When the performance evaluation result reaches a predetermined threshold, integrate the target domain adaptation early warning model into the online monitoring system.

[0026] In this embodiment, raw water quality fingerprint data and water quality anomaly event tag data of the source wastewater treatment plant are first acquired. The source area refers to a wastewater treatment plant that has been operating for a relatively long time and has accumulated rich water quality data and anomaly event records. Water quality fingerprint data is typically collected by a multi-parameter spectrometer, including multi-dimensional data such as ultraviolet-visible spectroscopy and fluorescence spectroscopy, which can comprehensively reflect the overall characteristics of components such as organic matter and suspended solids in the water. Water quality anomaly event tag data comes from the wastewater treatment plant's operation records, including the occurrence time, duration, type, and severity of various anomalies. These anomalies may include toxic substance impacts, microbial community imbalances, sudden changes in influent load, and other abnormal situations affecting treatment effectiveness. The acquired raw data often has issues such as asynchronous timelines, inconsistent formats, and missing values, requiring association labeling and preprocessing. During the association labeling process, water quality fingerprint data for the corresponding time period is labeled with the corresponding anomaly type based on the occurrence time and duration of the anomaly event; data from normal operation periods is labeled as normal. The preprocessing process includes time alignment, outlier handling, missing value imputation, and data normalization to ensure the data meets the input requirements of machine learning models. Furthermore, data augmentation is necessary, such as adding Gaussian noise and random shifting, to enhance the model's robustness. These processes result in a structured source domain training dataset, providing high-quality training material for subsequent model building.

[0027] Next, based on the source domain training dataset, a basic source domain early warning model is constructed, comprising a feature extraction network and a classifier network. This basic model employs a deep learning architecture, typically consisting of two parts: a feature extraction network and a classifier network. The feature extraction network is responsible for extracting abstract high-level features from the raw water quality fingerprint data. It usually employs a multi-layer convolutional neural network structure, effectively capturing local and global feature patterns in the spectral data. Specifically, the feature extraction network contains a combination of 3 to 5 convolutional layers and pooling layers. Each convolutional layer uses a different-sized kernel to capture features at different scales, while the pooling layers are used for dimensionality reduction and extraction of key features. The classifier network identifies and classifies anomaly types based on the extracted features. It typically uses a fully connected layer structure, with the last layer using a softmax activation function to output the probability distribution of each category. The model training process employs supervised learning, using the cross-entropy loss function to measure the difference between the predicted results and the true labels, and adaptively adjusting the network parameters using the Adam optimizer. To prevent overfitting, regularization techniques such as Dropout and L1 / L2 regularization are introduced during training. Furthermore, learning rate scheduling strategies, such as learning rate decay or periodic learning rates, are employed to optimize the model convergence process. After model training, performance is evaluated on the source domain validation set, including metrics such as accuracy, precision, recall, and F1 score, to ensure good model performance on source domain data. This results in a trained source domain early warning model that incorporates knowledge of source domain water quality anomaly patterns, providing a foundation for transfer to the target domain.

[0028] Then, short-term water quality fingerprint data is collected from wastewater treatment plants in the target domain. The target domain refers to newly built wastewater treatment plants or those requiring the establishment of water quality anomaly early warning systems. Due to short operating time or insufficient historical data, it is impossible to directly build a high-performance early warning model. The short-term water quality fingerprint data collected in the target domain should cover different operating conditions as much as possible, including spectral data under different hydraulic loads and different influent water quality conditions. The collection time is usually 2 to 4 weeks, much shorter than the amount of data required to build a complete early warning model (usually more than 6 months). The collected data is processed according to the same preprocessing workflow as the source domain data, including outlier detection and processing, missing value imputation, data normalization, etc., to ensure that the data format and distribution characteristics are compatible with the source domain data. Since the amount of data in the target domain is limited, the number of anomalous event samples may be small, so there may be class imbalance problems in the dataset, which need to be alleviated by synthetic minority class oversampling (SMOTE) or class weight adjustment. In addition, short-term data may not fully reflect the long-term variation characteristics of the system, so time series enhancement techniques, such as time warping and amplitude adjustment, can be introduced to increase data diversity. After these processes, a structured target domain adaptation dataset is obtained. Although the amount of data is limited, it contains key information on the water quality characteristics of the target domain, providing a foundation for subsequent domain adaptation.

[0029] Next, the feature extraction network in the trained source domain early warning model is decoupled and used as a feature extractor to process the source domain training dataset and the target domain adaptation dataset, respectively. The feature extractor is essentially a neural network that has learned to represent water quality fingerprint features, mapping the raw high-dimensional spectral data to a more abstract feature space. When the water quality fingerprint data from the source and target domains pass through this shared feature extractor, they generate their respective feature representations. However, due to differences in data distribution between the two domains, these feature representations often form different distribution regions in the feature space, affecting the model's generalization performance in the target domain. To quantify and analyze these distribution differences, the extracted features need to be statistically represented, calculating key statistics for the feature distribution of each domain, such as the mean vector and covariance matrix. These statistics together constitute the source domain feature distribution representation and the target domain feature distribution representation. By using visualization techniques (such as t-SNE or PCA) to reduce the dimensionality of the high-dimensional features, the distribution differences between the two domains in the feature space can be observed intuitively. These differences reflect variations in water quality characteristics, treatment processes, or operating conditions between the two wastewater treatment plants, and are the root cause of the poor performance when directly applying source domain models to the target domain. Therefore, domain-adaptive methods are needed to reduce these distributional differences, enabling feature extractors to extract cross-domain shared knowledge.

[0030] Then, a domain-adaptive feature extractor is obtained by reducing the difference between the source domain feature distribution representation and the target domain feature distribution representation through a domain adaptation method. Domain adaptation is a core technique of transfer learning, aiming to adjust the model to adapt to target tasks with different but related data distributions. In this method, an adversarial domain adaptation strategy is adopted to construct a domain adversarial neural network architecture. This architecture contains three main components: a feature extractor, a label predictor, and a domain discriminator. The feature extractor is the network part decoupled from the source domain model mentioned earlier; the label predictor is responsible for predicting the anomaly category based on features; and the domain discriminator attempts to determine which domain (source domain or target domain) the feature comes from. During training, a gradient reversal layer is introduced, so that the feature extractor must minimize the classification error and maximize the domain discriminant error, thereby learning a domain-invariant feature representation. Specifically, when a feature passes through the domain discriminator, the backpropagation gradient is reversed, causing the feature extractor to update in a direction that is difficult for the domain discriminator to distinguish. This is the core idea of ​​adversarial training. In addition to adversarial training, explicit distribution distance metrics, such as maximum mean difference (MMD) or Wasserstein distance, can also be introduced to directly minimize the statistical difference between the feature distributions of the two domains. Through multiple rounds of iterative training, the feature extractor gradually adjusts its parameters, enabling the extracted features to maintain their classification and discriminative capabilities while reducing inter-domain differences. This ultimately yields a domain-adaptive feature extractor capable of extracting shared feature representations from both the source and target domains that are discriminative for detecting water quality anomalies, laying the foundation for building a high-performance early warning model in the target domain.

[0031] Next, the classifier network is reconstructed based on the domain-adaptive feature extractor. The reconstructed classifier network is then trained using a target domain-adapted dataset to obtain a target domain-adapted early warning model. This step employs a "freeze feature extraction + retrain classifier" strategy, fully utilizing the feature extraction capabilities already adapted to the target domain while optimizing for the target domain-specific decision boundaries. Specifically, the parameters of the domain-adaptive feature extractor are kept unchanged (i.e., parameters are frozen), and a new classifier network is built upon it. The new classifier network typically consists of several fully connected layers, with the input dimension matching the output dimension of the feature extractor, and the output dimension equal to the number of water quality state categories. The classifier network parameters are initialized using Xavier or He initialization to ensure good gradient fluidity. Then, the reconstructed classifier network is trained under supervision using labeled samples (albeit in limited numbers) from the target domain-adapted dataset. During training, mini-batch gradient descent is used, employing an appropriate learning rate (typically smaller than when training the feature extractor) and regularization strength to prevent overfitting on the limited data. To further utilize unlabeled data in the target domain, semi-supervised learning techniques, such as pseudo-labeling, can be introduced. This involves using the current model to predict unlabeled data, selecting high-confidence predictions as pseudo-labels, and adding them to the training set for iterative training. This method effectively expands the training data and improves model performance. Furthermore, ensemble learning strategies can be applied to train multiple models with different initializations or hyperparameters. The prediction results can be merged through voting or weighted averaging to improve model stability and accuracy. Through the combined application of these techniques, a target domain adaptive early warning model is ultimately obtained. This model inherits the knowledge base of the source domain model while adapting to the specific data distribution of the target domain, enabling accurate early warning of water quality anomalies at the target wastewater treatment plant.

[0032] Finally, a comprehensive performance evaluation of the target domain adaptation early warning model was conducted using the test set in the target domain adaptation dataset. When the performance reached a predetermined threshold, the model was integrated into the online monitoring system. The performance evaluation employed a multi-dimensional indicator system, including traditional classification indicators such as accuracy, precision, recall, and F1 score, as well as water quality-specific indicators such as anomaly detection rate, early warning lead time, and false alarm rate. Tools such as confusion matrices and ROC curves were used to deeply analyze the model's detection capabilities and reliability across different types of anomalies. Only when key performance indicators reached predetermined thresholds (e.g., F1 score > 0.85, anomaly detection rate > 90%, false alarm rate < 5%) were the model considered to meet deployment requirements. Models meeting these standards were encapsulated into standardized software modules, including data preprocessing, feature extraction, and anomaly prediction functions, with clearly defined interface specifications. This software module was then integrated into the wastewater treatment plant's online monitoring system, configuring data access channels, early warning thresholds, and alarm methods to form a complete early warning system. A user-friendly, intuitive visualization interface was developed to display real-time water quality status, early warning results, and confidence levels. It also supports historical data review and trend analysis, providing decision support for operators. Furthermore, a continuous model update mechanism was established to regularly collect new data and feedback, employing incremental learning methods to update model parameters and ensure high performance over long-term operation. Through this systematic deployment and maintenance process, a complete closed loop from development to application of the water quality anomaly early warning model was achieved, providing strong support for the safe and stable operation of wastewater treatment plants.

[0033] The innovation of this method lies in its use of domain adaptation technology to address the data shortage problem in water quality early warning model construction. This enables newly built wastewater treatment plants to rapidly construct high-performance early warning models based on short-term data, significantly shortening the model development cycle and improving the safety and stability of water treatment projects. Key technologies in the method, such as quadratic integral firing neurons, adversarial domain adaptation, and feature selection based on uncertainty perception, represent cutting-edge research directions in the intersection of artificial intelligence and water treatment engineering, providing a new technological path for intelligent water quality monitoring.

[0034] In one embodiment, the step of associating and labeling the original water quality fingerprint data with the water quality anomaly event label data and then preprocessing it to obtain the source domain training dataset includes: Ultraviolet-visible spectrometers and near-infrared spectrometers were installed at the inlet, outlet, and effluent of the Yuanyu wastewater treatment plant. Water quality spectral data were collected at 15-minute intervals, and the sampling time and location were recorded to obtain the original water quality fingerprint data. Collect abnormal events such as toxic shocks, process fluctuations, and equipment failures from the historical operation records of the wastewater treatment plants in the source area, along with their corresponding occurrence times, and establish an event tag library to obtain the water quality abnormal event tag data; Align the original water quality fingerprint data with the water quality abnormal event label data according to the timestamp, determine the event status corresponding to each water quality fingerprint sample, and obtain a time-aligned labeled dataset; Baseline correction, scattering correction, and noise filtering are performed on the spectral data in the time-aligned labeled dataset to improve the signal-to-noise ratio. Spectral normalization is then performed to eliminate system differences between different batches of data to obtain standardized spectral data. Based on the standardized spectral data, a synthetic minority class oversampling technique is used to increase the number of anomalous event samples, thereby obtaining class-balanced training data. The class-balanced training data is divided into a training set, a validation set, and a test set according to time order to obtain the source domain training dataset.

[0035] Specifically, professional spectral monitoring equipment is first installed at key monitoring points in the source wastewater treatment plant. Specifically, ultraviolet-visible (UV-Vis) and near-infrared (NIIR) spectrometers are installed at the three key process nodes: the inlet, the biological treatment tank outlet, and the effluent outlet. These instruments can capture the absorption and scattering characteristics of water at different wavelengths, thus forming a "spectral fingerprint" of the water quality. They are set to automatically collect water quality spectral data every 15 minutes, simultaneously recording precise sampling timestamps and location information, which are crucial for subsequent data correlation. During the collection process, the UV-Vis spectrometer typically covers the 190-800 nm wavelength range, while the NIIR spectrometer covers the 800-2500 nm wavelength range. The combination of these two spectra can comprehensively reflect the integrated characteristics of organic matter, inorganic matter, and microorganisms in the water. Data from each sampling point is automatically uploaded to a central data server, forming the original water quality fingerprint database.

[0036] Next, historical records of abnormal events at the Yuanyu Wastewater Treatment Plant were collected. Staff systematically compiled various water quality anomalies that had occurred throughout history by reviewing the plant's operation logs, alarm records, and operator logs. These events mainly fell into three categories: toxic shocks (such as ammonia nitrogen and heavy metal contamination caused by sudden industrial wastewater discharge), process fluctuations (such as dissolved oxygen anomalies caused by aeration system malfunctions and sludge concentration fluctuations caused by reflux ratio imbalances), and equipment malfunctions (such as blower and pump station failures). For each type of abnormal event, detailed information such as the start and end times, scope of impact, and severity was recorded, establishing a structured event tag database, which constituted the water quality anomaly event tag dataset.

[0037] Next, data time alignment is performed. Since water quality fingerprint data and anomalous event labels come from different recording systems, they need to be precisely aligned according to timestamps. A time window matching algorithm is developed to associate each water quality fingerprint sample with the event state within a corresponding time window. If a water quality fingerprint sampling time falls within the time range of an anomalous event, the sample is labeled as the corresponding anomalous type; otherwise, it is labeled as normal. This step requires considering the impact delay and duration of anomalous events, and a reasonable time window setting is determined in collaboration with process experts. After alignment, a time-aligned labeled dataset is obtained, with each water quality fingerprint sample having a corresponding state label (normal or a specific anomalous type).

[0038] Preprocessing the acquired spectral data is a crucial step in improving the performance of subsequent models. First, baseline correction is performed to eliminate baseline shifts caused by instrument drift and environmental factors. A multi-point correction method is used, selecting multiple wavelengths in the spectrum known to have no absorption peaks as references. The baseline is calculated through polynomial fitting and subtracted from the original spectrum. Next, scattering correction is performed to reduce the scattering effect of suspended particulate matter in the water sample on the spectrum, primarily using multiplicative scattering correction (MSC) or standard normal variable (SNV) techniques. Then, the Savitzky-Golay smoothing filter algorithm is applied for noise removal, which effectively reduces random noise while preserving the characteristic peak shapes of the original spectrum. Finally, spectral normalization is performed to unify all spectral samples to the same scale range. Common methods include maximum value normalization, area normalization, or vector normalization. This step can eliminate system differences caused by changes in instrument status during different batch acquisitions. After this series of processing steps, standardized spectral data is obtained, with a significantly improved signal-to-noise ratio, making it more suitable for subsequent machine learning analysis.

[0039] Data imbalance is a common problem in machine learning tasks, especially in anomaly detection, where normal samples often far outnumber anomalous samples. To address this issue, this step uses Synthetic Minority Oversampling Technique (SMOTE) to increase the number of anomalous event samples based on standardized spectral data. The SMOTE algorithm generates new synthetic samples by interpolating between minority class samples in the feature space, rather than simply copying them. Specifically, for each minority class sample, a sample is randomly selected from its k nearest neighbors, and a point is randomly selected along the line segment connecting these two samples as the new synthetic sample. This method not only increases the number of minority class samples but also expands their distribution range in the feature space, improving the model's ability to learn anomalous patterns. By adjusting the oversampling ratio, a relative balance is achieved between the number of samples in each class, resulting in class-balanced training data.

[0040] Finally, the class-balanced training data is divided into training, validation, and test sets according to time sequence. Following the characteristics of time series data, a forward rolling partitioning method is used instead of random sampling. Specifically, the first 70% of the data is used as the training set for model parameter learning; the next 15% is used as the validation set for hyperparameter tuning and model selection; and the last 15% is used as the test set for final performance evaluation. This time-series partitioning method is more in line with real-world application scenarios, enabling the evaluation of the model's predictive ability at future time points and avoiding data leakage issues. After partitioning, a complete source domain training dataset is obtained, ready for subsequent model training.

[0041] like Figure 2 As shown, in one embodiment, the construction of a source domain early warning basic model including a feature extraction network and a classifier network, and the training of the source domain early warning basic model to obtain a trained source domain early warning basic model, includes: Step S21: Design a multi-layer convolutional neural network containing a combination of 3 to 5 convolutional layers and pooling layers as a feature extraction network to extract high-level feature representations from water fingerprint spectra, and obtain the feature extraction network structure. Step S22: Design a classifier network composed of fully connected layers. The classifier network receives the output of the feature extraction network structure and outputs the water quality state prediction result through the softmax activation function to obtain the source domain early warning basic model architecture. Step S23: Use the training set in the source domain training dataset to train the source domain early warning basic model architecture. Use the cross-entropy loss function and Adam optimizer, set the learning rate and batch size to perform the iterative training process, and obtain the initial training model. Step S24: Evaluate the performance of the initial training model using the validation set in the source domain training dataset, and adjust the learning rate, number of network layers, and regularization strength to obtain the model with optimized parameters; Step S25: Use the test set in the source domain training dataset to evaluate the model with optimized parameters, calculate accuracy, precision, recall and F1 score, and obtain the trained source domain early warning basic model.

[0042] Specifically, a multi-layer convolutional neural network is designed as the feature extraction network. The main purpose of this network is to extract discriminative high-level feature representations from water quality fingerprint spectral data. The architecture consists of a combination of 3 to 5 convolutional and pooling layers. Each convolutional layer uses kernels of different sizes (e.g., 3×1, 5×1, 7×1) to capture spectral feature patterns at different scales, particularly key information such as the shape, position, and intensity of absorption peaks. The first convolutional layer primarily identifies basic spectral features, such as absorption boundaries and peak positions; the second layer begins to combine these basic features to identify more complex patterns; the third and subsequent layers further abstract, capturing composite features related to specific water quality states. Each convolutional layer is followed by a batch normalization layer to accelerate training convergence and improve model stability, while also introducing nonlinearity using the ReLU activation function. After the convolutional layers, a max-pooling layer is added to reduce feature dimensionality, enhance the model's translation invariance, and reduce the risk of overfitting. Finally, a global average pooling layer transforms the feature map into a fixed-length feature vector, which will serve as the input to the subsequent classifier network. The design of the entire feature extraction network fully considers the characteristics of water quality spectral data, and has been particularly optimized for sensitivity to changes in spectral peak shape and peak position shift.

[0043] Next, a classifier network consisting of fully connected layers is designed. This classifier network receives the feature vector output by the feature extraction network, passes it through a series of fully connected layers and nonlinear transformations, and finally outputs the predicted water quality status. The specific structure includes 2 to 3 fully connected layers, with ReLU activation functions introduced between each layer to introduce nonlinearity, while Dropout technology (dropout rate of 0.3 to 0.5) is applied to prevent overfitting. The number of neurons in each fully connected layer decreases layer by layer, for example, it can be set to [256, 128, 64] to achieve layer-by-layer abstraction and dimensionality reduction of the features. The number of neurons in the last layer is equal to the number of predicted categories (usually including "normal" and various abnormal states), and a softmax activation function is used to convert the output into a probability distribution, facilitating the interpretation of the model's prediction confidence. The classifier network is designed to fully utilize the high-level features provided by the feature extraction network for accurate water quality status classification. Connecting the feature extraction network and the classifier network in series forms a complete source domain early warning basic model architecture, which can process water quality fingerprint data end-to-end and output prediction results.

[0044] Then, the source domain early warning basic model architecture was trained using the training set from the source domain training dataset. The training process employed supervised learning, with the labeled water quality state (normal / abnormal) as the objective. The cross-entropy loss function was chosen as the optimization objective, as it effectively measures the difference between the predicted probability distribution and the actual label distribution, making it particularly suitable for multi-class classification problems. For the optimizer, the Adam (Adaptive Moment Estimation) optimizer was selected, which combines the advantages of momentum and RMSProp, adaptively adjusting the learning rate for different parameters to accelerate the convergence process. The initial learning rate was set between 0.0001 and 0.001, adjusted according to model size and data complexity. The batch size was typically set between 32 and 128 to strike a balance between computational resources and training stability. An early stopping strategy was implemented during training, stopping training when performance on the validation set failed to improve for several consecutive epochs to prevent overfitting. Simultaneously, a learning rate decay strategy was implemented, reducing the learning rate when validation set performance stagnated to help the model escape local optima. After completing the iterative training, the initial training model is obtained. This model is already able to predict water quality anomalies on source domain data, but further optimization may be needed.

[0045] The performance of the initially trained model is evaluated using a validation set from the source domain training dataset, and model parameters and hyperparameters are adjusted based on the evaluation results. First, performance metrics such as accuracy, precision, recall, and F1 score are calculated using the validation set. These metrics identify model shortcomings; for example, low recall for a certain type of anomaly may indicate that the model is insensitive to that type of feature. Next, key hyperparameters are systematically tuned: the learning rate can be tested with multiple values ​​in the range of 0.00001 to 0.01; the number of network layers can be configured with different depths of 3 to 5; and the L1 and L2 regularization strengths can be adjusted from 0 to appropriate values ​​to control model complexity. Furthermore, different activation functions, pooling strategies, and attention mechanisms can be tried to enhance the model's expressive power. Methods such as grid search or Bayesian optimization are used to efficiently explore the hyperparameter space to find the optimal configuration. Through this series of tuning processes, a parameter-optimized model is obtained, which exhibits better warning performance on the validation set.

[0046] Finally, the optimized model was comprehensively evaluated using the test set from the source domain training dataset. The test set, completely independent of the training and validation processes, accurately reflects the model's generalization ability. Performance metrics were calculated on the test set, including overall accuracy, precision, recall, and F1 score for each anomaly type. Particular attention was paid to the model's performance in detecting significant water quality anomalies (such as toxic shocks) and its sensitivity to anomalies of varying severity. Simultaneously, the confusion matrix was analyzed to identify anomaly types that the model easily confuses, providing direction for future improvements. The model's performance at different decision thresholds was comprehensively evaluated using receiver operating characteristic (ROC) curves and precision-recall (PR) curves. After evaluation, if the model meets the predetermined performance requirements on the test set, it is confirmed as a successfully trained source domain early warning base model, which will be used in subsequent transfer learning processes.

[0047] In one embodiment, processing the short-term water quality fingerprint data according to a preprocessing procedure to obtain a target domain-adapted dataset includes: By deploying ultraviolet-visible spectrometers and near-infrared spectrometers of the same specifications as those used in the source wastewater treatment plant at key monitoring points in the target wastewater treatment plant, a target domain monitoring system is obtained. The target domain monitoring system collects water quality fingerprint data during the initial 1 to 3 months of operation, and records abnormal events and their corresponding tags to obtain a short-term dataset of the target domain. Using the same preprocessing procedure as the source domain training dataset, the spectral data in the target domain short-term dataset are processed through baseline correction, scattering correction, noise filtering, and normalization to obtain standardized target domain data. The standardized target domain data is divided into an adaptation training set and a test set to obtain the target domain adaptation dataset.

[0048] Specifically, a complete water quality fingerprint monitoring system is first deployed at the target wastewater treatment plant (i.e., the newly built wastewater treatment plant). To ensure data consistency and comparability, ultraviolet-visible spectrometers and near-infrared spectrometers of the exact same specifications and models as those at the source wastewater treatment plant must be installed at key monitoring points in the target wastewater treatment plant. These key monitoring points typically include the inlet, the outlet of the main biochemical reaction unit, and the final effluent. The installation location of the instruments must be rigorously evaluated to ensure that the sampling points represent the overall water flow characteristics while avoiding dead zones and the influence of local anomalies. During installation, the instrument parameters must be precisely calibrated, including wavelength calibration, intensity calibration, and dark current correction, to ensure that their measurement accuracy is consistent with that of the source equipment. All monitoring equipment is connected to a central server through a unified data acquisition system, forming a complete target-domain monitoring system. This system can not only automatically collect water quality fingerprint data but also monitor the instrument status in real time to ensure data quality.

[0049] Next, during the initial operational phase of the wastewater treatment plant in the target domain, a short-term water quality fingerprint data collection period of 1 to 3 months will be conducted. The data collection frequency will be consistent with the source domain, typically every 15 minutes, to ensure consistent temporal resolution. During the collection process, staff must closely monitor the operation of the wastewater treatment plant, meticulously recording all events that may affect water quality, such as fluctuations in influent water quality, adjustments to process parameters, equipment maintenance, or malfunctions. For any abnormal events, their start and end times, type, possible causes, and scope of impact will be recorded in detail, and a temporal correlation will be established with the spectral data. Although there are relatively few abnormal events at this stage, this limited labeled data is invaluable for subsequent model adaptation. Through this process, a complete short-term dataset of the target domain will be obtained, including continuous water quality fingerprint data and corresponding limited abnormal event labels.

[0050] Then, the collected short-term dataset of the target domain is preprocessed for standardization. To ensure consistency in processing methods, the same preprocessing procedure as the source domain training dataset must be strictly followed. First, baseline correction is performed to eliminate instrument drift and systematic errors; second, scattering correction is performed to reduce the scattering effect of suspended particles in the water sample on the spectrum; next, appropriate filtering algorithms are applied to remove noise and improve the signal-to-noise ratio; finally, spectral normalization is performed to ensure that spectral data collected at different time points are comparable. All parameter settings in the preprocessing process, including filter window size, normalization method, and threshold selection, must be consistent with the source domain processing. This consistency is crucial for ensuring the comparability of source and target domain data and lays the foundation for subsequent domain adaptation. After preprocessing, standardized target domain data is obtained, which has removed irrelevant variations introduced by instrument and environmental factors and retains true water quality characteristics.

[0051] Finally, the standardized target domain data is divided into adaptation training and test sets. Unlike the source domain data partitioning, due to the relatively limited amount of target domain data, a larger proportion is typically used for adaptation training. A typical partition ratio is 80% for the adaptation training set and 20% for the test set. The adaptation training set will be used for subsequent domain adaptation and classifier fine-tuning, while the test set is reserved for independent evaluation of the final model performance. The data partitioning still follows the chronological order principle to ensure that the test set represents the most recent data distribution. During the partitioning process, special attention is paid to ensuring that outlier samples (if any) are appropriately distributed in both subsets to avoid inconsistencies between training and test distributions. After partitioning, a complete target domain adaptation dataset is formed, including structured adaptation training and test sets, preparing for subsequent domain adaptation and model evaluation.

[0052] Through the detailed steps outlined above, a complete target domain adaptation dataset was established. Although the quantity of this data is limited, strict control over the collection and processing ensures comparability and consistency with the source domain data, providing a solid foundation for subsequent cross-domain knowledge transfer. This standardized processing flow is a key step in achieving rapid model building, enabling newly built wastewater treatment plants to obtain sufficient quality data for model adaptation in a short period, without having to wait for long-term data accumulation.

[0053] In one embodiment, the step of using the feature extraction network in the trained source domain early warning base model as a feature extractor, and using the feature extractor to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation; and reducing the difference between the source domain feature distribution representation and the target domain feature representation through a domain adaptation method to obtain a domain-adaptive feature extractor includes: Using the feature extraction network in the trained source domain early warning basic model as a feature extractor, the parameters of the bottom convolutional layer of the feature extractor are frozen to obtain the decoupled feature extractor. The decoupled feature extractor is used to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature representation and the target domain feature representation. The mean, variance and covariance matrix are calculated for the source domain feature representation and the target domain feature representation respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation. Based on the decoupled feature extractor, a label predictor for predicting sample labels and a domain classifier for determining the domain to which a sample belongs are added to obtain the domain adversarial network architecture. The domain adversarial network architecture is adversarially trained using the source domain training dataset and the target domain adaptation dataset. The feature extractor is then adversarially trained by using a gradient inversion layer to simultaneously minimize the classification error of the label predictor and maximize the discrimination error of the domain classifier. Based on the features extracted by the adversarial-trained feature extractor, the maximum average difference between the source domain feature distribution representation and the target domain feature distribution representation is calculated in the feature space. The adversarial-trained feature extractor is further fine-tuned by minimizing the maximum average difference to obtain a feature extractor with aligned feature distributions. Source domain validation data is extracted from the validation set of the source domain training dataset, and target domain validation data is extracted from the test set of the target domain adaptation dataset. The source domain validation data and the target domain validation data are processed respectively using the feature extractor aligned with the feature distribution. The alignment effect of the feature distribution is verified by t-SNE visualization and maximum mean difference metric to obtain the domain-adaptive feature extractor.

[0054] Specifically, the trained source domain early warning basic model is first decoupled. Decoupling refers to the process of decomposing the original end-to-end neural network model into two independent functional modules: feature extraction and classification / decision. Specifically, the feature extraction network (usually containing all convolutional and pooling layers) is extracted from the source domain early warning basic model and used as an independent feature extractor. In this process, parameter freezing is employed, i.e., fixing the weight parameters of the bottom convolutional layers (usually the first 1-2 layers) in the feature extractor, ensuring they remain unchanged during subsequent training. The theoretical basis for this is that the bottom convolutional layers of a neural network typically extract general low-level features (such as edges and textures), which have good transferability between different domains, while the higher convolutional layers extract more specific high-level semantic features, requiring adjustments for new domains. By retaining only the trainability of the higher convolutional layers, the basic feature representation ability captured by the pre-trained model is preserved, while providing flexibility for domain adaptation. After this step, the decoupled feature extractor is obtained, which retains the source domain model's ability to extract basic water quality fingerprint features while possessing the potential to adapt to the target domain data distribution.

[0055] Next, the decoupled feature extractors are used to process the source domain training dataset and the target domain adaptation dataset separately to obtain feature representations for the two domains. Specifically, each sample is input into the feature extractor, and the output of the last convolutional (or pooling) layer of the network is used as the feature representation for that sample. These feature representations are typically high-dimensional vectors containing abstract feature information from the water fingerprint data. Then, statistics are calculated to characterize the distribution characteristics of the feature representation sets for both the source and target domains. First, the mean vector of each domain feature is calculated, reflecting the central tendency of the features; second, the variance vector is calculated, describing the dispersion of the features; finally, the covariance matrix is ​​calculated, characterizing the correlation between features of different dimensions. These statistics together constitute the source domain feature distribution representation and the target domain feature distribution representation, which comprehensively describe the statistical characteristics of the feature spaces of the two domains, providing a mathematical foundation for subsequent evaluation of inter-domain differences and implementation of domain adaptation. By visualizing these distribution representations (e.g., using t-SNE dimensionality reduction), the distribution differences between the source and target domains in the feature space can be intuitively observed; these differences are precisely the reasons for the performance degradation of the direct transfer model.

[0056] Then, based on the decoupled feature extractor, a complete Domain Adversarial Network (DAN) architecture is constructed. A DAN is a neural network architecture specifically designed for domain adaptation. Its core idea is to reduce the difference in feature distribution between the source and target domains through adversarial learning mechanisms. The specific structure includes three main components: a feature extractor (i.e., the decoupled feature extractor obtained earlier), a label predictor, and a domain classifier. The label predictor is a fully connected network that receives the output of the feature extractor and predicts the category label of the sample (e.g., normal or abnormal water quality). The domain classifier is also a fully connected network, but its task is to predict which domain (source or target domain) the features originate from. These two classifiers are connected to the same feature extractor but have opposite optimization objectives. The unique feature of the DAN lies in the introduction of a gradient inversion layer, located between the feature extractor and the domain classifier. This layer inverts the gradient during backpropagation, causing the optimization direction of the feature extractor to be opposite to that of the domain classifier. This architectural design enables the system to learn domain-invariant feature representations, which is key to achieving effective domain adaptation.

[0057] Next, the domain adversarial network architecture is trained adversarially using the source domain training dataset and the target domain adaptation dataset. Adversarial training is a multi-objective optimization process where the feature extractor faces two competing objectives: on the one hand, it needs to minimize the classification error of the label predictor on the source domain data, ensuring that the extracted features have good discriminative ability for judging water quality status; on the other hand, due to the gradient reversal layer, it also needs to maximize the discriminative error of the domain classifier, making the extracted features as similar as possible between the source and target domains, making it difficult for the domain classifier to distinguish the source of the features. These two objectives are integrated through a joint loss function, typically expressed as a weighted sum of classification loss and domain discriminative loss. The training process uses mini-batch gradient descent, with each batch containing samples from both the source and target domains. Initially, the classification task is typically given a larger weight; as training progresses, the weight of the domain adaptation task is gradually increased. This strategy helps to ensure a smooth transition and avoid training instability. Through multiple rounds of iterative training, the feature extractor learns to extract feature representations that are both discriminative and domain-invariant, resulting in the adversarially trained feature extractor.

[0058] Then, the feature extraction algorithm trained adversarially is used to further optimize feature distribution alignment. While adversarial training can make feature distributions more consistent, it may not completely eliminate inter-domain discrepancies. To further optimize, the Maximum Mean Discrepancy (MMD) metric is introduced. This metric measures the difference between two distributions by calculating the mean distance between the two distributions in the Hilbert space of the reproducing kernel. In practice, the adversarially trained feature extraction algorithm is first used to process the source and target domain data separately to obtain feature representations for both domains. Then, the MMD values ​​of these two sets of features are calculated. Finally, the MMD values ​​are used as a loss function, and the feature extraction algorithm parameters are fine-tuned through backpropagation to minimize the output feature distribution MMD value. This process is equivalent to explicit distribution alignment in the feature space, complementing the previous adversarial training to form a stronger domain adaptability. Through multiple rounds of MMD minimization training, a feature extraction algorithm with aligned feature distributions is obtained. This algorithm can map data from different domains to closer regions in the feature space, laying the foundation for accurate prediction in the target domain.

[0059] Finally, the effectiveness of feature distribution alignment is evaluated and verified. A subset of samples is extracted from the validation set of the source domain training dataset as source domain validation data, and a subset of samples is extracted from the test set of the target domain adaptation dataset as target domain validation data. The feature extractor with aligned feature distributions processes these two sets of validation data to obtain their representations in the feature space. Then, the alignment effect is evaluated in two ways: first, t-SNE (t-distributed random neighborhood embedding) technology is used to reduce the high-dimensional features to 2D or 3D space for visualization, allowing for a direct observation of the overlap in the distribution of samples from the source and target domains in the feature space; second, the MMD value of the validation data is calculated to verify whether the alignment significantly reduces the distribution difference compared to before alignment. If the visualization results show significant overlap in the feature distributions of the two domains, and the MMD value is significantly lower than before alignment, then the feature alignment is confirmed to be effective. This yields the final domain-adaptive feature extractor, which can extract domain-invariant features from water quality fingerprint data, laying the foundation for building an accurate early warning model in the target domain.

[0060] In one embodiment, the step of using the decoupled feature extractor to process the source domain training dataset and the target domain adaptation dataset respectively to obtain source domain feature representations and target domain feature representations, and calculating the mean, variance, and covariance matrices of the source domain feature representations and target domain feature representations respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation, includes: A Monte Carlo dropout layer is added to the decoupled feature extractor so that the decoupled feature extractor can output the prediction result and its uncertainty estimate, thus obtaining the uncertainty quantification model; The uncertainty quantification model is used to process the source domain training dataset and the target domain adaptation dataset respectively, and the source domain feature representation and the target domain feature representation are extracted. For each feature of the source domain feature representation and the target domain feature representation, the coefficient of variation of its contribution to the prediction result is calculated through 10 to 20 Monte Carlo samplings to obtain the feature contribution uncertainty. The backpropagation algorithm is used to calculate the absolute gradient of each feature dimension in the source domain feature representation and the target domain feature representation with respect to the classification loss function. The absolute gradient value is then normalized and used as the feature importance score. The feature importance score is combined with the feature contribution uncertainty to obtain the feature importance-uncertainty matrix; Based on the feature importance-uncertainty matrix, features with feature importance scores greater than a preset importance threshold and feature contribution uncertainty less than a preset uncertainty threshold are sorted to obtain the key feature sorting results; Based on the ranking results of the key features, the weights of different feature channels in the uncertainty quantification model are dynamically adjusted to obtain an uncertainty-aware feature selection strategy. Based on the uncertainty-aware feature selection strategy, the uncertainty quantification model is used to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation.

[0061] Specifically, an uncertainty quantification mechanism is first introduced into the decoupled feature extractor. This is achieved by adding Monte Carlo dropout layers to the key layers (typically high-level convolutional or fully connected layers) of the feature extractor. Monte Carlo dropout is a technique for uncertainty estimation in neural networks. Its principle is to keep dropout active during the inference phase (which is usually disabled during inference), randomly dropping different neurons during each forward propagation. Running the same input multiple times yields different prediction results, and the statistical distribution of these results reflects the model's prediction uncertainty for that input. In this embodiment, the dropout rate is set between 0.2 and 0.5, and dropout layers are added after each target layer of the feature extractor, ensuring that these dropout layers remain active during the inference phase. This modification makes the feature extractor a Bayesian approximation model capable of estimating prediction uncertainty. After the modification, an uncertainty quantification model is obtained. This model can not only extract feature representations of water fingerprints but also quantify the uncertainty of these feature representations, providing richer information for subsequent feature selection and domain adaptation.

[0062] Next, an uncertainty quantification model is used to process the source domain training dataset and the target domain adaptation dataset separately, extracting feature representations from both domains and evaluating uncertainty. Specifically, for each sample, the uncertainty quantification model is used for 10 to 20 forward propagations (each propagation produces slightly different results due to the randomness of dropout), obtaining a series of feature vectors. Then, for each dimension of these feature vectors, the contribution coefficient of variation is calculated. The contribution coefficient of variation is a statistic used to measure the stability of the influence of a specific feature dimension on the final prediction result. It is calculated by dividing the standard deviation of the feature dimension in multiple forward propagations by the mean, and then multiplying by the contribution weight of that feature dimension to the final prediction (obtained through sensitivity analysis). The higher the coefficient of variation, the more unstable the contribution of that feature dimension to the prediction, and the greater its uncertainty. In this way, the uncertainty estimate of each feature dimension is obtained, i.e., the feature contribution uncertainty, which quantifies the reliability of the model's judgment on the importance of each feature, providing a new dimension for subsequent feature selection.

[0063] Then, the importance of each feature dimension is evaluated using the backpropagation algorithm. Specifically, for each sample, the gradient of the loss function with respect to each dimension of the feature representation is calculated. The magnitude of the absolute value of the gradient reflects the degree of influence of that dimension's feature on the prediction result—a larger gradient indicates that a small change in that dimension leads to a significant change in the prediction result, suggesting that the feature is important for prediction. To make the importance scores comparable between different samples and different feature dimensions, the absolute values ​​of the gradients need to be normalized, typically using max-min normalization or Z-score standardization. The normalized absolute value of the gradient serves as the feature importance score, evaluating the importance of each feature dimension from the perspective of prediction sensitivity. This gradient-based feature importance evaluation method, compared to traditional statistical correlation analysis, can more directly reflect the impact of features on model decisions, making it particularly suitable for interpretive analysis of deep learning models.

[0064] Next, the feature importance score is combined with the uncertainty of feature contribution to construct a two-dimensional evaluation matrix. Each row of this matrix corresponds to a feature dimension and contains two key indicators: importance score and uncertainty estimate. This two-dimensional evaluation framework allows features to be evaluated from two orthogonal dimensions: considering both the importance of the feature to the prediction and the reliability of this importance judgment. Based on this matrix, features can be divided into four categories: high importance and low uncertainty (the most valuable features), high importance and high uncertainty (features that need to be used with caution), low importance and low uncertainty (features that may be safely ignored), and low importance and high uncertainty (features that should be ignored the most). The feature importance-uncertainty matrix is ​​one of the innovations of this invention; it introduces an uncertainty dimension for the first time in the field of feature selection, providing a new approach for more robust feature selection.

[0065] Based on the feature importance-uncertainty matrix, feature selection and ranking are performed. First, two thresholds are set: the importance threshold is typically set to the 75th to 85th percentile of the feature importance score distribution; the uncertainty threshold is typically set to the 15th to 25th percentile of the feature uncertainty distribution. Then, feature dimensions that satisfy the condition of "importance score greater than the importance threshold and uncertainty less than the uncertainty threshold" are selected. These features are both important for prediction and have high judgment reliability. Next, these features are sorted in descending order of importance score to obtain the key feature ranking results. This feature selection method based on dual thresholds, compared to traditional methods that only consider importance, can filter out features that seem important but are unreliable, improving the robustness of feature selection. It is particularly suitable for feature selection in domain adaptation scenarios because, in domain transfer, some features that seem important in the source domain may become ineffective in the target domain, exhibiting high uncertainty.

[0066] Based on the ranking of key features, the weights of different feature channels in the uncertainty quantification model are dynamically adjusted. Specifically, a feature weighting layer is added after the last convolutional layer of the feature extractor. This layer applies different weight coefficients to each feature channel. The weight coefficients are allocated according to the following strategy: higher weights (e.g., 1.2 to 1.5) are assigned to top-ranked key features; for dimensions not selected as key features, appropriately reduced weights (e.g., 0.5 to 0.8) or very low weights (e.g., 0.1 to 0.3) are assigned based on the combination of their importance and uncertainty. This dynamic weight adjustment mechanism based on feature importance and uncertainty enables the model to strengthen reliable key features and suppress unreliable or unimportant features during forward propagation, forming an uncertainty-aware feature selection strategy. This strategy makes the feature extraction process more intelligent and adaptive, particularly suitable for handling feature shift problems in cross-domain data.

[0067] Finally, based on an uncertainty-aware feature selection strategy, the source domain training dataset and the target domain adaptation dataset are reprocessed using an adjusted uncertainty quantification model. In this processing, the model selectively strengthens key features and suppresses unimportant or highly uncertain features according to the previously determined feature weights. After processing, statistics—mean vector, variance vector, and covariance matrix—are calculated on the extracted feature representations to obtain the source domain feature distribution representation and the target domain feature distribution representation, respectively. These distribution representations are more focused on feature dimensions that are important for prediction and reliable in judgment, reducing the interference of irrelevant or unreliable features. Through this uncertainty-aware feature selection strategy, a more refined and reliable feature distribution representation is obtained, providing a better foundation for subsequent domain adaptation and improving the efficiency and effectiveness of the domain adaptation process.

[0068] In one embodiment, the reconstructed classifier network based on the domain-adaptive feature extractor, and the training of the reconstructed classifier network using the target domain-adaptive dataset to obtain a target domain-adaptive early warning model, includes: Based on the domain-adaptive feature extractor, the classifier network is reconstructed while keeping the parameters of the domain-adaptive feature extractor unchanged. Only the parameters of the classifier network are initialized to obtain the reconstructed model architecture. The classifier network in the reconstructed model architecture is trained under supervision using the adaptation training set in the target domain adaptation dataset with a learning rate of 0.0001 to 0.001 to obtain the model parameters for preliminary fine-tuning. A progressive learning rate decay strategy is implemented on the reconstructed model architecture, reducing the learning rate to 0.5 to 0.8 times the original learning rate after each preset number of training rounds, thereby obtaining an optimized training process; During the optimized training process, L1 regularization coefficients, L2 regularization coefficients, and Dropout ratios are introduced into the classifier network of the reconstructed model architecture to prevent the reconstructed model architecture from overfitting on the target domain adaptation dataset, thus obtaining a classifier network with regularization constraint parameters. The domain-adaptive feature extractor is combined with the classifier network with regularization constraint parameters to obtain a target domain model with regularization constraint parameters. The target domain model with regularization constraint parameters is used to predict the unlabeled data in the target domain adaptation dataset. The prediction results with a prediction confidence greater than 0.9 are selected as pseudo-labels to expand the adaptation training set for semi-supervised learning, and the pseudo-label-enhanced model is obtained. The Bagging ensemble method is used to train the reconstructed model architecture with 5 to 10 different initialization parameters and different learning rates and regularization coefficients. The prediction results of the 5 to 10 trained models are then integrated by weighted averaging to obtain the target domain adaptive early warning model.

[0069] Specifically, firstly, based on a domain-adaptive feature extractor, the complete water quality anomaly early warning model architecture is reconstructed. In this step, all parameters of the domain-adaptive feature extractor obtained in Example 5 are kept unchanged, i.e., the feature extraction part is completely frozen. The purpose of doing so is to preserve the domain-invariant feature representation ability already learned by the feature extractor and avoid destroying this ability during subsequent training. Then, the classifier network is redesigned and initialized on top of the feature extractor. The new classifier network typically consists of 2 to 3 fully connected layers, with non-linear activation functions such as ReLU or LeakyReLU used between each layer. The input dimension of the first layer of the classifier network matches the output dimension of the feature extractor, and the output dimension of the last layer is equal to the number of water quality state categories (usually including "normal" and various abnormal states). All parameters of the classifier network are initialized using a carefully designed strategy, such as Xavier or He initialization, to ensure that the gradient remains within an appropriate range during forward and backward propagation. This "freeze feature extractor + reconstruct classifier" strategy allows the model to fully utilize the domain-adaptive feature representation while optimizing for the specific classification task of the target domain. It is a commonly used "feature extractor transfer + classifier fine-tuning" paradigm in transfer learning.

[0070] Next, the reconstructed classifier network is trained under supervision using the adaptation training set from the target domain adaptation dataset. Since the feature extractor parameters are frozen, the training process only updates the parameters of the classifier network. Supervised learning is employed, using labeled samples from the target domain (though limited in number, they are invaluable). The loss function is chosen to suit the water quality anomaly detection task, typically cross-entropy loss or weighted cross-entropy loss, the latter handling potential class imbalance in the target domain data. The optimizer is Adam, with an initial learning rate set between 0.0001 and 0.001. A smaller learning rate contributes to the stability of the fine-tuning process and prevents overfitting to the limited target domain data. Mini-batch gradient descent is used during training, with the batch size flexibly set according to the size of the target domain adaptation dataset, typically between 8 and 32. Training continues for multiple epochs until the validation performance no longer shows significant improvement, thus obtaining the initially fine-tuned model parameters. The key at this stage is to fully utilize the limited target domain labeled data, enabling the classifier to adapt to the specific decision boundaries of the target domain.

[0071] Then, a progressive learning rate decay strategy is implemented during the training process to optimize the model convergence. The learning rate is a key hyperparameter affecting the training performance of neural networks. A progressive decay strategy helps the model quickly approach the optimal solution region in the early stages of training, while later it explores the space near the optimal solution more meticulously. Specifically, a threshold for the number of training epochs is pre-set (e.g., every 10 or 20 epochs). When the training reaches this threshold, the current learning rate is multiplied by a decay coefficient (usually between 0.5 and 0.8) to obtain a new, reduced learning rate. This strategy slows down the learning process in a stepwise manner, which is more conducive to finding robust local optima than a one-time large reduction in the learning rate or linear decay. The number and magnitude of the learning rate decay need to be dynamically adjusted according to the model's training curve: if the validation loss decreases slowly, the decay magnitude can be increased; if the validation loss fluctuates greatly, the decay frequency can be increased. Through this dynamic learning rate adjustment strategy, the model's training process is optimized, enabling it to achieve better performance on limited target domain data.

[0072] During optimized training, regularization techniques are also needed to prevent the model from overfitting on limited data in the target domain. Specifically, three complementary regularization methods are employed: L1 regularization, L2 regularization, and Dropout. L1 regularization (also known as Lasso regularization) adds a penalty term to the loss function based on the sum of the absolute values ​​of the parameters, encouraging the model to learn sparse parameters; the coefficient is typically set between 0.0001 and 0.001. L2 regularization (also known as weight decay) adds a penalty term based on the sum of squared parameters, controlling parameter size and preventing excessively large weights; the coefficient is typically set between 0.001 and 0.01. Dropout randomly discards a portion of neurons during training, preventing the network from over-relying on any specific feature combination; the discard ratio is typically set between 0.3 and 0.5. The combined use of these three techniques can suppress overfitting from different perspectives, enabling the model to have better generalization ability on limited data in the target domain. Training with regularization constraints results in a classifier network with regularized constraint parameters, which exhibits better robustness and generalization ability.

[0073] Next, the domain-adaptive feature extractor is combined with a classifier network having regularization constraints to form a complete target domain adaptation model. This combined model consists of two main parts: the front end is a domain-adaptive feature extractor capable of extracting water quality features shared by the source and target domains; the back end is a target domain-optimized classifier capable of making accurate water quality status judgments based on these features. During the combination process, it is necessary to ensure interface matching between the two parts, i.e., the output dimension of the feature extractor is consistent with the input dimension of the classifier. After combination, an end-to-end forward propagation test is performed on the entire model to verify smooth data flow and normal prediction function. Thus, a target domain model with regularization constraints is obtained, which combines the domain-adaptive feature extraction capability with the target domain-optimized classification capability.

[0074] To further utilize unlabeled data in the target domain, a semi-supervised learning strategy is employed to augment the training set. Specifically, a target domain model with regularization constraints is used to predict unlabeled data in the target domain adaptation dataset, and a confidence score (typically the maximum value of the softmax output) is calculated for each prediction. Then, samples with a prediction confidence score greater than 0.9 are selected, and the model's predicted class is used as the "pseudo-label" for these samples. These high-confidence pseudo-label samples are added to the original adaptation training set, expanding the training data volume. Next, the classifier network is retrained using the augmented training set. This process can be iterated multiple times, each time selecting samples predicted with high confidence by the current model and adding them to the training set. Pseudo-labeling is a classic method in semi-supervised learning, particularly suitable for scenarios where data labeling is costly. This approach fully utilizes unlabeled data in the target domain, resulting in a pseudo-label-enhanced model that significantly improves the model's performance in the target domain.

[0075] Finally, to further improve the robustness and accuracy of the model, an ensemble learning strategy is adopted. Bagging (Bootstrap aggregating) is a commonly used ensemble method that trains multiple models with different random initializations or different hyperparameters, and then merges their predictions to reduce the variance and overfitting risk of individual models. In this embodiment, based on the reconstructed model architecture, 5 to 10 different initialization parameters (such as different random seeds) and different hyperparameter configurations (such as different learning rates, regularization coefficients, etc.) are used for training. Each configuration generates an independent model with slightly different decision characteristics. Then, the prediction results of these models are weighted and averaged, with the weights determined based on the performance of each model on the validation set, and the model with better performance receiving a larger weight. Through this model ensemble, the decision boundaries of individual models can be smoothed, the influence of outliers can be reduced, and the stability and accuracy of predictions can be improved. Thus, the final target domain adaptive early warning model is obtained, which has a strong ability to detect water quality anomalies and can operate reliably in the actual environment of a newly built sewage treatment plant.

[0076] In one embodiment, the progressive learning rate decay strategy applied to the reconstructed model architecture, reducing the learning rate to 0.5 to 0.8 times the original learning rate after a preset number of training epochs, to obtain an optimized training process, includes: A multi-objective optimization function is defined, which includes prediction accuracy, minimization of domain differences, and control of model complexity, thus obtaining a multi-objective evaluation system; Based on the labeled data in the target domain adaptation dataset and the multi-objective evaluation system, a Pareto optimal solution set for learning rate and regularization strength is constructed to obtain the Pareto front. Calculate the prediction uncertainty under each set of hyperparameter configurations on the Pareto front, and perform a double sorting based on the position on the Pareto front to obtain the double sorting result; Based on the double ranking results, an uncertainty threshold is set. When the prediction uncertainty of the reconstructed model architecture on the validation set is greater than the uncertainty threshold, it is defined as a high uncertainty stage. When the prediction uncertainty of the reconstructed model architecture on the validation set is less than or equal to the uncertainty threshold, it is defined as a low uncertainty stage. In the high uncertainty phase, the learning rate is kept in the range of 0.0005 to 0.001 to enhance exploratory behavior, and in the low uncertainty phase, the learning rate is reduced to the range of 0.0001 to 0.0005 to accelerate convergence, thus obtaining an adaptive parameter scheduling scheme. The reconstructed model architecture is trained based on the adaptive parameter scheduling scheme. Each training epoch lasts for 10 to 20 training epochs and is considered a training cycle. At the end of each training cycle, the accuracy and prediction uncertainty of the reconstructed model architecture on the validation set are evaluated. Based on the accuracy improvement and prediction uncertainty reduction of the current training cycle compared to the previous training cycle, the learning rate decay strategy for subsequent training is automatically adjusted to obtain the optimized training process.

[0077] Specifically, firstly, a multi-objective optimization function is defined as a comprehensive evaluation system for model training. Traditional model training typically focuses on a single objective (such as classification accuracy), while in domain adaptation scenarios, multiple competing objectives need to be considered simultaneously. The multi-objective optimization function in this embodiment comprises three core components: prediction accuracy, domain variance minimization, and model complexity control. Prediction accuracy is measured by cross-entropy loss or F1 score, reflecting the model's classification performance on labeled data in the target domain. Domain variance minimization is quantified by maximum mean variance (MMD) or Wasserstein distance of feature distributions, assessing the similarity between the feature distributions of the source and target domains. Model complexity control is characterized by the L1 / L2 norm or the number of effective parameters, preventing overfitting due to excessive model complexity. These three objectives often have an inverse relationship; for example, overemphasizing domain variance minimization may compromise prediction accuracy. The multi-objective optimization function combines these three objectives through weighted summation or hierarchical optimization. The weights can be adjusted according to specific application scenarios, forming a comprehensive evaluation system that guides the optimization direction of the model, achieving a balance between predictive ability, transferability, and generalization ability.

[0078] Next, based on the labeled data in the target domain adaptation dataset and the multi-objective evaluation system, a Pareto optimal solution set for the learning rate and regularization strength is constructed. Pareto optimality is a core concept in multi-objective optimization, referring to the set of solutions that cannot simultaneously improve all objectives without compromising any one objective by adjusting the decision variables. In this embodiment, the decision variables are the learning rate and regularization strength (including L1 and L2 coefficients and the Dropout ratio), with values ​​ranging from learning rate (0.00001-0.01), L1 coefficient (0-0.01), L2 coefficient (0-0.1), and Dropout ratio (0.1-0.6), respectively. The construction process employs grid search or Bayesian optimization methods to systematically explore the hyperparameter space, train the model for each set of hyperparameter configurations, and evaluate the three objective function values. Then, the Pareto comparison algorithm is applied to identify non-dominated solutions (i.e., solutions that are not simultaneously superior to any other solution on all objectives), and these non-dominated solutions constitute the Pareto front. In practice, a Pareto front with 10-20 configuration points may be generated, with each point representing a hyperparameter combination that performs well on certain objectives. The Pareto front provides a set of candidate solutions to balance the objectives for subsequent hyperparameter selection, avoiding the limitations of choosing a single metric.

[0079] Then, the prediction uncertainty of each hyperparameter configuration on the Pareto front is evaluated, and a dual ranking is performed based on its position on the Pareto front. Prediction uncertainty refers to the model's confidence in its own predictions, which can be quantified using methods such as Monte Carlo Dropout, deep ensembles, or Bayesian neural networks. Specifically, for each hyperparameter configuration on the Pareto front, a corresponding model is constructed, and multiple predictions are made on the validation set samples (e.g., 20 predictions using Monte Carlo Dropout). The mean and standard deviation of the predicted class probabilities are calculated, and the average of the standard deviations is used as a measure of the prediction uncertainty of that configuration. The dual ranking process considers two dimensions simultaneously: first, a first-level ranking is performed based on the "dominance strength" of the configuration on the Pareto front (i.e., how many other configurations it dominates); then, within configurations with the same dominance strength, a second-level ranking is performed based on prediction uncertainty from low to high. This dual ranking mechanism considers both the balance of multi-objective performance and a preference for configurations with more certain predictions (i.e., more stable predictions), resulting in a ranking that comprehensively considers performance and stability, laying the foundation for adaptive hyperparameter selection.

[0080] Based on the double ranking results, a standard for dividing the uncertainty stages of model training is established. First, the average uncertainty of predictions for all samples on the validation set is calculated, and an uncertainty threshold is typically set to 1.2-1.5 times this average. Then, based on the comparison between the model's performance on the current validation set and this threshold, the training process is divided into two stages: when the prediction uncertainty is greater than the threshold, it is defined as a high uncertainty stage, indicating that the model's understanding of the current data distribution is insufficient or the feature mapping is unstable; when the prediction uncertainty is less than or equal to the threshold, it is defined as a low uncertainty stage, indicating that the model has formed a relatively stable decision boundary. This uncertainty-based stage division is one of the innovations of this embodiment. It allows the training strategy to be dynamically adjusted according to the model's learning state, rather than simply executing according to a preset schedule, which is more in line with the non-linear characteristics of the actual learning process.

[0081] After defining the uncertainty stages, an adaptive parameter scheduling scheme is designed. For the high uncertainty stage, a relatively high learning rate (0.0005 to 0.001) is maintained to enhance the model's exploratory ability, enabling it to quickly explore the parameter space and find potential optimization directions. In this stage, a higher learning rate allows for significant parameter adjustments, helping to escape local optima, but may also lead to training instability. Therefore, the batch size is appropriately increased in the high uncertainty stage (e.g., from 16 to 32 or 64) to reduce the variance of gradient estimation and improve training stability. For the low uncertainty stage, the learning rate is reduced to the range of 0.0001 to 0.0005 to finely explore the region near the optimal solution, accelerating model convergence. At this point, a lower learning rate allows for more cautious parameter adjustments, facilitating fine-tuning within the found promising regions. Simultaneously, in the low uncertainty stage, the regularization strength can be gradually increased to prevent the model from overfitting the labeled target domain data. This scheme, which dynamically adjusts learning parameters according to the uncertainty stage, makes the training process more intelligent and adaptive, automatically adjusting the optimization strategy based on changes in the model's learning state.

[0082] Finally, the reconstructed model architecture is trained using an adaptive parameter scheduling scheme, and a dynamic learning rate adjustment strategy is implemented. The training process is divided into multiple training epochs, each containing 10 to 20 epochs. At the end of each training epoch, two key metrics of the model on the validation set are systematically evaluated: prediction accuracy and prediction uncertainty. Then, the improvement in accuracy and the decrease in uncertainty in the current epoch relative to the previous epoch are calculated. These two metrics together reflect the degree and direction of model improvement. Based on these changes, the learning rate decay strategy for subsequent training is automatically adjusted: if the accuracy improves significantly but the uncertainty decreases only slightly, it may indicate that the model is learning effectively but has not yet reached a stable state, in which case the current learning rate can be maintained; if the accuracy improves only slightly but the uncertainty decreases significantly, it may indicate that the model is forming a stable decision boundary, in which case the learning rate can be appropriately reduced for fine-tuning; if neither metric shows significant improvement, it may indicate that the model is close to convergence, in which case the learning rate can be significantly reduced or an early stopping mechanism can be initiated. This dynamic learning rate adjustment strategy based on performance change trends is more flexible than a preset fixed decay plan. It can adapt to the characteristics of different datasets and model architectures, improve training efficiency, and obtain better model performance, ultimately resulting in an optimized training process.

[0083] In one embodiment, the step of using the target domain model with regularization constraint parameters to predict unlabeled data in the target domain adaptation dataset, selecting prediction results with a prediction confidence greater than 0.9 as pseudo-labels to expand the adaptation training set for semi-supervised learning, and obtaining a pseudo-label-enhanced model includes: For each sample of unlabeled data in the target domain adaptation dataset that fits the training set, the target domain model with regularization constraint parameters is used to perform 10 to 30 Monte Carlo predictions. The mean of the predicted class probability for each sample is calculated as the prediction confidence, and the standard deviation of the predicted class probability is calculated as the prediction uncertainty, so as to obtain the sample prediction evaluation result. The prediction confidence and prediction uncertainty in the sample prediction evaluation results are constructed into a two-dimensional evaluation space. Pareto ranking is used to identify samples located on the Pareto front to obtain a candidate sample set. Based on the accuracy of the target domain model with regularization constraint parameters on the validation set, the confidence threshold is set to 0.95 to 1.05 times the accuracy, and the uncertainty threshold is set to 0.8 to 1.2 times the median of the prediction uncertainty of all samples in the sample prediction evaluation results, thus obtaining the dynamic confidence threshold and the dynamic uncertainty threshold. Calculate the gradient norm of each sample in the candidate sample set with respect to the classifier network parameters in the target domain model with regularization constraint parameters, normalize the gradient norm and use it as the gradient contribution score, and sort the samples in the candidate sample set according to the gradient contribution score to obtain the gradient contribution ranking result. Based on the gradient contribution ranking results, samples with prediction confidence greater than the dynamic confidence threshold and prediction uncertainty less than the dynamic uncertainty threshold are selected. The predicted category of the sample is added as a pseudo-label to the adaptation training set for training to obtain the pseudo-label-enhanced model.

[0084] Specifically, firstly, a comprehensive assessment of the prediction uncertainty is performed on the unlabeled data in the target domain adaptation dataset. Traditional pseudo-labeling methods rely solely on the confidence level of a single prediction, making them susceptible to model overconfidence. To improve the reliability of pseudo-labels, this embodiment employs a Monte Carlo prediction method to perform multiple predictions for each unlabeled sample. Specifically, 10 to 30 forward propagations are performed for each sample, with the Dropout layer in the model remaining active during each forward propagation and undergoing random deactivation, resulting in multiple slightly different predictions. Based on these predictions, two key statistics are calculated: the mean of the predicted class probability and the standard deviation of the predicted class probability. The mean of the predicted class probability serves as the prediction confidence level of the sample, reflecting the average degree of confidence the model has in judging the sample's class; the standard deviation of the predicted class probability serves as the prediction uncertainty, reflecting the stability and consistency of the model's judgment. Higher confidence and lower uncertainty together indicate that the model's prediction for that sample is more likely to be reliable. This uncertainty estimation method based on multiple sampling originates from Bayesian inference theory, enabling a more comprehensive assessment of prediction reliability and avoiding the bias that may arise from a single prediction. This step yields a complete prediction evaluation for each unlabeled sample, including prediction category, prediction confidence, and prediction uncertainty.

[0085] Next, the sample prediction evaluation results are constructed into a two-dimensional evaluation space, and the Pareto optimization concept is applied to identify the optimal candidate samples. The two-dimensional evaluation space uses prediction confidence as the X-axis (the higher the better) and prediction uncertainty as the Y-axis (the lower the better), with each unlabeled sample having a corresponding coordinate point in this space. The Pareto ranking principle is applied to identify samples located on the Pareto front; these samples are not simultaneously outperformed by any other sample in both confidence and certainty dimensions. Specifically, for each sample, it is checked whether another sample simultaneously has higher confidence and lower uncertainty; if not, the sample is located on the Pareto front. Samples on the Pareto front represent the best compromise between the two objectives; this introduction of multi-objective optimization is one of the innovations of this embodiment. This method avoids the limitations that may arise from simply setting a fixed threshold, resulting in a set of candidate samples that perform best in balancing confidence and uncertainty. These samples become the preferred targets for subsequent pseudo-label generation, improving the quality and reliability of the pseudo-labels.

[0086] Then, based on the model's performance on the validation set, dynamic confidence and uncertainty thresholds are set. Static, fixed thresholds often struggle to adapt to the characteristics of different datasets and training stages, while dynamic thresholds can adaptively adjust according to the current model state. For the confidence threshold, it is set to 0.95 to 1.05 times the accuracy achieved by the model on the validation set. This design is based on the assumption that the model's prediction accuracy on unlabeled data should not significantly exceed its performance on the validation set. For example, if the model's accuracy on the validation set is 85%, the confidence threshold can be set to 80.75% to 89.25%. For the uncertainty threshold, it is set to 0.8 to 1.2 times the median prediction uncertainty of all samples. This range effectively filters out samples with abnormally high uncertainty while retaining a sufficient number of candidate samples. Using the median makes the threshold setting insensitive to outliers, making it more robust. These two dynamic thresholds are automatically updated as training progresses and model performance improves, ensuring that the pseudo-label strategy always adapts to the current model state. Through a dynamic threshold mechanism, a more flexible and adaptive sample selection criterion is obtained, which can maintain the high quality of pseudo-labels at different stages of training.

[0087] Next, we introduce a gradient contribution-based sample importance assessment. Besides prediction confidence and uncertainty, the potential contribution of a sample to model learning is also a crucial factor in selecting pseudo-labels. Calculating the gradient norm of each candidate sample with respect to the model parameters quantifies the sample's information value. Specifically, for each candidate sample, its pseudo-label is used as the true label, and the loss function between the model prediction and this "true label" is calculated. Then, the gradient of this loss function with respect to the classifier network parameters is calculated through backpropagation. Finally, the L2 norm of this gradient is calculated as a measure of gradient contribution. Samples with larger gradient norms indicate that they may contain more information that the model has not yet learned, have a greater impact on parameter updates, and therefore have higher learning value. To make gradient contributions comparable across different batches, normalization is required, typically by dividing by the largest gradient norm in the current batch. The normalized gradient contribution is used as a gradient contribution score to rank the importance of samples in the candidate sample set. This gradient-based sample importance assessment method originates from active learning theory and can identify the most valuable samples for model learning, further improving the quality and utility of pseudo-labels.

[0088] Finally, high-quality samples are selected for pseudo-label training based on the comprehensive evaluation results. Based on the previously established multi-dimensional evaluation system, a multi-screening strategy is used to select the final pseudo-label samples: First, samples with prediction confidence greater than the dynamic confidence threshold and prediction uncertainty less than the dynamic uncertainty threshold are selected, ensuring basic prediction reliability. Then, samples with higher contribution scores are prioritized based on gradient contribution ranking, ensuring the learning value of the samples. If the number of samples meeting the conditions is too large, an upper limit can be set (e.g., 30%-50% of the current labeled data) to prevent pseudo-label samples from dominating the training process. The finally selected samples are added to the adaptation training set as pseudo-labels for the next round of training, using their predicted categories as pseudo-labels. The pseudo-label training process can adopt a progressive strategy, using fewer pseudo-label samples and lower weights in the initial stage, gradually increasing the number and weights of pseudo-label samples as training progresses. This reduces the negative impact of potentially inaccurate pseudo-labels in the early stages. Simultaneously, slightly lower loss weights (e.g., 0.7-0.9) can be assigned to the pseudo-label samples to reflect the uncertainty of their labels. Through multiple rounds of pseudo-label generation and training, the model performance is gradually improved, and finally a pseudo-label-enhanced model is obtained. This model can effectively utilize unlabeled data in the target domain and significantly improve the accuracy and stability of early warning.

[0089] In one embodiment, the design includes a multi-layer convolutional neural network with a combination of 3 to 5 convolutional and pooling layers as a feature extraction network for extracting high-level feature representations from water fingerprint spectra, resulting in a feature extraction network structure including: A mathematical model of a quadratic integral firing neuron is constructed, wherein the membrane potential dynamics of the mathematical model are derived from the quadratic differential equation dV / dt=V²+I(t)-υ. reset Description, where V is the membrane potential, I(t) is the input current, and υ reset To reset the potential parameters, a quadratic integral firing neuron model was obtained; The step pulse firing function in the quadratic integral firing neuron model is replaced with the sigmoid approximation function to ensure the continuity and differentiability of the gradient, resulting in a differentiable neuron firing model. Based on the differentiable neuron firing model, a feature extraction network consisting of 3 to 5 convolutional layers is constructed. Each convolutional layer is followed by a batch normalization layer and the differentiable neuron firing model as the activation function, and then by a max pooling layer to obtain a convolutional network based on quadratic integral firing neurons. In each convolutional layer of the convolutional network based on quadratic integral firing neurons, the convolutional kernel parameters are initialized to follow a Gaussian distribution with a mean of 0 and a standard deviation of 0.01. The reset potential parameter υ of the quadratic integral firing neuron model is then... reset Initialize the parameters to values ​​in the range of -0.1 to -0.5 to obtain the convolutional network after parameter initialization; The output of the convolutional network after parameter initialization is flattened into a one-dimensional feature vector through a global average pooling layer to obtain the feature extraction network structure.

[0090] Specifically, firstly, a mathematical model of a quadratic integral firing neuron is constructed, a computational unit inspired by biological neurons. Traditional artificial neural networks use simplified neuron models (such as ReLU), while the dynamic characteristics of biological neurons are more complex, capable of capturing temporal information and energy accumulation processes. The quadratic integral firing neuron model is a type of computational unit that can better simulate the dynamic behavior of biological neurons. Its core is a quadratic differential equation describing membrane potential changes: dV / dt=V²+I(t)-υ reset Where V represents the membrane potential of the neuron, I(t) represents the input current (corresponding to the input signal in the neural network), and υ reset This indicates the reset potential parameter. Compared to the traditional integral firing model, the quadratic integral model adds a quadratic term V² for the membrane potential, making the neuron's dynamic behavior near the firing threshold more similar to that of a biological neuron, exhibiting richer nonlinear characteristics. In this model, when the membrane potential V exceeds a certain threshold, the neuron fires a spike pulse and resets the membrane potential to υ. resetThis firing mechanism enables neurons to encode the time integral characteristics of the input signal, making it particularly suitable for processing time-varying signals such as spectral data. Compared to traditional neural network units, the quadratic integral firing neuron model exhibits stronger temporal and nonlinear characteristics, enabling it to more effectively capture dynamic change patterns in water quality fingerprint data.

[0091] Next, to enable the quadratic integral firing neuron model to be applied within a deep learning framework, the gradient calculation problem needs to be addressed. Traditional spiking neuron models are not differentiable at the firing point, which hinders the application of the backpropagation algorithm. To solve this problem, this embodiment replaces the neuron's step firing function with a sigmoid approximation function. Specifically, the original step function H(VV) is... threshold (When V≥V) threshold The function σ((VV) is replaced with a smooth sigmoid function σ((VV)). The output is 1 if VV is active, and 0 otherwise. threshold The substitution λ(t) is used, where λ is a temperature parameter controlling the smoothness, typically set to a small positive number (e.g., 0.05). This substitution makes the pulse firing process continuous and differentiable, facilitating gradient computation and the application of the backpropagation algorithm. Furthermore, to further improve the stability of gradient propagation, a straight-through estimator technique can be employed, using discrete pulses during forward propagation and continuous approximate derivatives during backpropagation. These techniques result in a differentiable neuron firing model, enabling the integration of quadratic integral firing neurons into deep learning frameworks and end-to-end training via gradient descent.

[0092] Based on a differentiable neuron firing model, a deep convolutional network specifically designed for water fingerprint analysis is constructed. The network structure consists of 3 to 5 convolutional layers, each carefully tuned to adapt to the characteristics of spectral data. The first convolutional layer typically uses a relatively long kernel (e.g., 11×1 or 15×1) to capture a wide range of spectral features; subsequent layers gradually reduce the kernel size (e.g., 7×1, 5×1, 3×1) to capture more localized feature patterns. Each convolutional layer is followed by a batch normalization layer to accelerate training convergence and improve model robustness. Unlike traditional CNNs, this network uses the previously defined differentiable neuron firing model as the activation function, replacing the commonly used ReLU or sigmoid functions. This bio-inspired activation mechanism enables the network to better handle the temporal characteristics and complex nonlinear relationships in spectral data. After convolution and activation, a max-pooling layer is applied to reduce feature dimensionality and extract salient features. The pooling window size is typically 2 or 3, avoiding excessively large pooling windows to prevent loss of spectral details. This convolutional network architecture based on quadratic integral firing neurons combines the dynamic characteristics of biological neurons with the powerful expressive capabilities of deep learning, making it particularly suitable for processing water quality fingerprint data with complex spatiotemporal patterns.

[0093] After the network is built, fine-grained parameter initialization is crucial for the training stability of the spiking neural network. For the weight parameters of the convolutional layers, a truncated Gaussian distribution with a mean of 0 and a standard deviation of 0.01 is used for initialization. This relatively small initial value helps prevent neurons from over-saturating or over-firing in the early stages of training. Specifically, the parameters of each convolutional kernel are randomly sampled from this distribution, and weight decay is applied to prevent overfitting. For the key parameter in the quadratic integral firing neuron model—the reset potential υ... reset Initialize it within the range of -0.1 to -0.5, which is the experimentally validated optimal range that can prevent overfiring while maintaining neuronal sensitivity. Lower (more negative) υ reset A value close to zero (υ) means that neurons require more input after firing to reach the firing threshold again, which helps control network activity; while a higher (close to zero) υ value... reset A higher υ value makes neurons fire more easily, which is beneficial for information transmission. During initialization, a gradual strategy can be adopted based on network depth; deeper neurons use a slightly higher υ value. reset Values ​​are set to ensure gradient propagation. Furthermore, for the parameters of the batch normalization layer, the scaling factor γ is initialized to 1, and the bias β is initialized to 0, maintaining the input distribution unchanged. These refined initialization strategies collectively ensure the stability and convergence of the neural network in the early stages of training, laying the foundation for effective learning later.

[0094] Finally, the output layer of the network is designed to transform deep features into representations suitable for classification tasks. After the last convolutional layer, a global average pooling layer is added to average the values ​​of each feature map, ensuring a fixed-dimensional output regardless of the length of the input spectrum. Compared to the flatten operation, global average pooling significantly reduces the number of parameters, lowers the risk of overfitting, and maintains the spatial invariance of features. The output of global average pooling is a one-dimensional feature vector, with dimensions equal to the number of channels in the last convolutional layer (typically 64, 128, or 256). This feature vector contains a high-level abstract representation of the original water quality fingerprint spectrum, capturing key feature patterns related to water quality status. To further enhance the expressive power of the features, a feature attention mechanism, such as a squeeze-and-excitation module, can be added after global average pooling to assign different importance weights to features in different channels, highlighting the contribution of key feature channels. Through this series of processes, the final feature extraction network structure is obtained, which can effectively extract discriminative high-level feature representations from water quality fingerprint spectra, providing a solid foundation for subsequent water quality anomaly detection.

[0095] The innovation of this feature extraction network structure lies in combining a bio-inspired neuron model with deep learning techniques, making it particularly suitable for processing the temporal and complex nonlinear characteristics of water quality fingerprint data. Compared to traditional convolutional networks, the network based on quadratic integral firing neurons is more sensitive to continuously changing patterns over time and can better capture the spectral change sequences caused by water quality anomalies. Simultaneously, the differentiable design ensures that the network can be trained end-to-end using the standard gradient descent algorithm, overcoming the training difficulties of traditional spiking neural networks. This interdisciplinary approach combining biological neuroscience and deep learning represents a cutting-edge direction in neural network research and provides a new technical path for solving complex water quality monitoring problems.

[0096] In one embodiment, training the source domain early warning basic model architecture using the training set in the source domain training dataset, employing the cross-entropy loss function and the Adam optimizer, setting the learning rate and batch size, and performing an iterative training process to obtain an initial training model includes: Based on the differentiable neuron firing model in the feature extraction network structure, the gradient of the loss function with respect to the parameters of the quadratic integral firing neuron model is calculated using the chain rule, thus obtaining the gradient calculation scheme. Construct a joint loss function that includes both classification cross-entropy loss and neuron average firing rate regularization term to obtain the joint optimization objective; In the gradient calculation scheme, when the absolute value of the gradient of the quadratic integral firing neuron model is greater than a preset threshold, the gradient is clipped to the range of the preset threshold to obtain a gradient clipping strategy. Based on the gradient calculation scheme, the joint optimization objective, and the gradient pruning strategy, the source domain early warning basic model architecture is trained using the training set in the source domain training dataset, employing the Adam optimizer and an initial learning rate of 0.0001 to 0.001 to obtain the initial training model.

[0097] Specifically, a complete gradient calculation scheme is first established for deep networks based on quadratic integral firing neurons. Due to the special nonlinear dynamics of the quadratic integral firing neuron model, its gradient calculation is more complex than that of traditional neural networks. Specifically, the chain rule needs to be used to track the gradient path of the loss function through time steps and network layers to each neuron parameter. reset The partial derivatives of the loss function L are calculated first for each time step t. For each time step t, the gradient of the loss function L with respect to the neuron's output at that time step is also calculated. L / O t Then calculate the neuron output O. t Regarding the membrane potential V t gradient O t / V t This step uses a differentiable sigmoid approximation function derivative; then the membrane potential V is calculated. t Regarding the membrane potential V at the previous time step (t-1) gradient V t / V (t-1) This involves discretizing the quadratic differential equation; finally, the membrane potential is calculated in relation to the model parameter υ. reset gradient V t / υ reset The entire process requires special handling of neuron reset events, as resets lead to discontinuities in the membrane potential trajectory. These local gradients are chained together using the backpropagation algorithm to obtain the complete gradient calculation scheme. This scheme enables the quadratic integral firing neuron model to be effectively trained within a deep learning framework and is the key technological foundation for realizing this invention.

[0098] Next, a joint loss function specifically designed for water quality anomaly detection is constructed. Traditional classification tasks typically use only cross-entropy loss, but for bio-inspired spiking neural networks, simple classification loss may lead to overly sparse or overly dense neuron firing, affecting information encoding efficiency. Therefore, a joint loss function with two components is designed: classification cross-entropy loss and neuron average firing rate regularization. Classification cross-entropy loss is a standard multi-class loss function that measures the difference between the model's predicted probability distribution and the true label distribution. The neuron average firing rate regularization is the innovation of this invention; it regulates neuron activity by penalizing the difference between the average firing rate of neurons in the network and the target firing rate. Specifically, for each quadratic integral firing neuron in the network, its average firing rate (i.e., the proportion of firing time steps to the total number of time steps) on a batch of samples is calculated, and then the mean squared error between this average firing rate and the preset target firing rate (usually set to 0.1 to 0.3) is calculated. This regularization term is multiplied by a weighting factor (usually 0.001 to 0.01) and added to the classification cross-entropy loss to form the final joint optimization objective. This joint loss design ensures that the network can both classify accurately and maintain appropriate neuron firing activity, improving information encoding efficiency and model robustness.

[0099] Then, a specific gradient pruning strategy is designed to address the nonlinear dynamics of the quadratic integral firing neuron model. The quadratic integral firing neuron, due to its quadratic term V... 2 The existence of gradients can lead to extremely large gradient values ​​under certain conditions, causing training instability. To address this issue, this embodiment implements a gradient clipping strategy to limit the gradient to a reasonable range. Specifically, a gradient threshold τ is set (typically between 1.0 and 5.0), and when the calculated absolute value of the gradient is | When θL| is greater than τ, it is clipped to the range [-τ, τ], i.e. θL' = τ·sign( θL)·min(1,τ / | (θL|). This pruning method preserves the direction information of the gradient, limiting only its magnitude, effectively preventing the gradient explosion problem. The choice of the gradient pruning threshold τ needs to be adjusted according to the network size and data characteristics: for deeper networks or cases with high data variability, a smaller τ value can be chosen to ensure training stability; for shallower networks or cases with relatively concentrated data distribution, a larger τ value can be chosen to accelerate convergence. This adaptive gradient pruning strategy is a key technology for training neural networks based on quadratic integral firing, ensuring the training stability of complex nonlinear dynamic systems.

[0100] Based on the three key components mentioned above (gradient calculation scheme, joint optimization objective, and gradient pruning strategy), we begin formal training of the source domain early warning basic model architecture. First, we initialize the network parameters: for the convolutional layer weights, we use the He initialization method, i.e., starting from a mean of 0 and a standard deviation of sqrt(2 / n). in Sampling is performed from a truncated normal distribution, where n in This refers to the number of input channels; the reset potential parameter υ for a quadratic integral firing neuron. reset The parameters were initialized with uniformly distributed random values ​​ranging from -0.1 to -0.5. Then, the Adam optimizer was selected for parameter updates. This optimizer combines the advantages of momentum and adaptive learning rates, making it particularly suitable for handling sparse gradients and non-stationary objectives. The initial learning rate was set between 0.0001 and 0.001. The batch size was set between 16 and 64 to strike a balance between computational resources and training stability. The training process employed an iterative approach, with multiple batches per epoch. After each batch was processed, the loss was calculated, gradient backpropagation was performed, and parameters were updated. An early stopping strategy was implemented during training: training was stopped when the validation loss showed no improvement for 5-10 consecutive epochs to prevent overfitting. Simultaneously, a learning rate decay strategy was implemented: when the validation loss stabilized or increased, the learning rate was reduced to 0.5 to 0.7 times its original value. Through this process, an initial trained model with good performance on the source domain training data was obtained, laying the foundation for subsequent model optimization and domain adaptation.

[0101] In one embodiment, the performance of the initially trained model is evaluated using the validation set in the source domain training dataset, and the learning rate, number of network layers, and regularization strength are adjusted to obtain a parameter-optimized model, including: The anomaly detection rate, early warning time, and false alarm rate of the initial training model are defined as performance evaluation indicators. The score of the initial training model on each performance evaluation indicator is calculated using the validation set in the source domain training dataset to obtain the initial performance evaluation result. Based on the initial performance evaluation results, the learning rate search range is set to 0.00001 to 0.01, the network layer search range is 3 to 5 layers, the L1 regularization coefficient search range is 0 to 0.01, and the L2 regularization coefficient search range is 0 to 0.1, thus obtaining the hyperparameter search space; A grid search method is used in the hyperparameter search space to generate 20 to 50 sets of hyperparameter configuration combinations. The initial training model is retrained for each set of hyperparameter configuration combinations to obtain multiple candidate models. The performance of the multiple candidate models on three metrics—anomaly detection rate, early warning time, and false alarm rate—is evaluated using the validation set in the source domain training dataset. The comprehensive performance score of each candidate model is calculated to obtain the candidate model performance evaluation results. From the performance evaluation results of the candidate models, the candidate model with the highest comprehensive performance score is selected, and the corresponding learning rate, number of network layers and regularization strength parameters are extracted to obtain the optimal hyperparameter configuration. The initial training model is retrained using the optimal hyperparameter configuration to obtain the model with optimized parameters.

[0102] Specifically, firstly, a comprehensive performance evaluation index system is defined to objectively assess the practical application effect of the water quality anomaly early warning model. Unlike general classification tasks that primarily focus on accuracy, the water quality anomaly early warning system needs to comprehensively consider the performance of multiple key dimensions. This embodiment defines three core performance evaluation indicators: anomaly detection rate, warning lead time, and false alarm rate. The anomaly detection rate is the proportion of anomaly events successfully detected by the model out of the total number of anomaly events, calculated as (number of detected anomaly events / total number of anomaly events) × 100%. This indicator reflects the model's ability to capture real anomalies and is a key indicator for evaluating the model's sensitivity. The warning lead time is the time interval between the model issuing a warning signal and the actual occurrence of the anomaly, measured in minutes or hours. This indicator reflects the model's predictive ability; the earlier the warning, the more time the wastewater treatment plant has to take preventative measures. Specifically, for each successfully warned anomaly, the difference between the warning time and the actual occurrence time is calculated, and then the average value is taken. The false alarm rate is the proportion of false warnings issued by the model out of the total number of warnings, calculated as (number of false warnings / total number of warnings) × 100%. This metric reflects the model's accuracy; an excessively high false alarm rate leads to decreased system reliability, causing maintenance personnel to struggle with dealing with false alarms. The performance of the initially trained model on these three metrics is calculated using the source domain validation set, yielding initial performance evaluation results and providing a benchmark for subsequent parameter optimization.

[0103] Next, based on the initial performance evaluation results, the hyperparameter search space is defined. Model performance is closely related to multiple hyperparameters, requiring a systematic exploration of optimal combinations. This embodiment focuses on four key hyperparameters: learning rate, number of network layers, and two regularization coefficients. The learning rate affects the model's convergence speed and final performance, with a search range of 0.00001 to 0.01, covering five orders of magnitude. Logarithmic scaling is typically used, such as [0.00001, 0.0001, 0.001, 0.01]. The number of network layers determines the model's complexity and expressive power, with a search range of 3 to 5 layers, each corresponding to a different network architecture design. L1 regularization (Lasso regularization) penalizes the absolute value of weights and promotes weight sparsity, with a search range of 0 to 0.01, typical values ​​including [0, 0.0001, 0.001, 0.005, 0.01]. L2 regularization (Ridge regularization) controls the weight size by penalizing the sum of squared weights, preventing overfitting. The search range is 0 to 0.1, with typical values ​​including [0, 0.001, 0.01, 0.05, 0.1]. The combinations of these four hyperparameter dimensions constitute the complete search space, with a total of 4 (learning rate) × 3 (number of network layers) × 5 (L1 coefficients) × 5 (L2 coefficients) = 300 possible configurations. Considering computational resource constraints, typically 20 to 50 representative combinations are selected for testing. These combinations should cover the entire search space as evenly as possible to ensure that no potential optimal regions are missed.

[0104] Then, a grid search process is performed within the defined hyperparameter search space. Grid search is a commonly used hyperparameter optimization method that exhaustively searches a predefined parameter grid to find the optimal parameter combination. In this embodiment, 20 to 50 sets of hyperparameter configuration combinations are first generated from the search space to ensure coverage of key parameter regions. Then, for each set of hyperparameter configurations, the model is retrained using the same initialization strategy and training data. The training time can be appropriately shortened (e.g., 50%-70% of the original training time), but it is essential to ensure that the model reaches basic convergence. To improve search efficiency, an early stopping strategy can be adopted, terminating training early when the model's performance on the validation set does not improve for several consecutive epochs. Alternatively, cross-validation can be combined, dividing the training set into multiple folds and performing k-fold cross-validation (usually k=3 or 5) on each hyperparameter combination, taking the average performance. This reduces the impact of randomness in a single training iteration and yields more robust evaluation results. Through this process, multiple candidate models are generated, each corresponding to a specific set of hyperparameter configurations, preparing for the next step of performance evaluation.

[0105] Next, a comprehensive performance evaluation is performed on the generated candidate models. The source domain validation set is used to calculate the three core metrics defined earlier for each candidate model: anomaly detection rate, warning lead time, and false alarm rate. To comprehensively consider these three potentially conflicting metrics, a weighted scoring system needs to be constructed. The comprehensive performance score can be expressed as a weighted sum of the three metrics: Score = w1 × anomaly detection rate - w2 × false alarm rate + w3 × normalized warning lead time, where w1, w2, and w3 are weight coefficients, set according to the specific application scenario. Typically, w1 > w2 to reflect that detecting anomalies is more important than avoiding false alarms, while the warning lead time needs to be normalized to be on the same order of magnitude as the percentage metric. For example, w1 = 0.5, w2 = 0.3, and w3 = 0.2 can be set. In addition to the three core metrics, auxiliary metrics such as model inference speed and parameter count can also be considered, especially in resource-constrained environments. Through this comprehensive scoring mechanism, each candidate model will obtain a quantified performance score, reflecting its comprehensive performance across multiple dimensions. All candidate models are sorted according to their comprehensive performance scores to obtain the performance evaluation results of the candidate models, which provides a basis for selecting the optimal model.

[0106] Then, based on the comprehensive performance evaluation results, the candidate model with the best performance is selected. From the performance evaluation results, the candidate model with the highest comprehensive performance score is identified, and its corresponding hyperparameter configuration is extracted, including the optimal learning rate, number of network layers, and two regularization strength parameters. Furthermore, the model's performance on each individual metric should be analyzed to ensure there are no obvious weaknesses. If the highest-scoring model significantly lags behind in a key metric (e.g., an anomaly detection rate lower than expected), a model with a slightly lower comprehensive score but more balanced performance across metrics can be considered. To enhance the reliability of the results, the top 3-5 models can be further evaluated in detail, such as by training multiple times under different random seeds or by validating performance stability on additional test data. Through this careful selection process, the final optimal hyperparameter configuration is determined, preparing for the final model training.

[0107] Finally, the initially trained model is retrained using the determined optimal hyperparameter configuration to obtain the parameter-optimized model. The retraining process employs a full training cycle, using the source domain training set for parameter learning, while the source domain validation set monitors the training progress and implements an early stopping strategy. Unlike the initial training, this training uses optimized hyperparameters: optimal learning rate, network layer configuration, and L1 and L2 regularization coefficients. More refined learning rate scheduling strategies, such as cosine annealing or cyclic learning rates, can be implemented during training to further improve model performance. Furthermore, more comprehensive data augmentation techniques, such as adding Gaussian noise and random frequency masks, can be applied to enhance the model's robustness to spectral variations. After training, the model's performance on the three core metrics is evaluated again using the source domain validation set to confirm the optimization effect. If the performance is significantly better than the initial model, it is confirmed as the parameter-optimized model; if the improvement is limited, it may be necessary to reconsider the hyperparameter search strategy or expand the search space. The final parameter-optimized model exhibits better anomaly detection capabilities and generalization performance, laying a solid foundation for subsequent domain adaptation.

[0108] In one embodiment, the step of evaluating the performance of the target domain adaptation early warning model using a test set from the target domain adaptation dataset, and integrating the target domain adaptation early warning model into an online monitoring system when the performance evaluation result reaches a predetermined threshold, includes: The target domain adaptation warning model is comprehensively evaluated using the test set in the target domain adaptation dataset. The accuracy, precision, recall and F1 score are calculated and compared with a predetermined threshold to obtain a performance evaluation report. The detection performance and reliability of the target domain adaptive early warning model on different types of abnormal events are evaluated by confidence analysis, confusion matrix and ROC curve, potential weaknesses are identified and a reliability analysis report is obtained; The target domain adaptive early warning model is encapsulated into a standardized software module that includes data preprocessing, feature extraction, and anomaly prediction functions. A model interface specification is designed to obtain a deployable early warning model software package. The deployable early warning model software package is integrated into the online monitoring system of the wastewater treatment plant, and data access, early warning thresholds and alarm methods are configured to obtain a complete early warning system; Develop a visual interface to display water quality fingerprint data, anomaly warning results and confidence levels in real time, support historical data backtracking and trend analysis, and obtain a warning result visualization module; The design incorporates a continuous update mechanism for the target domain adaptive early warning model. This mechanism involves periodically collecting new water quality data and feedback information, and employing an incremental learning method to update the parameters of the target domain adaptive early warning model, thereby achieving continuous improvement in its performance.

[0109] Specifically, the performance of the target domain adaptation early warning model was first comprehensively and systematically evaluated using the test set in the target domain adaptation dataset. The test set consists of independent data that was not used for training and tuning during model development, and thus accurately reflects the model's performance in real-world application environments. The evaluation process employed a multi-dimensional indicator system, including traditional classification performance metrics and specialized metrics specific to water quality anomaly detection. For traditional classification metrics, accuracy (the proportion of all correctly predicted samples out of the total samples), precision (the proportion of correctly predicted anomaly samples out of all predicted anomalies), recall (the proportion of correctly predicted anomaly samples out of all actual anomaly samples), and F1 score (the harmonic mean of precision and recall) were calculated. For specialized water quality anomaly detection metrics, the anomaly detection rate (the success rate of detecting different types of anomalies), average early warning time (the average interval between the model's early warning time and the actual occurrence of the anomaly), false alarm rate (the proportion of false warnings out of the total number of warnings), and false negative rate (the proportion of undetected anomalies) were evaluated. For each indicator, corresponding predetermined thresholds are set, such as F1 score > 0.85, anomaly detection rate > 90%, average early warning time > 30 minutes, and false alarm rate < 5%. Only when all key indicators reach or exceed the predetermined thresholds is the model considered to meet the deployment conditions. This rigorous multi-dimensional evaluation ensures the reliability and practicality of the model in real-world applications, providing a scientific basis for model deployment decisions.

[0110] Next, in addition to overall performance metrics, in-depth reliability analysis is needed to evaluate the model's robustness under different conditions. First, confidence analysis is used to study the certainty and reliability of the model's predictions. For each test sample, the confidence score of the model output (usually the maximum value of the softmax output) is recorded, and the confidence distribution characteristics are analyzed, such as plotting a confidence histogram and calculating the mean confidence score and standard deviation. Reliable models typically have high confidence when predicting correctly and relatively low confidence when predicting incorrectly. Second, a confusion matrix is ​​constructed and analyzed to detail the prediction confusion between categories, paying particular attention to the confusion between different types of anomalies and the ability to distinguish between normal and minor anomalies. This helps identify weaknesses in the model, such as certain easily confused anomaly types. Third, ROC curves (Receiver Operating Characteristic curves) and PR curves (Precision-Recall curves) are plotted and analyzed, and the area under the curves (AUC) is calculated to evaluate the model's performance changes under different decision thresholds. Furthermore, sensitivity analysis should be performed to test the model's response to small changes in input data, such as adding different levels of noise or simulating sensor drift, to evaluate the model's robustness. Finally, for specific high-risk anomaly types (such as toxic shocks), separate in-depth analyses are conducted to ensure the model has a sufficiently high detection capability for these key anomalies. Through this series of analyses, a detailed reliability analysis report is generated, comprehensively assessing the model's strengths and potential weaknesses, providing guidance for the model's actual deployment and subsequent optimization.

[0111] Then, the validated target domain adaptive early warning model is encapsulated into standardized software modules for easy integration into real-world engineering environments. The encapsulation process first ensures the model's independence and portability, packaging the model and all its dependent components (such as data preprocessing, feature extraction, and anomaly prediction logic) into a self-contained software unit. Specifically, the data preprocessing component receives raw spectral data, performs normalization, noise filtering, and baseline correction, converting it into a standard input format acceptable to the model; the feature extraction component implements a trained feature extraction network, converting the preprocessed spectral data into a high-dimensional feature representation; and the anomaly prediction component implements a classifier network, making predictions based on the extracted features and calculating confidence levels. These three core functional modules are sequentially linked according to the data flow, forming a complete prediction pipeline. Simultaneously, a standardized model interface specification is designed, clearly defining the input data format, output result format, and calling method to ensure compatibility with different systems. The interface design should follow RESTful API or similar standard specifications, supporting synchronous and asynchronous calling modes. Furthermore, a model version control and configuration management mechanism is required to support smooth model upgrades and rollbacks. Finally, the aforementioned components and interface specifications are integrated into a deployable early warning model software package, which can be released as a container image, a standalone service, or an embedded library to meet the needs of different deployment environments.

[0112] Next, the packaged early warning model software package will be integrated into the wastewater treatment plant's online monitoring system to achieve real-time water quality anomaly early warning functionality. The integration process first requires configuring a data access mechanism to establish a data flow channel from water quality monitoring equipment to the early warning model. This typically includes setting the data acquisition frequency (e.g., once every 15 minutes), data transmission protocol (e.g., MQTT, OPC UA, etc.), and data buffering strategy. Secondly, early warning thresholds and decision rules need to be configured, defining the early warning trigger conditions for different types of anomalies. Early warning thresholds can be set based on model confidence levels, such as triggering an early warning when the prediction confidence of a certain type of anomaly exceeds 0.85; alternatively, differentiated thresholds can be set according to the risk level of different anomaly types, such as setting a lower threshold to increase sensitivity for high-risk toxic shocks. Then, alarm methods and notification paths need to be configured, including multiple channels such as on-site audible and visual alarms, SMS notifications, email notifications, and mobile app push notifications, ensuring that key personnel can be informed of anomalies in a timely manner. Furthermore, the recording and management functions of early warning events need to be implemented, including the storage and retrieval of information such as early warning time, early warning type, severity, and handling status. Finally, system integration testing was conducted to verify the normal operation of the entire early warning process, ensuring seamless connection between each step from data acquisition, processing, early warning triggering to notification sending. Through this series of configurations and tests, a complete early warning system was formed, enabling the early warning model to function effectively in real-world engineering environments, achieving early detection and warning of water quality anomalies.

[0113] Then, a dedicated visualization interface was developed to intuitively display water quality monitoring and early warning results, improving the system's usability and decision support capabilities. The core function of the visualization interface is to display real-time water quality fingerprint data, anomaly early warning results, and confidence levels, enabling operators to understand the current water quality status at a glance. The interface design adopts a dashboard style, with the main interface containing multiple functional areas: the top displays key indicators and a current status overview, such as the latest sampling time, comprehensive water quality score, and early warning status; the middle displays real-time spectral curves and trends of major characteristics, using different colors to indicate normal ranges and abnormal fluctuations; the bottom displays recent early warning records and processing status. To enhance intuitiveness, the interface uses color coding to represent different states and risk levels: green indicates normal, yellow indicates slight anomalies, and red indicates severe anomalies. In addition, the interface supports historical data review and trend analysis functions, allowing users to select any time period to view historical spectral data, early warning events, and processing records, and generate trend charts, such as the frequency of anomalies and changes in early warning lead times. Advanced analysis functions allow users to compare water quality characteristics across different periods and identify seasonal patterns or long-term trends. To support mobile work, responsive web interfaces or dedicated mobile applications can be developed to ensure that key personnel can monitor system status even when they are away from home. These feature-rich and easy-to-use visualization tools greatly enhance system usability and decision support capabilities, enabling operators to monitor water quality more efficiently, identify potential problems, and respond promptly.

[0114] Finally, a continuous update mechanism for the early warning model is designed to ensure that model performance continuously improves with the accumulation of new data, maintaining long-term effectiveness. This continuous update mechanism comprises four key stages: data collection, model evaluation, incremental learning, and version management. During the data collection phase, new water quality fingerprint data and corresponding anomaly records are automatically collected periodically (e.g., monthly or quarterly), along with feedback from operators regarding the accuracy of the early warning system, such as false alarms and missed alarms. This new data, after quality checks and standardization, is added to the target domain database. During the model evaluation phase, the performance of the currently deployed model is evaluated using the newly collected data. If a significant performance degradation is detected (e.g., an accuracy decrease of more than 5% or a false alarm rate increase of more than 10%), a model update process is triggered. During the incremental learning phase, the system uses expanded target domain data to incrementally update the model parameters, rather than completely retraining. Incremental learning employs a carefully designed process: First, most parameters of the feature extraction network are frozen, with only the last few layers of the classifier and feature extraction networks updated. Then, a small learning rate (e.g., 0.0001) and strong regularization constraints are used to prevent new data from causing the model to "forget" previously learned patterns. Finally, the updated model is comprehensively evaluated to ensure performance improvement. During the version management phase, the system saves multiple historical versions of the model and their performance records, supporting rollback to previous stable versions when necessary. Furthermore, an A / B testing mechanism can be implemented, deploying both the current and updated versions simultaneously to compare their performance in real-world environments, reducing the risk of version updates. Through this continuous update mechanism, the model can adapt to seasonal changes and long-term trends in water quality characteristics, maintaining consistently high performance and ensuring the long-term effective operation of the early warning system.

[0115] like Figure 3 As shown, a rapid construction system for a water quality fingerprint early warning model of a wastewater treatment plant includes: The source domain data acquisition and preprocessing module 10 is used to acquire the original water quality fingerprint data and water quality abnormal event label data of the source domain sewage treatment plant, and to preprocess the original water quality fingerprint data and the water quality abnormal event label data after association and annotation to obtain the source domain training dataset. The source domain early warning basic model training module 20 is used to construct a source domain early warning basic model containing a feature extraction network and a classifier network based on the source domain training dataset, and to train the source domain early warning basic model to obtain the trained source domain early warning basic model. The target domain data acquisition and processing module 30 is used to collect short-term water quality fingerprint data from the wastewater treatment plant in the target domain, process the short-term water quality fingerprint data according to the preprocessing process, and obtain the target domain adaptation dataset. The domain-adaptive feature extraction module 40 is used to use the feature extraction network in the trained source domain early warning base model as a feature extractor, and to use the feature extractor to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation; and to reduce the difference between the source domain feature distribution representation and the target domain feature representation through a domain-adaptive method to obtain a domain-adaptive feature extractor. The target domain model training module 50 is used to reconstruct the classifier network based on the domain-adaptive feature extractor, and train the reconstructed classifier network using the target domain adaptation dataset to obtain the target domain adaptation early warning model. The model deployment and integration module 60 is used to evaluate the performance of the target domain adaptation early warning model using the test set in the target domain adaptation dataset, and to integrate the target domain adaptation early warning model into the online monitoring system when the performance evaluation result reaches a predetermined threshold.

[0116] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for rapidly constructing a water quality fingerprint early warning model for wastewater treatment plants, characterized in that, include: The raw water quality fingerprint data and water quality anomaly event label data of the source wastewater treatment plant are obtained. The raw water quality fingerprint data and the water quality anomaly event label data are associated and labeled and then preprocessed to obtain the source training dataset. Based on the source domain training dataset, a source domain early warning basic model including a feature extraction network and a classifier network is constructed. The source domain early warning basic model is trained to obtain the trained source domain early warning basic model. Short-term water quality fingerprint data is collected from wastewater treatment plants in the target domain, and the short-term water quality fingerprint data is processed according to the preprocessing procedure to obtain the target domain adaptation dataset. The feature extraction network in the trained source domain early warning base model is used as a feature extractor. The feature extractor is used to process the source domain training dataset and the target domain adaptation dataset to obtain the source domain feature distribution representation and the target domain feature distribution representation. The difference between the source domain feature distribution representation and the target domain feature distribution representation is reduced by the domain adaptation method to obtain the domain-adaptive feature extractor. The classifier network is reconstructed based on the domain-adaptive feature extractor, and the reconstructed classifier network is trained using the target domain adaptation dataset to obtain the target domain adaptation early warning model. The target domain adaptation early warning model is evaluated using the test set in the target domain adaptation dataset. When the performance evaluation result reaches a predetermined threshold, the target domain adaptation early warning model is integrated into the online monitoring system.

2. The method according to claim 1, characterized in that, The process of associating and labeling the original water quality fingerprint data with the water quality anomaly event label data, followed by preprocessing, yields a source domain training dataset, including: Ultraviolet-visible spectrometers and near-infrared spectrometers were installed at the inlet, outlet, and effluent of the Yuanyu wastewater treatment plant. Water quality spectral data were collected at 15-minute intervals, and the sampling time and location were recorded to obtain the original water quality fingerprint data. Collect abnormal events such as toxic shocks, process fluctuations, and equipment failures from the historical operation records of the wastewater treatment plants in the source area, along with their corresponding occurrence times, and establish an event tag library to obtain the water quality abnormal event tag data; Align the original water quality fingerprint data with the water quality abnormal event label data according to the timestamp, determine the event status corresponding to each water quality fingerprint sample, and obtain a time-aligned labeled dataset; Baseline correction, scattering correction, and noise filtering are performed on the spectral data in the time-aligned labeled dataset to improve the signal-to-noise ratio. Spectral normalization is then performed to eliminate system differences between different batches of data to obtain standardized spectral data. Based on the standardized spectral data, a synthetic minority class oversampling technique is used to increase the number of anomalous event samples, thereby obtaining class-balanced training data. The class-balanced training data is divided into a training set, a validation set, and a test set according to time order to obtain the source domain training dataset.

3. The method according to claim 1, characterized in that, The construction of a source domain early warning basic model, including a feature extraction network and a classifier network, and training the source domain early warning basic model to obtain the trained source domain early warning basic model, includes: A multi-layer convolutional neural network with a combination of 3 to 5 convolutional and pooling layers was designed as a feature extraction network to extract high-level feature representations from water fingerprint spectra, resulting in the feature extraction network structure. Design a classifier network consisting of fully connected layers. The classifier network receives the output of the feature extraction network structure and outputs the water quality state prediction result through the softmax activation function, thus obtaining the source domain early warning basic model architecture. The source domain early warning basic model architecture is trained using the training set in the source domain training dataset. The cross-entropy loss function and Adam optimizer are used, and the learning rate and batch size are set to perform an iterative training process to obtain the initial training model. The performance of the initial trained model is evaluated using the validation set in the source domain training dataset. The learning rate, number of network layers, and regularization strength are adjusted to obtain the model with optimized parameters. The optimized model is evaluated using the test set in the source domain training dataset. Accuracy, precision, recall, and F1 score are calculated to obtain the trained source domain early warning basic model.

4. The method according to claim 1, characterized in that, The short-term water quality fingerprint data is processed according to the preprocessing procedure to obtain the target domain-adapted dataset, including: By deploying ultraviolet-visible spectrometers and near-infrared spectrometers of the same specifications as those used in the source wastewater treatment plant at key monitoring points in the target wastewater treatment plant, a target domain monitoring system is obtained. The target domain monitoring system collects water quality fingerprint data during the initial 1 to 3 months of operation, and records abnormal events and their corresponding tags to obtain a short-term dataset of the target domain. Using the same preprocessing procedure as the source domain training dataset, the spectral data in the target domain short-term dataset are processed through baseline correction, scattering correction, noise filtering, and normalization to obtain standardized target domain data. The standardized target domain data is divided into an adaptation training set and a test set to obtain the target domain adaptation dataset.

5. The method according to claim 1, characterized in that, The feature extraction network in the trained source domain early warning basic model is used as a feature extractor. The feature extractor is used to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation. A domain-adaptive feature extractor is obtained by reducing the difference between the source domain feature distribution representation and the target domain feature distribution representation through a domain-adaptive method, including: Using the feature extraction network in the trained source domain early warning basic model as a feature extractor, the parameters of the bottom convolutional layer of the feature extractor are frozen to obtain the decoupled feature extractor. The decoupled feature extractor is used to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature representation and the target domain feature representation. The mean, variance and covariance matrix are calculated for the source domain feature representation and the target domain feature representation respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation. Based on the decoupled feature extractor, a label predictor for predicting sample labels and a domain classifier for determining the domain to which a sample belongs are added to obtain the domain adversarial network architecture. The domain adversarial network architecture is adversarially trained using the source domain training dataset and the target domain adaptation dataset. The feature extractor is then adversarially trained by using a gradient inversion layer to simultaneously minimize the classification error of the label predictor and maximize the discrimination error of the domain classifier. Based on the features extracted by the adversarial-trained feature extractor, the maximum average difference between the source domain feature distribution representation and the target domain feature distribution representation is calculated in the feature space. The adversarial-trained feature extractor is further fine-tuned by minimizing the maximum average difference to obtain a feature extractor with aligned feature distributions. Source domain validation data is extracted from the validation set of the source domain training dataset, and target domain validation data is extracted from the test set of the target domain adaptation dataset. The source domain validation data and the target domain validation data are processed respectively using the feature extractor aligned with the feature distribution. The alignment effect of the feature distribution is verified by t-SNE visualization and maximum mean difference metric to obtain the domain-adaptive feature extractor.

6. The method according to claim 5, characterized in that, The process of using the decoupled feature extractor to process the source domain training dataset and the target domain adaptation dataset respectively to obtain source domain feature representations and target domain feature representations, and calculating the mean, variance, and covariance matrices of the source domain feature representations and target domain feature representations respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation, includes: A Monte Carlo dropout layer is added to the decoupled feature extractor so that the decoupled feature extractor can output the prediction result and its uncertainty estimate, thus obtaining the uncertainty quantification model; The uncertainty quantification model is used to process the source domain training dataset and the target domain adaptation dataset respectively, and the source domain feature representation and the target domain feature representation are extracted. For each feature of the source domain feature representation and the target domain feature representation, the coefficient of variation of its contribution to the prediction result is calculated through 10 to 20 Monte Carlo samplings to obtain the feature contribution uncertainty. The backpropagation algorithm is used to calculate the absolute gradient of each feature dimension in the source domain feature representation and the target domain feature representation with respect to the classification loss function. The absolute gradient value is then normalized and used as the feature importance score. The feature importance score is combined with the feature contribution uncertainty to obtain the feature importance-uncertainty matrix; Based on the feature importance-uncertainty matrix, features with feature importance scores greater than a preset importance threshold and feature contribution uncertainty less than a preset uncertainty threshold are sorted to obtain the key feature sorting results; Based on the ranking results of the key features, the weights of different feature channels in the uncertainty quantification model are dynamically adjusted to obtain an uncertainty-aware feature selection strategy. Based on the uncertainty-aware feature selection strategy, the uncertainty quantification model is used to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation.

7. The method according to claim 1, characterized in that, The classifier network is reconstructed based on the domain-adaptive feature extractor, and the reconstructed classifier network is trained using the target domain-adaptive dataset to obtain a target domain-adaptive early warning model, including: Based on the domain-adaptive feature extractor, the classifier network is reconstructed while keeping the parameters of the domain-adaptive feature extractor unchanged. Only the parameters of the classifier network are initialized to obtain the reconstructed model architecture. The classifier network in the reconstructed model architecture is trained under supervision using the adaptation training set in the target domain adaptation dataset with a learning rate of 0.0001 to 0.001 to obtain the model parameters for preliminary fine-tuning. A progressive learning rate decay strategy is implemented on the reconstructed model architecture, reducing the learning rate to 0.5 to 0.8 times the original learning rate after each preset number of training rounds, thereby obtaining an optimized training process; During the optimized training process, L1 regularization coefficients, L2 regularization coefficients, and Dropout ratios are introduced into the classifier network of the reconstructed model architecture to prevent the reconstructed model architecture from overfitting on the target domain adaptation dataset, thus obtaining a classifier network with regularization constraint parameters. The domain-adaptive feature extractor is combined with the classifier network with regularization constraint parameters to obtain a target domain model with regularization constraint parameters. The target domain model with regularization constraint parameters is used to predict the unlabeled data in the target domain adaptation dataset. The prediction results with a prediction confidence greater than 0.9 are selected as pseudo-labels to expand the adaptation training set for semi-supervised learning, and the pseudo-label-enhanced model is obtained. The Bagging ensemble method is used to train the reconstructed model architecture with 5 to 10 different initialization parameters and different learning rates and regularization coefficients. The prediction results of the 5 to 10 trained models are then integrated by weighted averaging to obtain the target domain adaptive early warning model.

8. The method according to claim 7, characterized in that, The reconstructed model architecture is subjected to a progressive learning rate decay strategy, whereby the learning rate is reduced to 0.5 to 0.8 times the original learning rate after a preset number of training epochs, resulting in an optimized training process, including: A multi-objective optimization function is defined, which includes prediction accuracy, minimization of domain differences, and control of model complexity, thus obtaining a multi-objective evaluation system; Based on the labeled data in the target domain adaptation dataset and the multi-objective evaluation system, a Pareto optimal solution set for learning rate and regularization strength is constructed to obtain the Pareto front. Calculate the prediction uncertainty under each set of hyperparameter configurations on the Pareto front, and perform a double sorting based on the position on the Pareto front to obtain the double sorting result; Based on the double ranking results, an uncertainty threshold is set. When the prediction uncertainty of the reconstructed model architecture on the validation set is greater than the uncertainty threshold, it is defined as a high uncertainty stage. When the prediction uncertainty of the reconstructed model architecture on the validation set is less than or equal to the uncertainty threshold, it is defined as a low uncertainty stage. In the high uncertainty phase, the learning rate is kept in the range of 0.0005 to 0.001 to enhance exploratory behavior, and in the low uncertainty phase, the learning rate is reduced to the range of 0.0001 to 0.0005 to accelerate convergence, thus obtaining an adaptive parameter scheduling scheme. The reconstructed model architecture is trained based on the adaptive parameter scheduling scheme. Each training epoch lasts for 10 to 20 training epochs and is considered a training cycle. At the end of each training cycle, the accuracy and prediction uncertainty of the reconstructed model architecture on the validation set are evaluated. Based on the accuracy improvement and prediction uncertainty reduction of the current training cycle compared to the previous training cycle, the learning rate decay strategy for subsequent training is automatically adjusted to obtain the optimized training process.

9. The method according to claim 7, characterized in that, The unlabeled data in the target domain adaptation dataset is predicted using the target domain model with regularization constraint parameters. Prediction results with a confidence level greater than 0.9 are selected as pseudo-labels to expand the adaptation training set for semi-supervised learning, resulting in a pseudo-label-enhanced model, including: For each sample of unlabeled data in the target domain adaptation dataset that fits the training set, the target domain model with regularization constraint parameters is used to perform 10 to 30 Monte Carlo predictions. The mean of the predicted class probability for each sample is calculated as the prediction confidence, and the standard deviation of the predicted class probability is calculated as the prediction uncertainty, so as to obtain the sample prediction evaluation result. The prediction confidence and prediction uncertainty in the sample prediction evaluation results are constructed into a two-dimensional evaluation space. Pareto ranking is used to identify samples located on the Pareto front to obtain a candidate sample set. Based on the accuracy of the target domain model with regularization constraint parameters on the validation set, the confidence threshold is set to 0.95 to 1.05 times the accuracy, and the uncertainty threshold is set to 0.8 to 1.2 times the median of the prediction uncertainty of all samples in the sample prediction evaluation results, thus obtaining the dynamic confidence threshold and the dynamic uncertainty threshold. Calculate the gradient norm of each sample in the candidate sample set with respect to the classifier network parameters in the target domain model with regularization constraint parameters, normalize the gradient norm and use it as the gradient contribution score, and sort the samples in the candidate sample set according to the gradient contribution score to obtain the gradient contribution ranking result. Based on the gradient contribution ranking results, samples with prediction confidence greater than the dynamic confidence threshold and prediction uncertainty less than the dynamic uncertainty threshold are selected. The predicted category of the sample is added as a pseudo-label to the adaptation training set for training to obtain the pseudo-label-enhanced model.

10. The method according to claim 3, characterized in that, The design incorporates a multi-layer convolutional neural network with 3 to 5 convolutional and pooling layers as a feature extraction network to extract high-level feature representations from water fingerprint spectra, resulting in a feature extraction network structure including: A mathematical model of a quadratic integral firing neuron is constructed, wherein the membrane potential dynamics of the mathematical model are derived from the quadratic differential equation dV / dt=V²+I(t)-υ. reset Description, where V is the membrane potential, I(t) is the input current, and υ reset To reset the potential parameters, a quadratic integral firing neuron model was obtained; The step pulse firing function in the quadratic integral firing neuron model is replaced with the sigmoid approximation function to ensure the continuity and differentiability of the gradient, resulting in a differentiable neuron firing model. Based on the differentiable neuron firing model, a feature extraction network consisting of 3 to 5 convolutional layers is constructed. Each convolutional layer is followed by a batch normalization layer and the differentiable neuron firing model as the activation function, and then by a max pooling layer to obtain a convolutional network based on quadratic integral firing neurons. In each convolutional layer of the convolutional network based on quadratic integral firing neurons, the convolutional kernel parameters are initialized to follow a Gaussian distribution with a mean of 0 and a standard deviation of 0.

01. The reset potential parameter υ of the quadratic integral firing neuron model is then... reset Initialize the parameters to values ​​in the range of -0.1 to -0.5 to obtain the convolutional network after parameter initialization; The output of the convolutional network after parameter initialization is flattened into a one-dimensional feature vector through a global average pooling layer to obtain the feature extraction network structure.

11. The method according to claim 10, characterized in that, The process of training the source domain early warning basic model architecture using the training set in the source domain training dataset, employing the cross-entropy loss function and the Adam optimizer, and setting the learning rate and batch size to perform an iterative training process, yields an initial training model, including: Based on the differentiable neuron firing model in the feature extraction network structure, the gradient of the loss function with respect to the parameters of the quadratic integral firing neuron model is calculated using the chain rule, thus obtaining the gradient calculation scheme. Construct a joint loss function that includes both classification cross-entropy loss and neuron average firing rate regularization term to obtain the joint optimization objective; In the gradient calculation scheme, when the absolute value of the gradient of the quadratic integral firing neuron model is greater than a preset threshold, the gradient is clipped to the range of the preset threshold to obtain a gradient clipping strategy. Based on the gradient calculation scheme, the joint optimization objective, and the gradient pruning strategy, the source domain early warning basic model architecture is trained using the training set in the source domain training dataset, employing the Adam optimizer and an initial learning rate of 0.0001 to 0.001 to obtain the initial training model.

12. The method according to claim 3, characterized in that, The performance of the initially trained model is evaluated using the validation set in the source domain training dataset. The learning rate, number of network layers, and regularization strength are adjusted to obtain a parameter-optimized model, including: The anomaly detection rate, early warning time, and false alarm rate of the initial training model are defined as performance evaluation indicators. The score of the initial training model on each performance evaluation indicator is calculated using the validation set in the source domain training dataset to obtain the initial performance evaluation result. Based on the initial performance evaluation results, the learning rate search range is set to 0.00001 to 0.01, the network layer search range is 3 to 5 layers, the L1 regularization coefficient search range is 0 to 0.01, and the L2 regularization coefficient search range is 0 to 0.1, thus obtaining the hyperparameter search space; A grid search method is used in the hyperparameter search space to generate 20 to 50 sets of hyperparameter configuration combinations. The initial training model is retrained for each set of hyperparameter configuration combinations to obtain multiple candidate models. The performance of the multiple candidate models on three metrics—anomaly detection rate, early warning time, and false alarm rate—is evaluated using the validation set in the source domain training dataset. The comprehensive performance score of each candidate model is calculated to obtain the candidate model performance evaluation results. From the performance evaluation results of the candidate models, the candidate model with the highest comprehensive performance score is selected, and the corresponding learning rate, number of network layers and regularization strength parameters are extracted to obtain the optimal hyperparameter configuration. The initial training model is retrained using the optimal hyperparameter configuration to obtain the model with optimized parameters.

13. The method according to claim 1, characterized in that, The step of using the test set in the target domain adaptation dataset to perform performance evaluation on the target domain adaptation early warning model, and integrating the target domain adaptation early warning model into the online monitoring system when the performance evaluation result reaches a predetermined threshold, includes: The target domain adaptation warning model is comprehensively evaluated using the test set in the target domain adaptation dataset. The accuracy, precision, recall and F1 score are calculated and compared with a predetermined threshold to obtain a performance evaluation report. The detection performance and reliability of the target domain adaptive early warning model on different types of abnormal events are evaluated by confidence analysis, confusion matrix and ROC curve, potential weaknesses are identified and a reliability analysis report is obtained; The target domain adaptive early warning model is encapsulated into a standardized software module that includes data preprocessing, feature extraction, and anomaly prediction functions. A model interface specification is designed to obtain a deployable early warning model software package. The deployable early warning model software package is integrated into the online monitoring system of the wastewater treatment plant, and data access, early warning thresholds and alarm methods are configured to obtain a complete early warning system; Develop a visual interface to display water quality fingerprint data, anomaly warning results and confidence levels in real time, support historical data backtracking and trend analysis, and obtain a warning result visualization module; The design incorporates a continuous update mechanism for the target domain adaptive early warning model. This mechanism involves periodically collecting new water quality data and feedback information, and employing an incremental learning method to update the parameters of the target domain adaptive early warning model, thereby achieving continuous improvement in its performance.

14. A rapid construction system for a water quality fingerprint early warning model of a wastewater treatment plant, characterized in that, include: The source domain data acquisition and preprocessing module is used to acquire the original water quality fingerprint data and water quality abnormal event label data of the source domain sewage treatment plant. After associating and labeling the original water quality fingerprint data and the water quality abnormal event label data, it is preprocessed to obtain the source domain training dataset. The source domain early warning basic model training module is used to construct a source domain early warning basic model containing a feature extraction network and a classifier network based on the source domain training dataset, and to train the source domain early warning basic model to obtain the trained source domain early warning basic model. The target domain data acquisition and processing module is used to collect short-term water quality fingerprint data from the wastewater treatment plant in the target domain, process the short-term water quality fingerprint data according to the preprocessing process, and obtain the target domain adapted dataset. The domain-adaptive feature extraction module is used to use the feature extraction network in the trained source domain early warning base model as a feature extractor, and to process the source domain training dataset and the target domain adaptation dataset respectively to obtain the source domain feature distribution representation and the target domain feature distribution representation; the difference between the source domain feature distribution representation and the target domain feature distribution representation is reduced by the domain-adaptive method to obtain the domain-adaptive feature extractor; The target domain model training module is used to reconstruct the classifier network based on the domain-adaptive feature extractor, and train the reconstructed classifier network using the target domain adaptation dataset to obtain the target domain adaptive early warning model. The model deployment and integration module is used to evaluate the performance of the target domain adaptation early warning model using the test set in the target domain adaptation dataset. When the performance evaluation result reaches a predetermined threshold, the target domain adaptation early warning model is integrated into the online monitoring system.