Deep learning-based water quality anomaly detection method for water purifier

Through the combination of space-time graph neural network and improved cuckoo search algorithm, a water quality abnormality detection method is constructed, which solves the problem of insufficient multi-sensor fusion and dynamic optimization capabilities in the existing technology, and realizes efficient and accurate water quality abnormality detection and intelligent alarm.

CN120470511AInactive Publication Date: 2025-08-12HUNSDON PURIFIED WATER EQUIP (CHINA) CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510983335.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-17
Publication Date
2025-08-12
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When facing multi-dimensional data mutations, abnormal trend spread or local pollution, it is difficult to accurately identify abnormal states that are not significantly mutations but have trend characteristics. The existing models lack efficient feature modeling and dynamic optimization capabilities in multi-sensor fusion, large-scale data flow processing and local abnormal propagation trend recognition.

Method used

The spatial and temporal graph neural network model is used to combine the improved cuckoo search algorithm to construct a graph structure of multiple monitoring units. The spatial correlation and temporal evolution characteristics of water quality data are extracted through the graph convolution network and the time convolution unit, and the hyperparameters are optimized with adaptive step size and mixed perturbation strategies to realize water quality abnormality detection.

Benefits of technology

Real-time identification and intelligent alarm for water quality abnormalities of the water purifier is realized, and detection accuracy, adaptability and response speed are improved. It is suitable for intelligent processing and analysis scenarios of heterogeneous data of multiple sensors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120470511A_ABST
    Figure CN120470511A_ABST
Patent Text Reader

Abstract

The invention discloses a water purifier water quality anomaly detection method based on deep learning. The method comprises the following steps: S1, collecting multi-dimensional index data of water quality sensors inside and outside a water purifier; s2, constructing a spatial adjacency matrix according to the physical distribution of the water quality sensors; s3, a time-space diagram neural network model is adopted to generate water quality time-space feature representation; s4, calculating the abnormal score of the water quality state based on the reconstruction error and the prediction error; s5, optimizing hyper-parameters of the water quality anomaly detection model by adopting an improved cuckoo search algorithm; s6, updating the positions of cuckoo individuals; and S7, applying the optimized water quality anomaly detection model to anomaly detection of the real-time water quality data flow. According to the method, the time-space diagram neural network model is combined, the cuckoo search algorithm and the anomaly detection and evaluation technology are improved, and deep learning-based water quality anomaly detection of the water purifier is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of water quality monitoring, and in particular to a method for detecting water quality anomalies in a water purifier based on deep learning. Background Art

[0002] In the field of water purification equipment, ensuring the safety and stability of effluent water quality has always been a core issue. In recent years, with the increasing requirements for water purity and abnormal response capabilities in household, industrial, and medical scenarios, how to achieve efficient, accurate, and real-time water quality anomaly monitoring and identification within water purifiers has become a research hotspot. In particular, faced with the interactive influence of multiple complex water quality factors, such as pH, conductivity, turbidity, temperature, and organic matter content, which fluctuate at a microscopic time scale, traditional detection methods that rely on single-indicator threshold judgments or fixed rule models can no longer meet the dynamic, accurate, and scalable requirements of practical applications.

[0003] Existing water quality monitoring systems for water purifiers typically use a sensor-based single-point data collection and fixed threshold judgment mechanism. This involves deploying water quality sensors to collect data on indicators such as pH, conductivity, total dissolved solids, temperature, and residual chlorine. A fixed safety threshold is then set for each indicator, triggering an alarm when a particular indicator exceeds the set value. However, this approach relies on human experience to set thresholds, making parameter adjustment difficult and lacking robustness. It often fails to accurately judge complex situations such as sudden changes in multidimensional data, the spread of abnormal trends, or localized contamination, and is prone to false positives or omissions. It is particularly difficult to identify abnormal conditions that are not significant mutations but exhibit trend characteristics.

[0004] To improve identification accuracy, some studies have introduced machine learning-based methods for water quality anomaly detection. These methods primarily include supervised classification models such as support vector machines, K-nearest neighbors, decision trees, and random forests. These methods train water quality classification models offline and then classify new data or identify anomalies online. While this improves judgment accuracy to a certain extent, these methods still suffer from three significant issues: First, they require a large amount of labeled data for model training, while anomaly data on water quality is often difficult to obtain; second, the models have limited generalization capabilities and poor adaptability to environmental changes, requiring frequent retraining and parameter adjustments; and third, most methods lack the ability to jointly model time series and spatial structures, failing to capture the dynamic temporal and spatial dependencies between multiple sensors.

[0005] With the development of graph neural networks and deep time series modeling technologies, some research has begun to attempt to incorporate spatiotemporal information into water quality anomaly detection. For example, a sensor deployment map is constructed, and graph convolutional networks and long-short-term memory networks are combined to extract spatial dependencies and temporal variation features, enabling node-level anomaly identification. However, these approaches still face several challenges: First, graph structure modeling is often statically defined and lacks the ability to dynamically interact with real-time data streams; Secondly, the selection of hyperparameters during model training is highly sensitive and lacks an effective adaptive tuning mechanism. Thirdly, the anomaly scoring mechanism of most models still relies on simple reconstruction error threshold judgment, which cannot effectively integrate predictive ability, spatial differences and historical behavioral characteristics. The anomaly scoring lacks contextual consistency and dynamic adjustment capabilities, which can easily cause recognition delays or misjudgments.

[0006] Furthermore, existing literature on optimizing model performance often employs parameter adjustment methods based on grid search, Bayesian optimization, or genetic algorithms. While these methods possess certain search capabilities, they suffer from low search efficiency and a high risk of reaching local optimality. In particular, they suffer from slow convergence and high computational resource consumption in high-dimensional spaces. While the traditional cuckoo search algorithm possesses strong global search capabilities, its fixed step size and single perturbation method can easily lead to slow search or convergence oscillation during optimization, and it lacks dynamic awareness and feedback of changing model performance trends.

[0007] Based on the above situation, existing technologies still have obvious deficiencies in the accuracy, generalization ability, adaptability, and real-time performance of water quality anomaly detection models, and are unable to meet the actual needs of smart water purification equipment for efficient water quality safety management. In particular, in key links such as multi-sensor fusion, large-scale data stream processing, identification of local anomaly propagation trends, and online model tuning, there is a lack of an end-to-end comprehensive solution with efficient feature modeling and dynamic optimization capabilities. Therefore, there is an urgent need for a new water quality anomaly detection method that can integrate multi-source water quality data, has graph structure expression capabilities and time series modeling capabilities, and introduces an adaptive intelligent optimization mechanism to improve detection accuracy, response speed, and model stability, and better apply it to real-time monitoring scenarios of smart water purifier systems.

[0008] Therefore, how to provide a method for detecting abnormal water quality in water purifiers based on deep learning is an urgent problem that needs to be solved by those skilled in the art. Summary of the Invention

[0009] One purpose of the present invention is to propose a method for detecting water quality anomalies in water purifiers based on deep learning. The present invention combines a spatiotemporal graph neural network model, an improved cuckoo search algorithm, and advanced anomaly detection and evaluation technology. By constructing a graph structure of multiple monitoring units, the graph convolutional network and the time convolution unit are used to extract the spatial correlation and temporal evolution characteristics in the water quality data, and comprehensively characterize the water quality status. The system design is based on a comprehensive anomaly scoring mechanism based on reconstruction error, prediction error, and spatial consistency, and optimizes the cuckoo search process through adaptive step size and mixed perturbation strategies, dynamically adjusting the key hyperparameters of the detection model to improve the model accuracy and convergence efficiency. This method can realize real-time identification and intelligent alarm of water quality anomalies in water purifiers, and has the advantages of high accuracy, strong adaptability, and fast response speed. It is suitable for intelligent processing and analysis scenarios of multi-sensor heterogeneous data.

[0010] A method for detecting abnormal water quality in a water purifier based on deep learning according to an embodiment of the present invention includes the following steps: S1, collect multi-dimensional indicator data of water quality sensors inside and outside the water purifier; S2, construct a spatial adjacency matrix based on the physical distribution of water quality sensors, and combine it with multidimensional indicator data to generate spatiotemporal graph structure data; S3. Based on the spatiotemporal graph structure data, a spatiotemporal graph neural network model is used to build a water quality anomaly detection model. The graph convolution operation is used to extract the spatial correlation features between nodes. The temporal convolution unit is combined to capture the dynamic characteristics of each node state over time, generating a spatiotemporal feature representation of water quality. S4, input the spatiotemporal characteristics of water quality into the anomaly detection submodule, and calculate the anomaly score of the water quality status based on the reconstruction error and the prediction error respectively; S5. Use the improved cuckoo search algorithm to optimize the hyperparameters of the water quality anomaly detection model. Configure an adaptive step size adjustment module and a mixed disturbance generation module for each cuckoo individual, initialize the population individuals, and perform search optimization based on the detection performance indicator of the water quality anomaly score on the validation set; S6. During the optimization process, the positions of cuckoo individuals are updated, some individuals with poor fitness are eliminated according to their fitness values, and new individuals are introduced to supplement the population; S7. Apply the optimized water quality anomaly detection model to anomaly detection of real-time water quality data streams, and output abnormal events based on the real-time detection results.

[0011] Optionally, the multidimensional indicator data specifically includes pH value, conductivity, turbidity, residual chlorine, and temperature.

[0012] Optionally, the hyperparameters specifically include the number of convolutional layers, feature dimensions, time window length, and anomaly score weighting coefficient.

[0013] Optionally, the S2 specifically includes: S21. Determine a water quality sensor node set, where the node set includes multiple water quality sensor nodes deployed inside and outside the water purifier; S22. Construct a spatial adjacency matrix based on the physical spatial distribution relationship of the water quality sensors. Any two elements in the spatial adjacency matrix represent whether there is a spatial connection relationship between the corresponding two water quality sensor nodes. If there is a connection, the corresponding position is one, otherwise it is zero; S23, collecting water quality index data of each water quality sensor node at multiple consecutive time points; S24, combining the multidimensional indicator data of all water quality sensor nodes within a preset time window into a time series feature matrix, where the feature matrix is water quality feature information of different water quality sensor nodes at different time points; S25. Construct spatiotemporal graph structure data based on the spatial adjacency matrix and the time series feature matrix. The spatiotemporal graph structure data includes a set of water quality sensor nodes, spatial connection relationships between water quality sensor nodes, and time series feature information of the water quality sensor nodes.

[0014] Optionally, the S3 specifically includes: S31. Using the spatiotemporal graph structure data as input, a water quality anomaly detection model is constructed; S32, perform a graph convolution operation on the feature matrix, use a graph convolution unit to extract the spatial structural relationship between monitoring units from the spatial adjacency matrix, and output a spatial feature representation; S33, performing normalization processing and activation function transformation on the spatial feature representation, and outputting the spatial feature representation after nonlinear transformation; S34, performing a temporal convolution operation on the spatial feature representation after the nonlinear transformation, using a one-dimensional temporal convolution kernel to perform convolution processing on the historical state of each monitoring unit along the time dimension, extracting the change trend in the time series, and outputting the temporal feature representation; S35. Fuse the spatial feature representation with the temporal feature representation to generate the final water quality spatiotemporal feature matrix, and use the attention weighting mechanism to calculate the fusion output: ; in, is the spatiotemporal characteristic matrix of water quality, is the channel index number, is the number of fusion channels, is the spatial feature transformation matrix under the kth channel, is the spatial feature representation after nonlinear transformation, is the time feature transformation matrix under the kth channel, It is the time feature representation and t is the time index.

[0015] Optionally, the S4 specifically includes: S41. In each time step, the water quality spatiotemporal feature matrix is mapped to each water quality sensor node, and an error recording unit is established for each water quality sensor node to record the reconstruction error and prediction error information of the water quality sensor node in the current time window; S42, respectively constructing a reconstruction network and a prediction network, obtaining a reconstruction feature vector and a prediction feature vector of the water quality sensor node based on the water quality spatiotemporal feature matrix, and obtaining the true feature of the next time step; S43. Calculate the abnormal score of the water quality status based on the water quality spatiotemporal feature matrix, the reconstructed feature vector, and the predicted feature vector: ; in, is the abnormality score, is the water quality spatiotemporal feature matrix, i is the index of the water quality sensor node, To reconstruct the eigenvector, is the actual water quality state of the node at time step t+1, is the predicted feature vector, is the set of adjacent nodes of node i, j is is the jth node in, 、 、 is the weighting coefficient, is the square of the Euclidean norm; S44, setting an abnormality score threshold of 0.75, when the abnormality score of the water quality sensor node exceeds the abnormality score threshold, it is determined that the water quality sensor node has water quality abnormality within the current time window; S45. All nodes that are judged to be abnormal are grouped into a water quality abnormal node set, and the corresponding water quality index type, abnormality occurrence time, and sensor spatial location are output.

[0016] Optionally, the S5 specifically includes: S51, initializing the population of the improved cuckoo search algorithm, setting the population size to the number of individuals in the population, and assigning an initial position and velocity to each cuckoo individual; S52: configuring a dynamic adaptive step-size adjustment module for each cuckoo individual, adjusting the step-size of the cuckoo individual in real time through an online learning mechanism, and dynamically calculating the step-size based on the historical performance of the cuckoo individual and the current search progress; S53. A hybrid perturbation generation module is configured for each cuckoo individual. The hybrid perturbation generation module combines local optimization and global optimization strategies to generate a perturbation solution. The local optimization adopts a Gaussian perturbation generation method, and the global optimization adopts a random perturbation generation method based on Levy flight to generate a new solution. S54. Search optimization is performed based on the detection performance indicator of the abnormal score of water quality status on the validation set.

[0017] Optionally, the S54 specifically includes: S541. Calculate the fitness of each cuckoo individual. The fitness function includes the abnormality score of the water quality status and the detection performance index on the validation set. A weighted combination of the two is used for comprehensive evaluation. Compared with the cuckoo search algorithm, the improved cuckoo search algorithm introduces an adaptive step size adjustment mechanism. The step size is dynamically adjusted based on the historical performance of each cuckoo individual and the current search progress: ; in, is the comprehensive evaluation score, For the The abnormality score of the water quality status of each cuckoo individual, The detection accuracy of each node is For the The detection speed of individual cuckoos, is the total number of individuals in the cuckoo population, 、 、 is the weighting coefficient, For the The number of nodes correctly identified as abnormal by cuckoo individuals, For the The number of nodes that are incorrectly marked as abnormal by the cuckoo individual, a is the abnormality score, For the cuckoo individuals; S542. Sort all individuals in the cuckoo population based on the comprehensive evaluation scores, record the cuckoo individual with the highest comprehensive evaluation score and the corresponding hyperparameter combination as the candidate optimal solution in this iteration; S543 , executing the optimization process of steps S51 to S54 until the optimal value of the comprehensive evaluation score changes by less than 0.0001 in several consecutive generations.

[0018] Optionally, the S6 specifically includes: S61. Calculate the fitness value for each cuckoo individual. The fitness value is calculated based on the abnormality score, accuracy, and detection speed of the water quality status: ; in, For the The fitness value of each cuckoo individual, 、 、 is the weighting coefficient, is a time window set, t is a time index, For nodes The spatiotemporal characteristic vector of water quality at time t, For nodes The reconstructed output vector at time t, For nodes The predicted output vector from time t to t+1, for The set of adjacent nodes of for For the nodes, is the square of the Euclidean norm, r is reconstruction, p is prediction, For the cuckoo individuals; S62. Sort the individuals in the cuckoo population according to the calculated fitness values, and eliminate individuals with fitness values less than 0.8 and remove them from the population; S63. Introduce new cuckoo individuals to replenish the population based on the number of eliminated individuals. For cuckoo individuals with a fitness greater than 1.1, guide them to make small, fine adjustments near the cuckoo individual with the highest fitness value. For individuals with a fitness less than 0.8, guide them to jump out of the local optimal area through large disturbances. The disturbance intensity is dynamically controlled based on the relative relationship between the current fitness of the cuckoo individual and the population mean. S64, recalculating the fitness value of the introduced new cuckoo individual and comparing it with the existing cuckoo individual. If the fitness value of the new cuckoo individual is better than that of the replaced cuckoo individual, the replacement operation is completed; S65, repeat steps S61 to S64 until the number of iterations reaches 100; Optionally, the S7 specifically includes: S71. Deploy the optimized water quality anomaly detection model on the data acquisition terminal to receive the multi-dimensional water quality data stream collected in real time by each node of the water purifier, and perform pre-processing and time series integration; S72. Input the pre-processed and time-series integrated water quality data into the water quality anomaly detection model to obtain an anomaly score for each monitoring unit, and compare it with a dynamic anomaly threshold constructed from the historical score distribution of the monitoring unit; S73. When the abnormality score of the monitoring unit exceeds the dynamic threshold of 0.82, it is marked as a suspected abnormal node and written into the abnormality memory pool of the monitoring unit; S74. Perform spatial propagation analysis on the suspected abnormal monitoring unit to determine whether the adjacent monitoring units in the spatiotemporal graph structure data also have abnormal scores within the time step. If the propagation path forms a continuous area, it is determined to be a potential pollution diffusion area; S75. Classify abnormal events and generate multi-dimensional alarm information including abnormal level, associated nodes, propagation direction, and recommended processing strategy; S76. Push multi-dimensional alarm information to the user end via the local terminal, automatically recommend response measures based on the alarm level, and automatically initiate key monitoring of input data in adjacent time periods; S77. If a monitoring unit has an abnormal state in multiple discontinuous time periods, analyze the abnormal periodicity from the monitoring unit abnormality memory pool and dynamically modify the abnormality score weight.

[0019] The beneficial effects of the present invention are: The deep learning-based water quality anomaly detection method for water purifiers proposed in the present invention has systematically optimized and improved the overall structure and key links to address the shortcomings of existing technologies, significantly enhancing the water purification equipment's ability to intelligently identify complex water quality anomalies. By introducing a spatiotemporal graph neural network model, it effectively integrates the spatial distribution relationship between sensors and the dynamic characteristics of the evolution of water quality indicators over time, solving the problems of traditional methods' inability to model multi-sensor associations and capture time trends, and improving the model's detection sensitivity to local pollution diffusion, trend-type changes, and sudden anomalies. Compared to single-point detection or static models, the present invention can achieve continuous modeling and dynamic characterization of water quality status, enhancing the detection system's adaptability to nonlinearity, water quality disturbances, and periodic changes.

[0020] Furthermore, this paper innovatively introduces an improved cuckoo search algorithm to adaptively optimize key hyperparameters in the water quality anomaly detection model. During the search process, cuckoo individuals are equipped with a dynamic step-size adjustment mechanism and a hybrid perturbation generation module, overcoming the shortcomings of traditional optimization algorithms, which suffer from slow convergence and proneness to local optima. During the optimization process, a multi-dimensional comprehensive evaluation function is constructed, integrating indicators such as anomaly score, detection accuracy, and detection efficiency for fitness assessment. This allows model optimization to focus not only on accuracy but also on real-time performance and stability. Ultimately, the optimal parameter configuration is output to enhance the model's practical performance in real-world scenarios.

[0021] Combining these two technical advantages, this invention implements an efficient, accurate, and scalable solution for detecting water quality anomalies in water purifiers, capable of real-time sensing, anomaly scoring, and dynamic alerting of multi-source water quality data. This system not only possesses strong detection capabilities and robustness, but also boasts excellent algorithm adaptability and engineering feasibility, adapting to the needs of diverse water purification equipment and complex application environments. It provides technical support for ensuring terminal water safety and enhancing the intelligence level of intelligent water purification systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings: Figure 1 This is a flow chart of a water quality anomaly detection method for a water purifier based on deep learning proposed by the present invention; Figure 2 This is a schematic diagram of a water quality anomaly detection method for a water purifier based on deep learning proposed by the present invention; Figure 3 This is a data flow diagram of the water quality anomaly detection method for water purifiers based on deep learning proposed by the present invention. DETAILED DESCRIPTION

[0023] The present invention will now be described in further detail with reference to the accompanying drawings, which are simplified schematic diagrams that illustrate the basic structure of the present invention in a schematic manner.

[0024] refer to Figure 1-3 , a water quality anomaly detection method for a water purifier based on deep learning, comprising the following steps: S1, collect multi-dimensional indicator data of water quality sensors inside and outside the water purifier; S2, construct a spatial adjacency matrix based on the physical distribution of water quality sensors, and combine it with multidimensional indicator data to generate spatiotemporal graph structure data; S3. Based on the spatiotemporal graph structure data, a spatiotemporal graph neural network model is used to build a water quality anomaly detection model. The graph convolution operation is used to extract the spatial correlation features between nodes. The temporal convolution unit is combined to capture the dynamic characteristics of each node state over time, generating a spatiotemporal feature representation of water quality. S4, input the spatiotemporal characteristics of water quality into the anomaly detection submodule, and calculate the anomaly score of the water quality status based on the reconstruction error and the prediction error respectively; S5. Use the improved cuckoo search algorithm to optimize the hyperparameters of the water quality anomaly detection model. Configure an adaptive step size adjustment module and a mixed disturbance generation module for each cuckoo individual, initialize the population individuals, and perform search optimization based on the detection performance indicator of the water quality anomaly score on the validation set; S6. During the optimization process, the positions of cuckoo individuals are updated, some individuals with poor fitness are eliminated according to their fitness values, and new individuals are introduced to supplement the population; S7. Apply the optimized water quality anomaly detection model to anomaly detection of real-time water quality data streams, and output abnormal events based on the real-time detection results.

[0025] This paper uses an improved cuckoo search algorithm to optimize the hyperparameters of the water quality anomaly detection model. It combines graph convolution with temporal convolution to extract multidimensional spatiotemporal characteristics of water quality, and constructs a dynamic anomaly scoring mechanism to accurately identify the water quality status of water purifiers. It also optimizes model performance through adaptive step size and mixed perturbation mechanisms, improving the accuracy and real-time performance of anomaly detection.

[0026] In this embodiment, the multi-dimensional indicator data specifically include pH value, conductivity, turbidity, residual chlorine, and temperature.

[0027] This method collects pH, conductivity, turbidity, residual chlorine, and temperature to construct a high-dimensional water quality feature space. Using a graph neural network, it extracts the spatiotemporal dependencies between these indicators, enhancing the anomaly detection model's ability to characterize complex water quality states. This method effectively avoids misjudgments based on a single indicator, enabling the joint identification of multiple pollution sources and improving the accuracy and reliability of test results.

[0028] In this embodiment, the hyperparameters specifically include the number of convolutional layers, feature dimensions, time window length, and anomaly score weighting coefficient.

[0029] The proposed method optimizes hyperparameters, including the number of convolutional layers, feature dimension, time window length, and anomaly score weighting coefficient. By performing a global search in a high-dimensional parameter space using an improved cuckoo search algorithm, it achieves a joint optimization of the water quality anomaly detection model structure and scoring mechanism. This method automatically adjusts network depth and feature expression capabilities, balancing temporal perception granularity with scoring sensitivity, significantly improving the model's detection accuracy and generalization capabilities.

[0030] In this embodiment, S2 specifically includes: S21. Determine a water quality sensor node set, where the node set includes multiple water quality sensor nodes deployed inside and outside the water purifier; S22. Construct a spatial adjacency matrix based on the physical spatial distribution relationship of the water quality sensors. Any two elements in the spatial adjacency matrix represent whether there is a spatial connection relationship between the corresponding two water quality sensor nodes. If there is a connection, the corresponding position is one, otherwise it is zero; S23, collecting water quality index data of each water quality sensor node at multiple consecutive time points; S24, combining the multidimensional indicator data of all water quality sensor nodes within a preset time window into a time series feature matrix, where the feature matrix is water quality feature information of different water quality sensor nodes at different time points; S25. Construct spatiotemporal graph structure data based on the spatial adjacency matrix and the time series feature matrix. The spatiotemporal graph structure data includes a set of water quality sensor nodes, spatial connection relationships between water quality sensor nodes, and time series feature information of the water quality sensor nodes.

[0031] This method constructs a spatial graph structure composed of multiple sensor nodes inside and outside the water purifier and integrates water quality indicator data within a continuous time window to generate a complete spatiotemporal graph structure. The spatial adjacency matrix captures the physical connections between sensors, and combined with the time series feature matrix to construct the spatiotemporal graph input, providing a precise structured modeling foundation for subsequent graph neural networks. This method effectively enhances the organization and spatiotemporal consistency of water quality information, improving the model's ability to represent complex dynamic pollution characteristics and detection accuracy.

[0032] In this embodiment, S3 specifically includes: S31. Using the spatiotemporal graph structure data as input, a water quality anomaly detection model is constructed; S32, perform a graph convolution operation on the feature matrix, use a graph convolution unit to extract the spatial structural relationship between monitoring units from the spatial adjacency matrix, and output a spatial feature representation; S33, performing normalization processing and activation function transformation on the spatial feature representation, and outputting the spatial feature representation after nonlinear transformation; S34, performing a temporal convolution operation on the spatial feature representation after the nonlinear transformation, using a one-dimensional temporal convolution kernel to perform convolution processing on the historical state of each monitoring unit along the time dimension, extracting the change trend in the time series, and outputting the temporal feature representation; S35. Fuse the spatial feature representation with the temporal feature representation to generate the final water quality spatiotemporal feature matrix, and use the attention weighting mechanism to calculate the fusion output: ; in, is the spatiotemporal characteristic matrix of water quality, is the channel index number, is the number of fusion channels, is the spatial feature transformation matrix under the kth channel, is the spatial feature representation after nonlinear transformation, is the time feature transformation matrix under the kth channel, It is the time feature representation and t is the time index.

[0033] Based on spatiotemporal graph data, this method combines graph convolution with temporal convolution operations to extract spatial correlations and historical state change trends between monitoring units, enhancing feature expression capabilities through nonlinear transformations. An attention weighting mechanism is introduced during the fusion phase to dynamically adjust the importance of spatial and temporal features, enabling refined interaction between multi-channel features. This method effectively improves the water quality anomaly detection model's ability to model local pollution diffusion and trend changes, enhancing the model's expression accuracy and anomaly detection sensitivity.

[0034] In this embodiment, the S4 specifically includes: S41. In each time step, the water quality spatiotemporal feature matrix is mapped to each water quality sensor node, and an error recording unit is established for each water quality sensor node to record the reconstruction error and prediction error information of the water quality sensor node in the current time window; S42, respectively constructing a reconstruction network and a prediction network, obtaining a reconstruction feature vector and a prediction feature vector of the water quality sensor node based on the water quality spatiotemporal feature matrix, and obtaining the true feature of the next time step; S43. Calculate the abnormal score of the water quality status based on the water quality spatiotemporal feature matrix, the reconstructed feature vector, and the predicted feature vector: ; in, is the abnormality score, is the water quality spatiotemporal feature matrix, i is the index of the water quality sensor node, To reconstruct the eigenvector, is the actual water quality state of the node at time step t+1, is the predicted feature vector, is the set of adjacent nodes of node i, j is is the jth node in, 、 、 is the weighting coefficient, is the square of the Euclidean norm; S44, setting an abnormality score threshold of 0.75, when the abnormality score of the water quality sensor node exceeds the abnormality score threshold, it is determined that the water quality sensor node has water quality abnormality within the current time window; S45. All nodes that are judged to be abnormal are grouped into a water quality abnormal node set, and the corresponding water quality index type, abnormality occurrence time, and sensor spatial location are output.

[0035] This invention builds a dual reconstruction and prediction network, performs bidirectional error modeling on the spatiotemporal characteristics of water quality, and calculates multidimensional anomaly scores based on the differences in adjacent node states. By setting dynamic thresholds for anomaly detection, it effectively distinguishes local disturbances from actual pollution events. The system accurately labels the time, location, and type of anomaly nodes, enabling fine-grained water quality anomaly identification. This mechanism enhances the detection model's sensitivity and ability to discriminate between multiple types of anomalies, improving the accuracy and interpretability of anomaly identification.

[0036] In this embodiment, the S5 specifically includes: S51, initializing the population of the improved cuckoo search algorithm, setting the population size to the number of individuals in the population, and assigning an initial position and velocity to each cuckoo individual; S52: configuring a dynamic adaptive step-size adjustment module for each cuckoo individual, adjusting the step-size of the cuckoo individual in real time through an online learning mechanism, and dynamically calculating the step-size based on the historical performance of the cuckoo individual and the current search progress; S53. A hybrid perturbation generation module is configured for each cuckoo individual. The hybrid perturbation generation module combines local optimization and global optimization strategies to generate a perturbation solution. The local optimization adopts a Gaussian perturbation generation method, and the global optimization adopts a random perturbation generation method based on Levy flight to generate a new solution. S54. Search optimization is performed based on the detection performance indicator of the abnormal score of water quality status on the validation set.

[0037] This paper initializes a cuckoo population and configures an adaptive step size and mixed perturbation module for each individual, achieving dynamic adjustment and multi-scale exploration in the optimization search process. It also introduces Gaussian perturbation and the Levy flight strategy to effectively balance local fine-grained search with global exploration capabilities. Optimizing the detection performance of water quality anomaly scores on a validation set, the model improves search efficiency and accuracy in a multidimensional parameter space, ensuring the optimal configuration of the water quality anomaly detection model.

[0038] In this embodiment, the S54 specifically includes: S541. Calculate the fitness of each cuckoo individual. The fitness function includes the abnormality score of the water quality status and the detection performance index on the validation set. A weighted combination of the two is used for comprehensive evaluation. Compared with the cuckoo search algorithm, the improved cuckoo search algorithm introduces an adaptive step size adjustment mechanism. The step size is dynamically adjusted based on the historical performance of each cuckoo individual and the current search progress: ; in, is the comprehensive evaluation score, For the The abnormality score of the water quality status of each cuckoo individual, The detection accuracy of each node is For the The detection speed of individual cuckoos, is the total number of individuals in the cuckoo population, 、 、 is the weighting coefficient, For the The number of nodes correctly identified as abnormal by cuckoo individuals, For the The number of nodes that are incorrectly marked as abnormal by the cuckoo individual, a is the abnormality score, For the cuckoo individuals; S542. Sort all individuals in the cuckoo population based on the comprehensive evaluation scores, record the cuckoo individual with the highest comprehensive evaluation score and the corresponding hyperparameter combination as the candidate optimal solution in this iteration; S543 , executing the optimization process of steps S51 to S54 until the optimal value of the comprehensive evaluation score changes by less than 0.0001 in several consecutive generations.

[0039] This method constructs a comprehensive fitness function based on water quality anomaly scores and detection performance, incorporating a dynamic step-size adjustment mechanism to enhance the search strategy's responsiveness to individual historical performance. By introducing multidimensional evaluation metrics of precision and speed, the optimization process balances detection accuracy and efficiency. The algorithm tracks the individual with the best overall score during successive iterations and uses a threshold for minimal score changes as the termination criterion, effectively improving the optimization convergence speed and parameter search stability.

[0040] In this embodiment, S6 specifically includes: S61. Calculate the fitness value for each cuckoo individual. The fitness value is calculated based on the abnormality score, accuracy, and detection speed of the water quality status: ; in, For the The fitness value of each cuckoo individual, 、 、 is the weighting coefficient, is a time window set, t is a time index, For nodes The spatiotemporal characteristic vector of water quality at time t, For nodes The reconstructed output vector at time t, For nodes The predicted output vector from time t to t+1, for The set of adjacent nodes of for For the nodes, is the square of the Euclidean norm, r is reconstruction, p is prediction, For the cuckoo individuals; S62. Sort the individuals in the cuckoo population according to the calculated fitness values, and eliminate individuals with fitness values less than 0.8 and remove them from the population; S63. Introduce new cuckoo individuals to replenish the population based on the number of eliminated individuals. For cuckoo individuals with a fitness greater than 1.1, guide them to make small, fine adjustments near the cuckoo individual with the highest fitness value. For individuals with a fitness less than 0.8, guide them to jump out of the local optimal area through large disturbances. The disturbance intensity is dynamically controlled based on the relative relationship between the current fitness of the cuckoo individual and the population mean. S64, recalculating the fitness value of the introduced new cuckoo individual and comparing it with the existing cuckoo individual. If the fitness value of the new cuckoo individual is better than that of the replaced cuckoo individual, the replacement operation is completed; S65, repeat steps S61 to S64 until the number of iterations reaches 100; This method constructs a multi-factor fitness function by integrating anomaly scores, detection accuracy, and detection speed, enabling detailed evaluation and dynamic ranking of cuckoo individuals. By setting fitness thresholds, poor-quality individuals are eliminated, and high-fitness individuals are guided to perform localized, refined searches, while low-fitness individuals undergo significant jumps, enhancing global exploration capabilities. As new individuals are introduced, their fitness is updated in real time, replacing poor-quality individuals. After 100 iterations, a stable optimal solution is achieved, significantly improving the efficiency and accuracy of model optimization.

[0041] In this embodiment, the S7 specifically includes: S71. Deploy the optimized water quality anomaly detection model on the data acquisition terminal to receive the multi-dimensional water quality data stream collected in real time by each node of the water purifier, and perform pre-processing and time series integration; S72. Input the pre-processed and time-series integrated water quality data into the water quality anomaly detection model to obtain an anomaly score for each monitoring unit, and compare it with a dynamic anomaly threshold constructed from the historical score distribution of the monitoring unit; S73. When the abnormality score of the monitoring unit exceeds the dynamic threshold of 0.82, it is marked as a suspected abnormal node and written into the abnormality memory pool of the monitoring unit; S74. Perform spatial propagation analysis on the suspected abnormal monitoring unit to determine whether the adjacent monitoring units in the spatiotemporal graph structure data also have abnormal scores within the time step. If the propagation path forms a continuous area, it is determined to be a potential pollution diffusion area; S75. Classify abnormal events and generate multi-dimensional alarm information including abnormal level, associated nodes, propagation direction, and recommended processing strategy; S76. Push multi-dimensional alarm information to the user end via the local terminal, automatically recommend response measures based on the alarm level, and automatically initiate key monitoring of input data in adjacent time periods; S77. If a monitoring unit has an abnormal state in multiple discontinuous time periods, analyze the abnormal periodicity from the monitoring unit abnormality memory pool and dynamically modify the abnormality score weight.

[0042] This invention deploys an optimized detection model to achieve efficient access and dynamic analysis of real-time water quality data. It builds dynamic thresholds based on historical scores to enhance the adaptability of anomaly identification. It also identifies potential diffusion areas through anomaly memory pools and spatial propagation analysis. The system generates multidimensional alerts based on anomaly levels, automatically recommends response measures, supports key monitoring strategies, and dynamically modifies scoring results through periodic analysis, significantly enhancing the system's intelligent response and risk prediction capabilities in variable water quality environments.

[0043] Example 1: In order to verify the feasibility of the present invention in implementation, the present invention was applied to the remote monitoring and water quality abnormality early warning system of water purification equipment under a certain city's tap water company. A secondary water supply system of a residential community in the city that has been in operation for more than three years and has typical urban water quality fluctuation characteristics was selected as the experimental scenario.

[0044] The residential complex consists of three high-rise residential buildings, each equipped with a monitoring system consisting of five water quality sensors installed at the water inlet, water tank outlet, first-floor user access point, mid-level floor user access point, and top-floor user access point. Each sensor collects real-time data on pH, conductivity, turbidity, residual chlorine, and water temperature, sampling every five minutes. The system will operate for two months, from December 1, 2024, to January 31, 2025.

[0045] Traditional solutions use fixed-threshold detection strategies, which frequently result in false positives and missed negatives in this scenario. For example, a natural drop in residual chlorine due to falling temperatures is often misinterpreted as abnormal water quality, while slow pH changes caused by long-term sedimentation in water tanks go undetected. This invention effectively addresses these issues by constructing a spatiotemporal sensor graph, leveraging graph neural networks to extract spatial features and temporal trends, and combining this with an improved cuckoo search algorithm to dynamically optimize the detection model's hyperparameters.

[0046] During the deployment process, we divided the system into training and deployment phases. During the training phase, we collected water quality data from December 1, 2024, to January 10, 2025, using 80% of the data as the training set and 20% as the validation set. During this period, we recorded the system's accuracy, recall, response time, and anomaly recognition performance before and after optimization. The optimized system had 3 convolutional layers, 12 time windows, and anomaly score weighting coefficients set to [0.4, 0.4, 0.2]. After automatic search using the cuckoo search algorithm, the system converged in 84 rounds, achieving a final fitness score of 0.936, surpassing the 0.873 obtained with manual parameter tuning.

[0047] During the deployment phase, which ran from January 11 to 31, 2025, the system automatically monitored the status of each sensor, calculating anomaly scores and triggering alarms in real time. During this period, the system identified 16 anomalies, 12 of which were confirmed to be true pollution events. The remaining four were fluctuations in indicators caused by changes in water pressure, which, while not pollution-related, were still valuable to monitor.

[0048] Table 1 Comparison of optimization effects of water quality anomaly detection for water purifiers based on deep learning ; Table 1 demonstrates that this method, in real-world scenarios, not only effectively reduces missed and false alarms, improves the sensitivity and discriminability of the detection model, but also significantly enhances the system's response speed and processing efficiency, demonstrating its high practicality and scalability. Its spatiotemporal graph structure modeling capabilities and adaptive optimization mechanism provide a new solution for intelligent water quality monitoring. If extended to urban pipe networks, hospital water supplies, or campus water systems, this approach will have even broader application prospects.

[0049] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, who makes equivalent replacements or changes based on the technical solution and inventive concept of the present invention, should be covered by the scope of protection of the present invention.

Claims

1. A water quality anomaly detection method for a water purifier based on deep learning, characterized in that: The steps include: S1, collect multi-dimensional indicator data of water quality sensors inside and outside the water purifier; S2, construct a spatial adjacency matrix based on the physical distribution of water quality sensors, and combine it with multidimensional indicator data to generate spatiotemporal graph structure data; S3. Based on the spatiotemporal graph structure data, a spatiotemporal graph neural network model is used to build a water quality anomaly detection model. The graph convolution operation is used to extract the spatial correlation features between nodes. The temporal convolution unit is combined to capture the dynamic characteristics of each node state over time, generating a spatiotemporal feature representation of water quality. S4, input the spatiotemporal characteristics of water quality into the anomaly detection submodule, and calculate the anomaly score of the water quality status based on the reconstruction error and the prediction error respectively; S5. Use the improved cuckoo search algorithm to optimize the hyperparameters of the water quality anomaly detection model. Configure an adaptive step size adjustment module and a mixed disturbance generation module for each cuckoo individual, initialize the population individuals, and perform search optimization based on the detection performance indicator of the water quality anomaly score on the validation set; S6. During the optimization process, the positions of cuckoo individuals are updated, some individuals with poor fitness are eliminated according to their fitness values, and new individuals are introduced to supplement the population; S7. Apply the optimized water quality anomaly detection model to anomaly detection of real-time water quality data streams, and output abnormal events based on the real-time detection results.

2. The method for detecting abnormal water quality in a water purifier based on deep learning according to claim 1, characterized in that: The multi-dimensional indicator data specifically include pH value, conductivity, turbidity, residual chlorine, and temperature.

3. The method for detecting abnormal water quality in a water purifier based on deep learning according to claim 1, characterized in that: The hyperparameters specifically include the number of convolutional layers, feature dimensions, time window length, and anomaly score weighting coefficient.

4. The method for detecting abnormal water quality in a water purifier based on deep learning according to claim 1, characterized in that: The S2 specifically includes: S21. Determine a water quality sensor node set, where the node set includes multiple water quality sensor nodes deployed inside and outside the water purifier; S22. Construct a spatial adjacency matrix based on the physical spatial distribution relationship of the water quality sensors. Any two elements in the spatial adjacency matrix represent whether there is a spatial connection relationship between the corresponding two water quality sensor nodes. If there is a connection, the corresponding position is one, otherwise it is zero; S23, collecting water quality index data of each water quality sensor node at multiple consecutive time points; S24, combining the multidimensional indicator data of all water quality sensor nodes within a preset time window into a time series feature matrix, where the feature matrix is water quality feature information of different water quality sensor nodes at different time points; S25. Construct spatiotemporal graph structure data based on the spatial adjacency matrix and the time series feature matrix. The spatiotemporal graph structure data includes a set of water quality sensor nodes, spatial connection relationships between water quality sensor nodes, and time series feature information of the water quality sensor nodes.

5. The method for detecting abnormal water quality in a water purifier based on deep learning according to claim 1, characterized in that: The S3 specifically includes: S31. Using the spatiotemporal graph structure data as input, a water quality anomaly detection model is constructed; S32, perform a graph convolution operation on the feature matrix, use a graph convolution unit to extract the spatial structural relationship between monitoring units from the spatial adjacency matrix, and output a spatial feature representation; S33, performing normalization processing and activation function transformation on the spatial feature representation, and outputting the spatial feature representation after nonlinear transformation; S34, performing a temporal convolution operation on the spatial feature representation after the nonlinear transformation, using a one-dimensional temporal convolution kernel to perform convolution processing on the historical state of each monitoring unit along the time dimension, extracting the change trend in the time series, and outputting the temporal feature representation; S35. Fuse the spatial feature representation with the temporal feature representation to generate the final water quality spatiotemporal feature matrix, and use the attention weighting mechanism to calculate the fusion output: ; in, is the spatiotemporal characteristic matrix of water quality, is the channel index number, is the number of fusion channels, is the spatial feature transformation matrix under the kth channel, is the spatial feature representation after nonlinear transformation, is the time feature transformation matrix under the kth channel, It is the time feature representation and t is the time index.

6. The method for detecting abnormal water quality in a water purifier based on deep learning according to claim 1, characterized in that: The S4 specifically includes: S41. In each time step, the water quality spatiotemporal feature matrix is mapped to each water quality sensor node, and an error recording unit is established for each water quality sensor node to record the reconstruction error and prediction error information of the water quality sensor node in the current time window; S42, respectively constructing a reconstruction network and a prediction network, obtaining a reconstruction feature vector and a prediction feature vector of the water quality sensor node based on the water quality spatiotemporal feature matrix, and obtaining the true feature of the next time step; S43. Calculate the abnormal score of the water quality status based on the water quality spatiotemporal feature matrix, the reconstructed feature vector, and the predicted feature vector: ; in, is the abnormality score, is the water quality spatiotemporal feature matrix, i is the index of the water quality sensor node, To reconstruct the eigenvector, is the actual water quality state of the node at time step t+1, is the predicted feature vector, is the set of adjacent nodes of node i, j is is the jth node in, 、 、 is the weighting coefficient, is the square of the Euclidean norm; S44, setting an abnormality score threshold of 0.75, when the abnormality score of the water quality sensor node exceeds the abnormality score threshold, it is determined that the water quality sensor node has water quality abnormality within the current time window; S45. All nodes that are judged to be abnormal are grouped into a water quality abnormal node set, and the corresponding water quality index type, abnormality occurrence time, and sensor spatial location are output.

7. The method for detecting abnormal water quality in a water purifier based on deep learning according to claim 1, characterized in that: The S5 specifically includes: S51, initializing the population of the improved cuckoo search algorithm, setting the population size to the number of individuals in the population, and assigning an initial position and velocity to each cuckoo individual; S52: configuring a dynamic adaptive step-size adjustment module for each cuckoo individual, adjusting the step-size of the cuckoo individual in real time through an online learning mechanism, and dynamically calculating the step-size based on the historical performance of the cuckoo individual and the current search progress; S53. A hybrid perturbation generation module is configured for each cuckoo individual. The hybrid perturbation generation module combines local optimization and global optimization strategies to generate a perturbation solution. The local optimization adopts a Gaussian perturbation generation method, and the global optimization adopts a random perturbation generation method based on Levy flight to generate a new solution. S54. Search optimization is performed based on the detection performance indicator of the abnormal score of water quality status on the validation set.

8. The method for detecting abnormal water quality in a water purifier based on deep learning according to claim 7, characterized in that: The S54 specifically includes: S541. Calculate the fitness of each cuckoo individual. The fitness function includes the abnormality score of the water quality status and the detection performance index on the validation set. A weighted combination of the two is used for comprehensive evaluation. Compared with the cuckoo search algorithm, the improved cuckoo search algorithm introduces an adaptive step size adjustment mechanism. The step size is dynamically adjusted based on the historical performance of each cuckoo individual and the current search progress: ; in, is the comprehensive evaluation score, For the The abnormality score of the water quality status of each cuckoo individual, The detection accuracy of each node is For the The detection speed of individual cuckoos, is the total number of individuals in the cuckoo population, 、 、 is the weighting coefficient, For the The number of nodes correctly identified as abnormal by cuckoo individuals, For the The number of nodes that are incorrectly marked as abnormal by the cuckoo individual, a is the abnormality score, For the cuckoo individuals; S542. Sort all individuals in the cuckoo population based on the comprehensive evaluation scores, record the cuckoo individual with the highest comprehensive evaluation score and the corresponding hyperparameter combination as the candidate optimal solution in this iteration; S543 , executing the optimization process of steps S51 to S54 until the optimal value of the comprehensive evaluation score changes by less than 0.0001 in several consecutive generations.

9. The method for detecting abnormal water quality in a water purifier based on deep learning according to claim 1, characterized in that: The S6 specifically includes: S61. Calculate the fitness value for each cuckoo individual. The fitness value is calculated based on the abnormality score, accuracy, and detection speed of the water quality status: ; in, For the The fitness value of each cuckoo individual, 、 、 is the weighting coefficient, is a time window set, t is a time index, For nodes The spatiotemporal characteristic vector of water quality at time t, For nodes The reconstructed output vector at time t, For nodes The predicted output vector from time t to t+1, for The set of adjacent nodes of for For the nodes, is the square of the Euclidean norm, r is reconstruction, p is prediction, For the cuckoo individuals; S62. Sort the individuals in the cuckoo population according to the calculated fitness values, and eliminate individuals with fitness values less than 0.8 and remove them from the population; S63. Introduce new cuckoo individuals to replenish the population based on the number of eliminated individuals. For cuckoo individuals with a fitness greater than 1.1, guide them to make small, fine adjustments near the cuckoo individual with the highest fitness value. For individuals with a fitness less than 0.8, guide them to jump out of the local optimal area through large disturbances. The disturbance intensity is dynamically controlled based on the relative relationship between the current fitness of the cuckoo individual and the population mean. S64, recalculating the fitness value of the introduced new cuckoo individual and comparing it with the existing cuckoo individual. If the fitness value of the new cuckoo individual is better than that of the replaced cuckoo individual, the replacement operation is completed; S65. Repeat steps S61 to S64 until the number of iterations reaches 100.

10. The method for detecting abnormal water quality in a water purifier based on deep learning according to claim 1, characterized in that: The S7 specifically includes: S71. Deploy the optimized water quality anomaly detection model on the data acquisition terminal to receive the multi-dimensional water quality data stream collected in real time by each node of the water purifier, and perform pre-processing and time series integration; S72. Input the pre-processed and time-series integrated water quality data into the water quality anomaly detection model to obtain an anomaly score for each monitoring unit, and compare it with a dynamic anomaly threshold constructed from the historical score distribution of the monitoring unit; S73. When the abnormality score of the monitoring unit exceeds the dynamic threshold of 0.82, it is marked as a suspected abnormal node and written into the abnormality memory pool of the monitoring unit; S74. Perform spatial propagation analysis on the suspected abnormal monitoring unit to determine whether the adjacent monitoring units in the spatiotemporal graph structure data also have abnormal scores within the time step. If the propagation path forms a continuous area, it is determined to be a potential pollution diffusion area; S75. Classify abnormal events and generate multi-dimensional alarm information including abnormal level, associated nodes, propagation direction, and recommended processing strategy; S76. Push multi-dimensional alarm information to the user end via the local terminal, automatically recommend response measures based on the alarm level, and automatically initiate key monitoring of input data in adjacent time periods; S77. If a monitoring unit has an abnormal state in multiple discontinuous time periods, analyze the abnormal periodicity from the monitoring unit abnormality memory pool and dynamically modify the abnormality score weight.

Citation Information

Cited By

  • Sudden infectious disease intelligent positioning system based on spatial-temporal distribution anomaly detection

    CN120636858A

  • Ore grinding system control method based on large model and cuckoo algorithm

    CN120891784A

  • Water dispenser water quality guarantee management control system and method thereof

    CN121187143A