Abnormal data detection method for water control machine
By constructing a spatiotemporal causal graph and introducing a counterfactual reasoning mechanism, the water control machine anomaly detection method solves the problem in existing technologies that cannot distinguish between real faults and changes in user behavior. It achieves high-precision, adaptive anomaly detection, reduces false alarm rate, and improves detection accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-04-03
AI Technical Summary
Existing methods for detecting anomalies in water control systems cannot effectively distinguish between genuine malfunctions and changes in user behavior, resulting in a high false alarm rate and an inability to dynamically adapt to changes in user water usage habits, thus affecting detection accuracy.
By constructing a spatiotemporal causal graph, using graph neural networks to learn water use behavior patterns, and introducing a counterfactual reasoning mechanism to distinguish between changes in legitimate user water use behavior and real malfunctions, spatiotemporal graph convolutional networks are used for anomaly detection.
It improves the detection capability for low-flow-rate, long-term abnormal events, reduces the false alarm rate, achieves adaptive detection of changes in user behavior, and enhances the accuracy and reliability of detection.
Smart Images

Figure CN121786667A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent water management and anomaly detection technology, and in particular to a method for detecting abnormal data of water control machines. Background Technology
[0002] Currently, the safe and stable operation of urban water supply networks is the cornerstone of ensuring people's livelihood and social development. Timely detection and accurate location of abnormal events in the network (such as leaks, pipe bursts, and water theft) are among the core challenges in building smart water systems. To achieve this goal, relevant technologies mainly rely on multi-dimensional time-series data collected by sensors such as flow and pressure deployed in the network, and analyze this data using data-driven models. These technologies can be broadly categorized into three types: methods based on statistical process control (SPC), such as Shewhart control charts and cumulative sum control charts; methods based on traditional machine learning, such as support vector machines (SVM) and isolated forests; and methods based on deep learning that have emerged in recent years, particularly autoencoder models built using recurrent neural networks (RNNs), long short-term memory networks (LSTMs), or graph neural networks (GNNs). The core idea of these methods is to learn the patterns or baselines of "normal" water use behavior at the data level and identify anomalies by calculating the deviation of the current data from this baseline (such as reconstruction error).
[0003] Regarding the aforementioned technologies, the inventors believe they all suffer from a critical, inherent flaw: the models' understanding of "normal" behavior is static, lacking the ability to analyze the root causes of abnormal events, thus failing to effectively distinguish between "real-world fault anomalies" and "changes in user behavior." Once trained, existing models solidify their understanding of normal patterns. However, in the real world, users' water usage habits are not static; they may undergo significant and lasting changes due to factors such as changes in family members, seasonal variations (e.g., summer gardening irrigation), and altered lifestyles. When these new, historically unprecedented normal water usage patterns occur, existing models, unable to understand the rationale behind these changes, inevitably misidentify them as "anomalies" deviating from the normal baseline, leading to numerous false alarms. This high false alarm rate severely weakens the reliability and practical value of the detection system, causing "alarm fatigue" among maintenance personnel, potentially overlooking truly urgent faults such as pipeline leaks. Therefore, a detection method that can dynamically adapt to changes in user behavior and intelligently analyze the root causes of anomalies is urgently needed. Summary of the Invention
[0004] The purpose of this invention is to provide a method for detecting abnormal data of water control machines, which aims to solve the problem that existing technologies have difficulty in detecting silent anomalies with low flow rates and long durations, and cannot effectively distinguish between real equipment failures and changes in users' legitimate water use behavior, resulting in insufficient detection accuracy.
[0005] To achieve the above objectives, the present invention provides the following technical solution: A method for detecting abnormal data from water control machines involves constructing discrete water usage events into a graph structure with spatiotemporal and causal relationships. A graph neural network is used to learn normal water usage behavior patterns, and a counterfactual reasoning mechanism is introduced to intelligently correct potential anomalies, thereby achieving high-precision and adaptive detection of abnormal water control machine data. The method specifically includes the following steps: Step 1: Acquire multi-source data from the water control machine and process the multi-source data into a water usage event sequence.
[0006] First, raw time-series data, including flow rate, pressure, and valve status, is acquired from the water control system. To facilitate pattern recognition, this invention does not directly process the raw numerical sequence but transforms it into a discrete sequence of water usage events with clear semantics. Specifically, the continuous data stream is segmented into a series of structured water usage events using preset rules or unsupervised segmentation algorithms. Each water usage event e... i It can be represented as a tuple: e i =(τ i ,a i ,t i ); Where, τ i Event type is a classification label that characterizes the nature of an event, such as traffic initiation, stable traffic, and sudden pressure drop. a i This is an attribute vector for an event, containing a quantitative description of the event, such as average flow rate, duration, etc. t i This is the timestamp of the event.
[0007] Step 2: Based on the water usage event sequence, construct a spatiotemporal causal graph representing user water usage behavior.
[0008] To deeply explore the underlying logic of water use behavior, this invention elevates a one-dimensional event sequence into a spatiotemporal causal graph G rich in structural information. t =(V t ,ε t ).
[0009] In this diagram, the node set V t It consists of the aforementioned water use events.
[0010] edge set ε t This characterizes the complex relationships between events and is defined by a weighted adjacency matrix A.
[0011] The weighted adjacency matrix is formed by weighted summation of different relation submatrices: A=αA temp +βA causal +γA ctx ; in: A temp It is a temporal adjacency matrix, used to represent the chronological order of events.
[0012] A causal It is a causal adjacency matrix, whose weights are determined by a pre-trained causal inference module. Generation aims to capture the causal logic between events, such as the "valve opening" event being the cause of the "flow increase" event.
[0013] A ctx It is a context adjacency matrix used to connect events with similar external context information (such as both occurring at night), providing background for behavioral patterns.
[0014] α, β, γ are adjustable weighting coefficients.
[0015] Through this step, isolated data points are organized into a structured whole that fully reflects the temporal sequence, causal relationship, and contextual logic.
[0016] Step 3: Process the spatiotemporal causal graph using a spatiotemporal graph convolutional network to calculate an initial anomaly score representing the current water use behavior.
[0017] This invention employs a Spatiotemporal Graph Convolutional Network (FSTGCN) to model the spatiotemporal causal graph. First, using a graph sequence generated from massive historical normal water usage data, a baseline model of normal water usage behavior is established through training that minimizes reconstruction loss. This baseline model can deeply understand the normal water usage patterns of a specific user in different contexts.
[0018] Once new water usage data is acquired and a corresponding spatiotemporal causal graph is constructed, it is input into a pre-trained baseline model of normal water usage behavior. The model attempts to reconstruct the input graph, and the difference between the reconstructed graph and the input graph, i.e., the reconstruction error, is used as the initial anomaly score S. anomaly The fraction can be calculated using the following formula: Among them, V new It is the node set of the newly generated graph, x v It is the original feature vector of node v. These are the feature vectors reconstructed by the model. A high initial anomaly score indicates that the current water usage behavior deviates from the learned normal pattern.
[0019] Step 4: When the initial anomaly score exceeds a preset threshold, a counterfactual graph is generated based on preset counterfactual assumptions, and the counterfactual anomaly score of the counterfactual graph is calculated using the spatiotemporal graph convolutional network.
[0020] To avoid misjudging legitimate changes in user behavior as malfunctions, this invention introduces a counterfactual reasoning mechanism. When a high initial anomaly score triggers a potential anomaly warning, the system does not immediately issue an alarm, but instead initiates this step.
[0021] First, the system will generate a set of reasonable counterfactual assumptions {H}. k Each hypothesis represents a possible legitimate change in a user's water usage habits, such as "the user has installed a new garden irrigation system".
[0022] Subsequently, for each hypothesis H k The graph structure of the previously generated high-anomaly-score spatiotemporal causal graph is virtually modified, for example, by adding a normal causal subgraph representing "timed irrigation" to the graph, thereby generating a corresponding counterfactual graph G′. k .
[0023] Finally, each counterfactual graph G′ k The data is then input into the same baseline model of normal water use behavior, and its reconstruction error is calculated to obtain the corresponding counterfactual anomaly score S′. k .
[0024] Step 5: Determine whether there is an anomaly based on the initial anomaly score and the counterfactual anomaly score.
[0025] The final decision of this invention integrates the results of preliminary testing and counterfactual correction. The decision logic is as follows: If in all counterfactual anomaly scores {S′ k If at least one score is below a preset threshold, it indicates that a reasonable counterfactual hypothesis can successfully "explain" the seemingly abnormal water usage behavior. In this case, the system determines that the event is a change in user behavior.
[0026] Conversely, if all counterfactual anomaly scores are not lower than the preset threshold, this indicates that even if all possibilities of legitimate changes in user behavior have been considered, the current water usage pattern is still abnormal. In this case, the system determines that the event is a genuine fault anomaly, such as a pipe leak or equipment damage.
[0027] Furthermore, once a change in user behavior is identified and confirmed by the user, the system can update the baseline model of normal water use behavior based on the adopted counterfactual hypothesis. This allows the model to adapt to changes in user behavior and avoid similar false alarms in future detections.
[0028] In summary, the present invention has at least one of the following beneficial technical effects: 1. This invention constructs discrete water usage event sequences into a spatiotemporal causal graph containing temporal and causal edges, and utilizes a spatiotemporal graph convolutional network to analyze the graph structure patterns, thus changing the detection method that relies on instantaneous data values or simple statistical thresholds. This method can identify anomalies from the inherent logic and temporal evolution of water usage events. It can still effectively identify events with insignificant flow values but abnormal causal relationships or behavioral patterns (such as continuous small flow rates generated before valve opening), thereby improving the detection capability for low-flow-rate, long-duration anomaly events.
[0029] 2. This invention introduces a verification step based on counterfactual assumptions after the initial anomaly score exceeds a threshold. This step generates a counterfactual graph and recalculates the counterfactual anomaly score, achieving secondary screening of potential anomalies. This method can effectively distinguish between anomalies caused by genuine equipment failures and pattern biases caused by legitimate changes in user water usage habits (such as the addition of irrigation equipment). Only when the anomaly score remains high after counterfactual correction is it determined to be a genuine failure, thereby reducing the false alarm rate caused by changes in user behavior.
[0030] 3. This invention incorporates an update step into the baseline model of normal water use behavior after a change in user behavior is detected. This step integrates the new, legitimate water use behavior pattern into the user's personalized baseline model based on counterfactual assumptions adopted and confirmed by the system. This mechanism enables the detection method to adapt to changes in individual users' water use habits, continuously optimizes its detection benchmark, avoids repeated false alarms for the same legitimate behavior change, and improves the accuracy and specificity of the detection model during long-term operation. Attached Figure Description
[0031] Figure 1 This is a schematic diagram of the overall process of a water control machine abnormal data detection method according to the present invention; Figure 2 This is a schematic diagram of the event-based processing of water usage time-series data according to the present invention; Figure 3 This is a schematic diagram illustrating the mapping of water use event sequences to graph nodes according to the present invention; Figure 4 This is a schematic diagram of the spatiotemporal causal graph edge construction of the present invention; Figure 5 This is a schematic diagram of the spatiotemporal graph convolutional network structure of the present invention; Figure 6 This is a schematic diagram of the training process for the baseline model of normal water use behavior of the present invention; Figure 7 This is a schematic diagram illustrating the online calculation of the initial anomaly score according to the present invention; Figure 8 This is a schematic diagram of counterfactual reasoning and graph generation in the present invention; Figure 9 This is a schematic diagram illustrating the final decision-making and adaptive update process of the present invention; Figure 10 This is a schematic diagram of the overall architecture of the adaptive intelligent water anomaly detection system of the present invention; Figure 11 This is a schematic diagram of the hardware structure of the intelligent water anomaly detection device of the present invention; Figure 12 This is an overall flowchart of the adaptive intelligent water anomaly detection method of the present invention. Detailed Implementation
[0032] The following is in conjunction with the appendix Figure 1 -Appendix Figure 12 The present invention will be further described in detail below; See attached document Figure 1 , Figure 1 This is a flowchart illustrating a method for detecting abnormal data from a water control machine according to an embodiment of the present invention. The present invention provides a method for detecting abnormal data from a water control machine, and a specific embodiment of this method may include the following steps: In one embodiment, the method first performs the acquisition and synchronization of multi-source heterogeneous data. Specifically, for a specific user identifier u, multi-dimensional time-series data is collected from the water control machine hardware or its associated data management system within a preset time window. This data forms the basis for subsequent analysis.
[0033] The multi-source data can specifically be: traffic time-series data F = {f1, f2, ..., f...} T Pressure time series data P = {p1, p2, ..., p} T}, and the valve state sequence V={v1,v2,...,v T} Where T is the total number of data points within the time window. These data sequences are time-aligned, meaning that at the same timestamp t, the corresponding flow value f can be obtained. t Pressure value p t and valve status v t .
[0034] To ensure the quality of the raw data, preprocessing is necessary before proceeding to subsequent steps. Missing values in the data sequence can be filled using linear interpolation or nearest-neighbor methods. Random noise or high-frequency spikes can be smoothed using moving average filters or Gaussian filters to obtain a data sequence that better reflects actual water usage trends.
[0035] Numerical data from different sources, such as flow rate and pressure, exhibit significant differences in their physical dimensions and numerical ranges. To eliminate the impact of these differences on subsequent model processing, the numerical data sequences need to be normalized. In one embodiment, the Min-Max Normalization method is used to linearly map the data to the [0,1] interval. The calculation formula is as follows: Where, x′ norm x is the normalized data value; x is the original data value; x max and x min These are the maximum and minimum values of the data sequence within the current processing window, respectively. After this step, all numerical data are placed on a uniform scale.
[0036] After completing the above steps of data collection, cleaning, synchronization, and normalization, the system obtains a clean and standardized multidimensional data matrix for a specific user within a preset time window, providing high-quality data input for the next step of water event processing.
[0037] See attached document Figure 2 , Figure 2 This is a schematic diagram illustrating the event-based processing of water usage time-series data according to an embodiment of the present invention. After completing the acquisition and synchronization of multi-source data, the method continues to perform the following steps: To transform numerical time-series data into structured information that is easier to analyze for patterns, this embodiment performs event-based processing on the preprocessed data sequence. The core of this step is to segment and identify the continuous data stream into a series of discrete water usage events with clear semantics based on its inherent behavioral patterns, ultimately generating a water usage event sequence. Where N is the total number of events in the sequence.
[0038] Each water usage event e i Each is defined as a structured tuple, in the form of: e i =(τ i ,a i ,t i ); Among them, t i This is the timestamp of the event. τ i This is the event type, a discrete classification label used to qualitatively describe the nature of the water use event. i It is an event attribute vector used to quantitatively describe the key features of the event.
[0039] Event type τ iThe specific categories are predefined and may include, but are not limited to: flow initiation, flow cessation, stable flow, flow pulse, pressure drop, and pressure recovery. These types cover typical water usage behavior segments.
[0040] Event attribute vector a i The dimensions and specific content depend on the corresponding event type τ i For example, for an event of the "steady flow" type, its attribute vector may include the average flow value, duration, and cumulative water consumption of the event; for an event of the "pressure drop" type, its attribute vector may include the magnitude and rate of pressure drop.
[0041] Event identification and segmentation can be achieved by setting a series of rules. For example, when the normalized flow value f′ t From below the start-up threshold θ low A "traffic initiation" event is identified when the traffic value rises above this threshold. A stable threshold θ is defined as a period of time (ΔT) during which the standard deviation of the traffic value's fluctuation range is less than the standard deviation of the stability threshold. stable If a time period is identified as a "stable flow" event, its corresponding attribute vector is calculated. By combining judgment rules for dimensions such as real-time values, rates of change, and durations of data such as flow and pressure, continuous data streams can be completely segmented into discrete event sequences.
[0042] By performing the above event processing steps, the original multidimensional data stream, which was previously difficult to analyze directly, is effectively transformed into a structured event sequence carrying high-level semantic information. This sequence clearly describes the order, type, and specific quantitative characteristics of various water usage behaviors of users over a period of time, providing the necessary input for subsequent construction of a spatiotemporal causal graph.
[0043] See attached document Figure 3 , Figure 3 This is a schematic diagram of the mapping from a water use event sequence to graph nodes according to an embodiment of the present invention. After generating the water use event sequence in the aforementioned steps, the method continues to perform the following steps: To leverage graph structures for in-depth analysis of user water usage behavior, this embodiment uses the water usage event sequence generated in the previous step. Mapped to a spacetime causal graph G t =(V t ,ε t The node set V t Specifically, each water usage event e in the sequence i Each is considered an independent node v in the graph. i V t ={v1,v2,...,v N}
[0044] In order for the graph model to perform mathematical operations and feature extraction on nodes, it is necessary to perform mathematical operations and feature extraction on each node v. i Define an initial feature vector This feature vector is related to the water use event e. i =(τ i ,a i ,t i The numerical representation of the event. In one embodiment, the initial feature vector is formed by concatenating the event's type encoding vector and the event's attribute vector.
[0045] Event type τ i It is a discrete category label that needs to be converted into a numerical form. This embodiment uses one-hot encoding for the conversion. If the system predefines M different event types, then the event type τ i It is encoded as an M-dimensional vector c i The value is 1 only in the dimension corresponding to the event type, and 0 in all other dimensions.
[0046] Therefore, node v i initial feature vector It can be constructed in the following ways: Where concat(·) represents the vector concatenation operation, c i It is event type τ i The M-dimensional vector a obtained after one-hot encoding i This is the attribute vector of the event itself. Through this step, each node obtains an initial numerical representation that fully reflects its qualitative type and quantitative characteristics, providing input for the subsequent computation of the spatiotemporal graph convolutional network.
[0047] See attached document Figure 4 , Figure 4 This is a schematic diagram of spatiotemporal causal graph edge construction according to an embodiment of the present invention. After the graph nodes are defined, the method continues to perform the following steps: To fully characterize the complex dependencies between various water usage event nodes, this embodiment defines the edge set ε of the graph. t This is used to construct the graph structure. These edge relationships are ultimately represented numerically by a comprehensive weighted adjacency matrix A. This adjacency matrix describes the relationship between any two nodes v in the graph. i and v j The type and strength of the connections between them.
[0048] In one embodiment, the weighted adjacency matrix A is formed by merging multiple sub-matrices representing different relationships through a weighted summation. The specific calculation formula is as follows: A=αA temp +βA causal +γA ctx ; Among them, A temp A causal and A ctx These are the temporal adjacency matrix, the causal adjacency matrix, and the contextual adjacency matrix, respectively. α, β, and γ are preset weighting coefficients used to adjust the relative importance of different types of relationships.
[0049] The temporal adjacency matrix A temp This is used to represent the direct chronological relationship of water use events over time. In a specific implementation, its matrix elements (A) temp ) ij The definition is: if event e j It is the event immediately following event e in the event sequence. i The event that occurred, then (A) temp ) ij =1; otherwise, (A temp ) ij =0. This matrix captures the basic sequence of water usage behavior.
[0050] The causal adjacency matrix A causal Used to represent potential causal relationships between events. This matrix consists of a separate causal inference module. Generate. This module is configured to receive any pair of water usage events (e i ,e j ) eigenvectors As input, it outputs a scalar value in the range [0,1], representing the event e. i It is event e j The confidence level of the cause. Therefore, matrix elements The causal inference module can be a feedforward neural network or gradient boosting decision tree model that has been pre-trained on a dataset labeled with causal relationships.
[0051] The context adjacency matrix A ctx This is used to connect events that are not necessarily adjacent in time but share the same external context information. External context information may include the time period in which the event occurred (e.g., early morning, late night), date type (e.g., weekday, weekend), or season. If event e... i and event e j If they share the same preset context label, then matrix elements (A) ctx ) ij =1; otherwise, 0. This matrix provides background information for the model to understand water usage patterns in a specific scenario.
[0052] Through the above steps, the system successfully transforms a one-dimensional event sequence into a multi-relationship graph represented by a weighted adjacency matrix A. This graph structure not only includes the temporal sequence of events but also incorporates the inherent causal logic of behaviors and the influence of the external environment, providing a structured input for subsequent high-order pattern recognition using spatiotemporal graph convolutional networks.
[0053] See attached document Figure 5 , Figure 5 This is a schematic diagram of a spatiotemporal graph convolutional network structure used in an embodiment of the present invention. After constructing the spatiotemporal causal graph, the method uses a spatiotemporal graph convolutional network to process the graph in order to establish a baseline model of normal water use behavior.
[0054] In one embodiment, the spatiotemporal graph convolutional network employed is an encoder-decoder structure. This network consists of multiple stacked spatio-temporal blocks. The encoder portion is responsible for mapping the node features of the input spatiotemporal causal graph to a low-dimensional latent representation vector, while the decoder portion is responsible for reconstructing the original node features from this latent representation vector.
[0055] Each spatiotemporal convolutional module consists of a graph convolutional layer and a temporal convolutional layer connected in series. This structure is designed to extract feature patterns of water use behavior from both spatial and temporal dimensions simultaneously.
[0056] Graph convolutional layers are responsible for feature aggregation on the spatial structure of the graph, that is, aggregating information about each node and its neighboring nodes. For the l-th graph convolutional layer, the transformation process of its node features can be represented by the following formula: Among them, H (l) H is the node feature matrix of the l-th layer. (l+1) This is the output node feature matrix. σ is a non-linear activation function, such as the ReLU function. W (l) It is the trainable weight matrix of this layer. This is the matrix obtained after normalizing the weighted adjacency matrix A generated in the preceding steps. Its specific calculation method is as follows: in I N It is the identity matrix. yes The diagonal linear dimension matrix, whose diagonal elements This operation aims to capture the structured dependencies between events.
[0057] The temporal convolutional layer follows the graph convolutional layer and is responsible for capturing the evolution of features over time. This layer modulates the feature matrix H output by the graph convolutional layer. (l+1) One-dimensional convolution operations are performed along the time axis. By using convolution kernels with specific sizes and dilation rates, this layer can effectively aggregate water use event features across different time spans, thereby identifying temporal behavioral patterns.
[0058] The encoder consists of several stacked spatiotemporal convolutional modules, taking the initial node feature matrix X as input and outputting a compact latent representation vector Z. The decoder has a structure symmetric to the encoder, but employs upsampling or transposed convolution operations. Its input is the latent representation vector Z, and its goal is to output the reconstructed node feature matrix. The reconstructed node feature matrix The dimension of the feature matrix is the same as that of the initial node feature matrix X, and it is used for subsequent calculation of anomaly scores.
[0059] See attached document Figure 6 , Figure 6 This is a schematic diagram of the training process for a baseline model of normal water use behavior according to an embodiment of the present invention. After defining the structure of the spatiotemporal graph convolutional network, the method continues to establish a baseline model capable of representing normal water use behavior through a specific training process.
[0060] In one embodiment, the goal of training the baseline model is to enable it to accurately reconstruct a spatiotemporal causal graph representing normal water use behavior. To this end, a training dataset is required, which contains only spatiotemporal causal graph samples corresponding to normal water use periods extracted from historical data and confirmed to contain no known anomalies.
[0061] The training process is as follows: Spatiotemporal causal graphs of normal water use behavior are extracted in batches from the training dataset. For each input graph G, its initial node feature matrix is X, and its adjacency matrix is A. This graph is input into the aforementioned spatiotemporal graph convolutional network composed of an encoder and a decoder. After forward propagation computation, the reconstructed node feature matrix is obtained. To drive the model to learn normal patterns, a loss function is needed to quantify the difference between the input features and the reconstructed features. This embodiment adopts... Mean Squared Error (MSE) is used as the reconstruction loss function. The calculation formula is as follows: Where N is the total number of nodes in the graph currently being processed. It is the i-th node v in the graph i The initial feature vector, It is the feature vector of the corresponding node obtained after network reconstruction. This represents the square of the L2 norm. The smaller this loss function value, the higher the accuracy of the model's reconstruction of the input graph.
[0062] The model is trained through an iterative optimization process. In each iteration, the average loss for a batch of samples is calculated, and the gradient of the loss function with respect to all trainable weight parameters in the network is computed using the backpropagation algorithm. Subsequently, a gradient descent optimizer (such as the Adam optimizer) is used to update these weight parameters based on the computed gradients.
[0063] Repeat the above iterative process until the model's loss function converges to a preset low level, or until a preset number of training epochs are reached. After training, the weight parameters in the network are fixed, and the spatiotemporal graph convolutional network at this point constitutes the "normal water use behavior baseline model." This model has the ability to reconstruct normal water use patterns with low error, laying the foundation for calculating the initial anomaly score in the subsequent online detection phase.
[0064] See attached document Figure 8 , Figure 8 This is a schematic diagram of the counterfactual reasoning triggering and hypothesis generation process according to an embodiment of the present invention. After calculating the initial anomaly score in the aforementioned steps, the method continues to perform the following steps to identify potential anomalies.
[0065] In one embodiment, the system uses the initial anomaly score S calculated in the previous step. anomaly With a preset exception trigger threshold θ trigger The threshold can be compared. This threshold can be set based on historical data statistical analysis or by the system administrator according to the actual application scenario.
[0066] If and only if S anomaly >θ trigger At this point, the system determines that the current water usage behavior is suspected of deviating from the normal pattern and triggers a counterfactual reasoning process. The system will not directly determine it as a real fault at this moment, but will initiate a verification step to distinguish between a real fault and a legitimate change in behavior.
[0067] The core of this verification step is to introduce a set of pre-set counterfactual assumptions {H}. k These counterfactual assumptions are stored in a counterfactual assumption library, each assumption H k Each quantifies a possible, legitimate, non-faulty change scenario in a user's water usage habits.
[0068] The assumptions in the counterfactual hypothesis library may include: Hypothesis H1: Represents a user adding a periodically water-using appliance (such as a dishwasher or washing machine). This hypothesis is specifically defined as an event subgraph pattern with specific water usage, duration, and frequency of occurrence.
[0069] Hypothesis H2: Characterizes a user initiating a new, long-lasting water use activity (such as garden irrigation or pool filling). This hypothesis is specifically defined as an event pattern characterized by long duration and low to medium flow rate.
[0070] Hypothesis H3: Represents how seasonal variations lead to changes in overall water use behavior (e.g., an overall increase in water use frequency during the summer). This hypothesis is specifically defined as a rule for globally adjusting the frequency or attribute values of specific types of events (e.g., "steady flow") in the graph.
[0071] When the counterfactual reasoning process is triggered, the system selects one or more relevant counterfactual hypotheses from the hypothesis library. The purpose of selection is to attempt to "explain" the currently observed high anomaly scores using these legitimate variations. This set of selected hypotheses will be used in the next step to generate the corresponding counterfactual graph.
[0072] See attached document Figure 9 , Figure 9 This is a schematic diagram of a counterfactual diagram generation process according to an embodiment of the present invention. After selecting one or more counterfactual hypotheses to be tested from the hypothesis library, the method continues to perform the following steps.
[0073] In one embodiment, the system targets each selected counterfactual hypothesis H. k For the original spatiotemporal causal graph G that was judged to have a high outlier score new =(X new A new Perform a structural modification to generate a corresponding counterfactual graph G′ k =(X′) k ,A′ k The goal of this generation process is to transform hypothesis H... k The legally permissible changes described are visualized based on the original image.
[0074] The structured modifications can target the node features of the graph, the edge connections, or both simultaneously. The specific modification operations are determined by the corresponding counterfactual assumption H. k It is determined by its inherent definition.
[0075] If we assume H k If the changes involve quantitative characteristics of the event, the modification will apply to the node feature matrix X. newFor example, for a hypothesis describing "the addition of a specific model of washing machine," this hypothesis would include parameters such as the standard flow rate and duration of operation of that washing machine. When generating the counterfactual graph, the system will... new The system locates event nodes that match the pattern (such as a high-traffic "stable traffic" event) and modifies the corresponding attribute values (such as average traffic value) in their node feature vectors to the assumed standard values. This process generates a new node feature matrix X′. k .
[0076] If we assume H k If the changes involve alterations to the relationship patterns between events, the modifications will apply to the weighted adjacency matrix A. new For example, given a hypothesis describing "timed irrigation of the new yard," this hypothesis might define a new strong causal relationship: a "valve opening" event necessarily leads to a long-term "steady flow" event. When generating the counterfactual graph, the system will consider the causal adjacency matrix A... causal In this process, the connection weight between the two corresponding event nodes is adjusted to a high-confidence value defined by the hypothesis. This process generates a new weighted adjacency matrix A′. k .
[0077] By implementing the above modifications, each counterfactual hypothesis H k Both are used to generate a unique counterfactual graph G′ k This newly generated graph can be understood as a revised version of the original observed behavior, depicting "if the user's behavior changes as assumed H..." k Therefore, the observed water use events map should present this scenario. These generated counterfactual maps will serve as input for the next reassessment.
[0078] See attached document Figure 10 , Figure 10 This is a schematic diagram of the final decision-making process according to an embodiment of the present invention. After generating a corresponding counterfactual graph for each hypothesis to be tested, the method continues to perform the following steps.
[0079] In one embodiment, the system will generate each counterfactual graph G′ k The data is sequentially input into a previously trained baseline model of normal water use behavior with fixed network parameters. This model performs a forward propagation calculation for each counterfactual graph, receiving its node feature matrix X′. k and adjacency matrix A′ k It outputs a reconstructed counterfactual node feature matrix.
[0080] Subsequently, for each counterfactual graph G′ kThe system calculates a corresponding counterfactual anomaly score S′. k This score is used to measure performance when the counterfactual assumption H is applied. k After correction, the new water use behavior map matches the normal pattern to a certain degree. The calculation formula is the same as the initial outlier score calculation formula: Among them, V′ k It is the node set of the k-th counterfactual graph, with a total number of nodes |V′. k | It is node v′ in the graph i eigenvectors, It is the output vector obtained by reconstructing the feature vector of this node by the baseline model.
[0081] After calculating the counterfactual anomaly scores {S′} corresponding to all tested hypotheses k After that, the system proceeds to the final decision-making step. This step assigns a counterfactual anomaly score S′ to each counterfactual anomaly. k With a preset acceptance threshold θ accept Compare them.
[0082] The final decision logic is as follows: If among all the calculated counterfactual anomaly scores, there exists at least one S′ k Satisfying condition S′ k ≤θ accept If the initial high anomaly score is determined to be caused by a legitimate change in user behavior, the system will output the final decision as "user behavior change" and can record which counterfactual hypothesis H is at fault. k The abnormal scores were successfully reduced to an acceptable range.
[0083] If none of the calculated counterfactual anomaly scores satisfy the above condition, that is, for all k, S′ k >θ accept This indicates that no pre-defined assumption of legitimate behavioral change can reasonably explain the currently observed data pattern. In this case, the system determines the anomaly to be either a genuine fault requiring attention or an unexpected water usage event. The final decision output by this method at this point is "genuine fault anomaly".
[0084] See attached document Figure 11 , Figure 11 This is a schematic diagram of a model adaptive update triggering process according to an embodiment of the present invention. After making a final decision on potential anomalies, the method includes an adaptive update mechanism for the model, which first performs the following steps to determine whether an update is triggered.
[0085] In one embodiment, whether or not the model adaptive update is triggered depends directly on the final decision output by the counterfactual reasoning and decision-making module in the previous stage. The goal of this mechanism is to update the baseline model only when the system confirms that the user has generated a new, legitimate water usage behavior pattern.
[0086] The specific trigger condition is set as follows: the model update process is initiated if and only if the final decision result is "change in user behavior". This decision result indicates that the initial high anomaly score is not caused by device malfunction or data error, but can be reasonably explained by one or more pre-set counterfactual assumptions.
[0087] More specifically, the following two prerequisites must be met to trigger this update process: A newly generated water use behavior graph G new Its initial abnormal score S anomaly The abnormal triggering threshold θ is higher than the preset threshold. trigger .
[0088] In the subsequent counterfactual verification process, there exists at least one counterfactual hypothesis H. k The generated counterfactual graph G′ k Its corresponding counterfactual anomaly score S′ k The threshold value is lower than or equal to the preset acceptance threshold θ. accept .
[0089] If the final decision is "real fault anomaly," the model update process will not be triggered. This setting ensures the purity of the baseline model and prevents real fault data from being incorrectly learned as normal patterns. This avoids reducing the model's ability to detect future real faults. In this case, the system only reports the anomaly without adjusting any model parameters using the corresponding anomaly data graph.
[0090] See attached document Figure 12 , Figure 12 This is a schematic diagram of a baseline model update process according to an embodiment of the present invention. When the adaptive update condition of the model is triggered, the method continues to perform the following steps to adjust the baseline model of normal water use behavior.
[0091] In one embodiment, the system first selects from one or more successful counterfactual graphs (i.e., their counterfactual anomaly scores S′). k ≤θ accept In this process, a graph is selected to update the model. A specific selection rule is to choose the counterfactual graph that minimizes the counterfactual anomaly score. This graph is denoted as the target update graph G′. target Its node feature matrix and adjacency matrix are X′ respectively. target and A′ target .
[0092] The baseline model is not retrained from scratch, but rather fine-tuned based on the existing model parameters. The selected target image G′ is then updated. target As a single sample or a small batch of samples, it is input into the currently solidified baseline model.
[0093] The goal of model updating is to minimize the model's reconstruction error of the target updated map. This process uses the same loss function as the initial training, namely the mean squared error loss. Among them, V′ target It is the target update graph G′ target The set of nodes. It is node v′ in the graph i The feature vectors are the inputs for the fine-tuning steps. It is the output vector obtained by reconstructing the feature vector of this node by the baseline model.
[0094] The system calculates using the backpropagation algorithm. The gradients of the current model's network weights are calculated, and a gradient descent optimizer (such as Adam) is used to update the weights in one or a few iterations. In this update step, the learning rate is set to a lower value than the learning rate used in the initial training phase. This setting aims to ensure that the model retains as much learned knowledge about past normal behavior as possible while learning new patterns, preventing catastrophic forgetting.
[0095] After completing the above fine-tuning steps, the network parameters of the baseline model are updated. In this way, new user behavior patterns identified as legitimate by the counterfactual reasoning process are formally integrated into the normal behavior baseline model. This reduces the likelihood of these new behavior patterns being incorrectly identified as abnormal in the future, thus enabling the detection model to adapt to changes in user behavior.
[0096] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for detecting abnormal data from a water control machine, comprising the following steps: S1. Acquire multi-source data from the water control unit and process the multi-source data into a water usage event sequence; S2. Based on the water usage event sequence, construct a spatiotemporal causal graph representing user water usage behavior, wherein the nodes of the spatiotemporal causal graph are water usage events, and the edges include at least temporal edges established based on the event time sequence relationship and causal edges established through the causal inference module. S3. The spatiotemporal causal graph is processed using a spatiotemporal graph convolutional network to calculate an initial anomaly score representing the current water use behavior; S4. When the initial anomaly score exceeds a preset threshold, a counterfactual graph is generated based on a preset counterfactual assumption, and the counterfactual anomaly score of the counterfactual graph is calculated using the spatiotemporal graph convolutional network. S5. Determine whether there is an anomaly based on the initial anomaly score and the counterfactual anomaly score.
2. The method for detecting abnormal data of a water control machine according to claim 1, characterized in that, In step S1, the step of processing the multi-source data into a water use event sequence is as follows: The multi-source data is segmented and transformed into structured water use events containing event type, event attribute vector, and timestamp.
3. The method for detecting abnormal data of a water control machine according to claim 1, characterized in that, The edges of the spatiotemporal causal graph are represented by a weighted adjacency matrix, which is a weighted combination of matrices representing the temporal edges and the causal edges, respectively.
4. The method for detecting abnormal data of a water control machine according to claim 3, characterized in that, The edges of the spatiotemporal causal graph are further defined as context edges, which are used to connect water use events with preset external context information, and the weighted adjacency matrix is further composed of a weighted combination of matrices representing the context edges.
5. The method for detecting abnormal data of a water control machine according to claim 1, characterized in that, In step S4, the step of calculating the counterfactual anomaly score of the counterfactual graph using a spatiotemporal graph convolutional network specifically includes: A baseline model of normal water use behavior, trained on historical normal water use data, is pre-established using the aforementioned spatiotemporal graph convolutional network. The spatiotemporal causal graph generated from the new water usage data is then input into the baseline model of normal water usage behavior, and the reconstruction error of the baseline model is used as the counterfactual anomaly score.
6. The method for detecting abnormal data of a water control machine according to claim 1, characterized in that, In step S4, the counterfactual assumption is a preset scenario that represents a legitimate change in the user's water usage habits.
7. The method for detecting abnormal data of a water control machine according to claim 1, characterized in that, In step S5, the step of determining whether an anomaly exists specifically includes: If at least one of the counterfactual anomaly scores is lower than the preset threshold, it is determined as a change in user behavior; If all the counterfactual anomaly scores are not lower than the preset threshold, then they are determined to be genuine fault anomalies.
8. The method for detecting abnormal data of a water control machine according to claim 1, characterized in that, When a change in user behavior is detected, the water control machine abnormal data detection method further performs the following steps: The baseline model of normal water use behavior is updated based on the adopted counterfactual assumptions.