Water level data anomaly detection method based on rule and neural network fusion
By embedding hydrological rule constraints into the LSTM model, the adaptability and data dependency issues of water level data detection in existing technologies are solved, enabling more efficient anomaly detection and improving the interpretability and detection accuracy of water level data.
Patent Information
- Application Number
- CN202610064065.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-19
- Publication Date
- 2026-03-20
AI Technical Summary
Existing methods for detecting anomalies in water level data suffer from poor adaptability and excessive reliance on data, making it difficult to effectively identify nonlinear and multi-correlated water level fluctuation anomalies in complex hydrological scenarios, and they are prone to missed detections or false detections.
We adopt a rule-based and neural network-based approach, which transforms the anomaly detection rules in the hydrological field into a differentiable constraint embedded LSTM model by constructing a rule-constrained LSTM model. By combining knowledge-driven and data-driven approaches, we improve the interpretability and accuracy of the detection results.
It improves the comprehensiveness and accuracy of anomaly detection in water level data, reduces the rate of missed detections and false detections, and provides high-quality hydrological decision support.
Smart Images

Figure CN121706023A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of hydrological data processing technology, and in particular relates to a method for detecting anomalies in water level data based on the fusion of rules and neural networks. It is applicable to the identification of anomalies in water level monitoring data in multiple scenarios such as river main streams, reservoirs, and coastal tide levels. Background Technology
[0002] Water level data serves as a core basis for hydrological monitoring, water conservancy project scheduling, water resource management, and disaster early warning; its quality directly impacts the accuracy of decision-making. However, during the collection and transmission of water level data, it is often affected by multiple factors such as complex environmental conditions, equipment failures, and transmission interference, resulting in abnormal data in the raw collected water level data.
[0003] Current methods for detecting anomalies in water level data are mainly divided into two categories: rule-based detection methods and data-driven detection methods. These two methods have the following obvious shortcomings: (1) Rule-based detection methods can only detect defined situations, have poor adaptability to complex hydrological scenarios, are difficult to handle nonlinear and multi-correlated water level fluctuation anomalies, and are easily affected by gradual anomalies caused by sensor failures. (2) Data-driven detection methods are overly dependent on data quality. When anomalies exist in the data, the model may learn these anomalies due to its strong generalization ability, resulting in missed detections. At the same time, the extrapolation ability is weak, and the detection effect of anomalies in unseen data is unstable.
[0004] Therefore, based on the above situation, this application develops a method for detecting water level data anomalies based on the fusion of rules and neural networks. Summary of the Invention
[0005] To address the shortcomings of the existing technologies, this invention provides a method for detecting anomalies in water level data based on the fusion of rules and neural networks. By incorporating rule parameters into LSTM and combining data-driven and knowledge-driven paradigms, the method can accurately identify abnormal water level data while improving the interpretability and engineering applicability of the anomaly detection results.
[0006] The present invention is solved by the following technical solution.
[0007] A method for detecting anomalies in water level data based on the fusion of rules and neural networks includes the following steps: S10: Identify upstream and downstream water level stations associated with the target water level station, analyze rainfall stations affecting the water level of the target station, and select a method for calculating watershed areal rainfall; S20: Data acquisition and preprocessing, converting the processed water level data and areal rainfall into a time-series format suitable for LSTM model input, and dividing it into several datasets, including training and validation sets; S30: Based on the physical characteristics of water level monitoring stations and historical observation data, construct an anomaly judgment rule system for the target water level station, and transform the rules into quantitative representations. Differentiable mathematical constraints are then embedded into the training objective loss function of the LSTM model; S40: Construct a rule-constrained LSTM model, train the LSTM model using the dataset, determine whether the model has converged based on the trend of the loss function changes on the training and validation sets, correct the model parameters and rule weight coefficients, and output the trained rule-constrained LSTM model; S50: Collect the water level of the target water level station and the water levels of the upstream and downstream water level stations with the highest correlation, calculate the basin surface rainfall, input it into the trained rule-constrained LSTM model, and perform water level anomaly data detection and result output.
[0008] Furthermore, step S10 also includes the following specific steps: S11: Extract the basin boundary of the river where the target water level station is located, and in combination with the river direction and the distribution of the water level station network, select all upstream and downstream water level stations located at the target water level station as candidate associated stations, extract the water level data of the target water level station and the candidate stations for the past 3 years in 5-minute intervals, and use the Pearson correlation coefficient formula to calculate the correlation between the water levels of the two stations; S12: Based on the catchment area boundary of the target water level station, expand the buffer zone outward as the screening range; S13: Use the Thiessen polygon method to calculate the basin surface rainfall, and allocate rainfall according to the spatial distribution weight of the rainfall stations.
[0009] Furthermore, in step S12, a 5km buffer zone is extended outward as the screening range. National benchmark rain gauge stations within the catchment area are selected first, followed by regional automatic rain gauge stations within the catchment area, and finally stations within the buffer zone. These stations are only selected when the number of stations within the catchment area is ≤2.
[0010] Furthermore, step S20 also includes the following specific steps: S21: Collect historical water level data of the target water level station. The data collection dimensions include water level value, collection time, and hydrological monitoring elements associated with the target water level station; S22: Perform missing value completion and abnormal data labeling on the collected target water level data. If the proportion of abnormal data is too low, use time-series oversampling or synthesize minority class samples to increase the proportion of abnormal data; S23: Perform missing data completion, abnormal data standardization, and unified time frequency on the associated water level and rainfall data, and calculate the basin surface rainfall according to step S13; S24: Perform data normalization and time-series data windowing on the processed data to transform it into a sample dataset suitable for LSTM model training, and divide it into training set and validation set.
[0011] Furthermore, step S30 also includes the following specific steps: S31: Design water level anomaly detection rules by combining the experience of experts in the field of hydrology and the actual hydrological characteristics of the target detection station; S32: Quantify and characterize each rule, transform it into a differentiable mathematical constraint expression and embed it into the training framework of the LSTM model, and realize the quantitative calculation of the deviation degree of each constraint condition by constructing a violation quantification function.
[0012] Furthermore, in step S31, the water level anomaly detection rules include mean deviation rules, threshold rules, correlation rules, and rate of change rules.
[0013] Furthermore, step S40 also includes the following specific steps: S41: Based on the standard LSTM time series modeling capability, embed a quantitative constraint mechanism of hydrological domain rules to construct a rule-constrained LSTM model and determine the total loss function Loss; S42: Output layer, based on the Sigmoid activation function, calculates the water level anomaly probability. Output to (0,1); S43: Initialize the core parameters of the rule-constrained LSTM model. The initialization process adopts the Xavier normal distribution initialization strategy. Input the time series sample dataset preprocessed in step S24 into the model. Minimize the total loss function Loss as the optimization objective. Use the F1 score as the evaluation index during model training to judge the model performance. Conduct iterative training of the model and complete the parameter iterative update; S44: Set the convergence threshold of the loss function. At the same time, the lower limit threshold for the F1 score is set as... In each training round, the total loss value (Loss) and F1 score of the model are calculated on the validation set. If the following conditions are met... or If the loss no longer decreases significantly, the model training is considered converged, the iteration process is terminated, and the currently trained rule-constrained LSTM model is output. Otherwise, the parameter adjustment phase is initiated to update the model parameters. With rule constraint weights Return to step S43 and restart model training based on the updated parameters until the convergence condition is met; S45: Adjust the model parameters according to the gradient.
[0014] Furthermore, step S50 also includes the following specific steps: S51: Collect real-time water level data from the target water level station and the upstream and downstream water level stations with the highest correlation, simultaneously collect real-time rainfall data from related rain gauge stations, and execute steps S22, S23, and S24 to perform data preprocessing, basin-wide rainfall calculation, and data normalization; S52: Input the data from step S51 into the rule-constrained LSTM model trained in step S44, and output the rule-constrained LSTM model to output the probability of water level anomaly at time t of the target water level station. Correlation matrix between probability and rule violation S53: Introduce scenario risk coefficients based on the hydrological characteristics, engineering importance, and disaster impact range of different scenarios involving reservoirs, rivers, and coastal tide levels. And by combining the anomaly probability and weighted violation degree, a comprehensive anomaly judgment index is calculated. ; Utilizing comprehensive judgment indicators Classification of water level anomaly data S54: Output the results based on the above content. .
[0015] Compared with existing technologies, this invention has the following beneficial effects: It provides a water level data anomaly detection method based on the fusion of rules and neural networks, which is applicable to multiple scenarios such as river main streams, reservoirs, and coastal tide levels. By transforming the anomaly judgment rules in the hydrological field into differentiable constraints and embedding them into an LSTM model, it integrates the advantages of knowledge and data-driven approaches. This not only solves the problem of poor adaptability of traditional rule-based methods, but also makes up for the shortcomings of data-driven methods, such as reliance on data and weak extrapolation. By outputting information such as anomaly probability, violation rules, and contribution, it enhances the interpretability of the results, reduces the false negative and false positive rates of water level data, improves the comprehensiveness and accuracy of anomaly detection, and provides high-quality data support for hydrological-related decision-making. Attached Figure Description
[0016] Figure 1 This is a flowchart of the water level data anomaly detection method based on the fusion of rules and neural networks in this invention.
[0017] Figure 2 This is a flowchart illustrating the construction process of the rule-constrained LSTM model in this invention. Detailed Implementation
[0018] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0019] The following are specific embodiments of the present invention to help those skilled in the art understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.
[0020] like Figure 1 As shown, a method for detecting water level data anomalies based on the fusion of rules and neural networks includes the following steps.
[0021] Step S10: Select a river water level station, analyze its associated upstream and downstream water level stations and rainfall stations, and use the Thiessen polygon method to calculate the watershed surface rainfall. This step S10 specifically includes the following steps S11-S13.
[0022] Step S11: Extract the watershed boundary of the river channel where water level station A is located. Based on the river's west-to-east direction, initially determine the upstream candidate station as station B and the downstream candidate station as station C. Next, collect 5-minute water level data from stations A, B, and C over the past 3 years, obtaining a total of 315,360 samples. Calculate the correlation using the Pearson correlation coefficient formula. If the correlation coefficient... If the value is ≥0.75, it is determined to be a related upstream or downstream water level station.
[0023] Step S12: Based on the boundary of the catchment area of station A, after extending the buffer zone by 5km, select 3-5 rain gauge stations. Prioritize the national benchmark rain gauge station within the catchment area, then select the regional automatic rain gauge station within the catchment area, and finally select the station within the buffer zone. Only supplement the selection when the number of stations within the catchment area is ≤2.
[0024] Step S13: Calculate the watershed areal rainfall using the Thiessen polygon method. Distribute rainfall according to the spatial distribution weights of rain gauges. The areal rainfall formula is as follows: ; Indicates the number of rain gauges. For the first 5-minute rainfall at each rain gauge station No. The area of the Thiessen polygon corresponding to each rain gauge within the catchment area. The total catchment area of the target water level station.
[0025] Step S20: Data acquisition and preprocessing. The processed water level data and areal rainfall data are converted into a time-series format suitable for LSTM model input and divided into several datasets, including training and validation sets. Step S20 specifically includes the following steps S21-S24.
[0026] Step S21: Collect water level values (unit: m) and collection time from stations A, B, and C, and correlate them with rainfall values (unit: mm) from rain gauge stations; at the same time, record special conditions in the watershed during the same period (such as rainstorms and typhoons) to assist in the labeling of abnormal data.
[0027] Step S22: Perform operations such as missing value completion and abnormal data labeling on the collected water level data, and use time-series oversampling or synthesize minority class samples to increase the proportion of abnormal data.
[0028] Step S23: Perform operations such as missing data completion, abnormal data labeling, and time frequency unification on the associated water level and rainfall data, and calculate the watershed surface rainfall according to step S13.
[0029] Step S24: Normalize the processed data and window the time-series data to transform it into a sample dataset suitable for LSTM model training. Divide the dataset into a training set and a validation set in an 8:2 ratio to form a complete sample dataset. :
[0030] .
[0031] in, Indicates the length of the time window. Indicates the water level at the target point. Indicates the water level at the upstream water level station. This indicates the water level at the downstream water level station. This indicates the rainfall amount per unit area of the watershed.
[0032] Step S30: Based on the physical characteristics and historical observation data of the water level monitoring stations, construct an anomaly judgment rule system for the target monitoring stations. Transform the rules into differentiable mathematical constraints through quantitative representation, and then embed them into the training target loss function of the LSTM model. Step S30 specifically includes the following steps S31-S32.
[0033] Step S31: Combining the experience of experts in the field of hydrology with the actual hydrological characteristics of the target monitoring station, design water level anomaly detection rules, including mean deviation rules, threshold rules, correlation rules, rate of change rules, etc., as detailed below.
[0034] (1) Mean deviation rule: Calculate the mean water level within the most recent time window of the monitored water level. and standard deviation Set the deviation coefficient The water level exceeded [ , The range is abnormal.
[0035] (2) Threshold rule: The water level must not exceed the historical extreme value or the safety threshold. Based on basic information and historical data, the final water level threshold is determined. , ].
[0036] (3) Association Rules: Based on the transmissibility of water flow and the principle of water balance, the water levels at upstream and downstream stations should maintain a reasonable difference at the same time. By calculating the difference between the water level at the monitoring station and the water levels at the upstream and downstream stations, the reasonable difference is set as follows: [ , ]and[ , ].
[0037] (4) Rate of Change Rule: Based on the time series characteristics of water level, a multi-index system of rate of change rule is constructed, including absolute / relative rate of change / standard rate of change. Three reasonable thresholds for the rate of change are set as follows: [ , ]、[ , ]and[ , ].
[0038] Step S32: Quantify and represent each rule, transform it into a differentiable mathematical constraint expression and embed it into the training framework of the LSTM model. Quantify the deviation of each constraint condition by constructing a violation metric function. The specific method is as follows.
[0039] (1) Mean deviation rule:
[0040] Rule 1: ,in, for The water level value that is constantly monitored;
[0041] degree of violation ;
[0042] (2) Threshold rule:
[0043] Rule 2: degree of violation ;
[0044] Rule 3: degree of violation ;
[0045] in, , This is the allowable range of minute errors;
[0046] (3) Association rules:
[0047] Rule 4: ,in, for Upstream water level at any given time;
[0048] degree of violation ;
[0049] Rule 5: ,in, for Upstream water level at any given time;
[0050] degree of violation ;
[0051] (4) Sequential logic rules:
[0052] Rule 6: ;in, It is the absolute rate of change;
[0053] degree of violation ;
[0054] Rule 7: ,in, To set a minimum value to prevent the denominator from being zero;
[0055] degree of violation ;
[0056] Rule 8: ,in, The standard deviation of the absolute rate of change within the time window;
[0057] degree of violation .
[0058] Step S40: As Figure 2 As shown, a rule-constrained LSTM model is constructed, trained using the training dataset, and convergence is determined based on the trend of the loss function changes on the training and validation sets. The model parameters and rule weight coefficients are then adjusted, and the trained rule-constrained LSTM model is output. Step S40 specifically includes the following steps S41-S45.
[0059] Step S41: Based on the standard LSTM time series modeling capabilities, embed a quantitative constraint mechanism for hydrological rules to construct a rule-constrained LSTM model, and determine the total loss function as follows:
[0060] ;
[0061] in This is the regularization coefficient, and a suitable value can be determined through cross-validation. For model parameters, These are weighting coefficients (used to balance class imbalance problems). For sample data size, For the first The true labels of each sample (1 indicates anomaly, 0 indicates normality). Output the first value for the model The probability that a sample is an anomaly. For the number of rules, Weights are constrained by the rules. For the first The degree of violation of the rules.
[0062] Step S42: The output layer uses the Sigmoid activation function to calculate the probability of water level anomalies. Output to (0,1), the closer to 1, the higher the probability of the sample being abnormal. Core output: Auxiliary output: It is used to record the constraint weights, violation levels, regularization coefficients, and cross-entropy weighting coefficients of each rule.
[0063] Step S43: Initialize the core parameters of the rule-constrained LSTM model. The initialization process adopts the Xavier normal distribution initialization strategy. Input the time series sample dataset preprocessed in step S24 into the model. Minimize the total loss function Loss as the optimization objective. Use the F1 score as the evaluation index during model training to judge the model performance and carry out iterative model training. In each round of training, first calculate the anomaly prediction probability of the training set samples through forward propagation. and the degree of violation of each rule The total loss is obtained, and then the gradient of the loss with respect to each model parameter is calculated using the chain rule based on the backpropagation algorithm. The Adam optimizer (with a learning rate preset to 0.001) is used to complete the parameter iterative update.
[0064] Step S44: Set the convergence threshold of the loss function At the same time, the lower limit threshold for the F1 score is set as... In each training round, the total loss value (Loss) and F1 score of the model are calculated on the validation set. If the following conditions are met... or If the loss no longer decreases significantly, the model training is considered converged, the iteration process is terminated, and the currently trained rule-constrained LSTM model is output. Otherwise, the parameter adjustment phase is initiated to update the model parameters. With rule constraint weights Return to step S43 and restart model training based on the updated parameters until the convergence condition is met.
[0065] Step S45: Adjust the model parameters according to the gradient. The update method is as follows:
[0066] ;
[0067] in For training rounds, , For the first The training parameters of the model in the first round (including weights and biases) and the first round of training. The rules constrain the weights, among which The learning rate for the model parameters. The learning rate is the weight of the rule constraints. For parameters gradient, Weights for rule constraints The gradient.
[0068] Step S50: Collect water levels at the target station and the upstream and downstream stations with the highest correlation, calculate the basin-wide rainfall, and input the data into the trained rule-constrained LSTM model to detect water level anomalies and output the results. Step S50 specifically includes the following steps S51-S54. Step S51: Collect real-time water level data from the target water level station and the upstream and downstream water level stations with the highest correlation (collection frequency is the same as the training data, which is 5 minutes / time). Simultaneously collect real-time rainfall data from the associated rain gauge stations, and execute steps S22, S23 and S24 to perform data preprocessing, watershed surface rainfall calculation and data normalization.
[0069] Step S52: Input the data from Step S51 into the rule-constrained LSTM model trained in Step S44, and output the rule-constrained LSTM model, which outputs the probability of water level anomaly at time t at the target water level station. Correlation matrix between probability and rule violation :
[0070] .
[0071] Calculate weighted violation and single rule contribution :
[0072] Select The rules are the main rules for violations.
[0073] Step S53: Introduce scenario risk coefficients based on the hydrological characteristics, engineering importance, and disaster impact range of different scenarios involving reservoirs, rivers, and coastal tide levels. And by combining the anomaly probability and weighted violation degree, a comprehensive anomaly judgment index is calculated. :
[0074] ;
[0075] Using comprehensive judgment indicators Classification of water level anomaly data :
[0076] .
[0077] Step S54: Output the results based on the above content. :
[0078] .
[0079] This invention addresses the problems of poor adaptability of rule-based methods and weak extrapolation of data-driven methods by integrating rule-based and LSTM neural network technologies. The core of this invention is to transform hydrological rules into a differentiable constraint embedding model, thus combining the advantages of knowledge-driven and data-driven approaches.
[0080] Specifically, the technical solution of this invention addresses the shortcomings of rule-based methods as follows: (1) Expanding the rule coverage: Combining the experience of hydrological experts and the characteristics of stations, a multi-dimensional anomaly judgment rule system is constructed, covering 8 rules in 4 categories: mean deviation, threshold, correlation (upstream and downstream water levels), and rate of change (absolute / relative / standard), covering linear and nonlinear anomaly scenarios. (2) Rule quantification and dynamic optimization: Each rule is transformed into a differentiable mathematical constraint expression (such as the violation calculation formula of the mean deviation rule) and embedded into the LSTM model training framework; at the same time, through the rule weight coefficient ( (3) Enhanced capabilities by combining time series data: Relying on the modeling capabilities of LSTM for time series data, it makes up for the shortcomings of traditional rules in capturing long-term, multi-correlated water level fluctuation anomalies.
[0081] Furthermore, the technical solution in this invention addresses the shortcomings of data-driven methods with the following strategies: (1) Introducing rule constraints to reduce data dependence: In the total loss function of the LSTM model, a constraint term for rule violation is added ( Even if there are anomalies in the data, the rules can guide the model to avoid learning anomalies and reduce missed detections. (2) Data preprocessing optimizes data quality: By performing operations such as missing value completion, anomaly data labeling, temporal oversampling (copying anomaly windows and adding noise), and synthesizing minority class samples (SMOTE temporal variants), the quality of training data is improved, and the problem of poor model generalization ability caused by the low proportion of anomalies in the data is solved. (3) Multi-index evaluation ensures extrapolation stability: The model training uses the F1 score as the evaluation index, and at the same time combines the convergence threshold of the loss function ( ) and F1 score lower limit threshold ( To determine convergence and avoid model overfitting, a comprehensive judgment index (S) is calculated by combining anomaly probability and weighted violation degree during detection, so that the model can still output results stably in unseen scenarios.
[0082] As described above, this application provides a water level data anomaly detection method based on the fusion of rules and neural networks. It is applicable to multiple scenarios such as river main streams, reservoirs, and coastal tide levels. By transforming the anomaly judgment rules in the hydrological field into differentiable constraints and embedding them into an LSTM model, it integrates the advantages of knowledge and data-driven approaches. This not only solves the problem of poor adaptability of traditional rule-based methods but also makes up for the shortcomings of data-driven methods, such as reliance on data and weak extrapolation. By outputting information such as anomaly probability, violation rules, and contribution, it enhances the interpretability of the results, reduces the false negative and false positive rates of water level data, and improves the comprehensiveness and accuracy of anomaly detection, providing high-quality data support for hydrological-related decision-making.
[0083] The scope of protection of this invention includes, but is not limited to, the above embodiments. The scope of protection of this invention is defined by the claims. Any substitutions, modifications, or improvements to this technology that are easily conceived by those skilled in the art fall within the scope of protection of this invention.
Claims
1. A method for detecting anomalies in water level data based on the fusion of rules and neural networks, characterized in that, Includes the following steps: S10: Identify the upstream and downstream water level stations associated with the target water level station, analyze the rainfall stations that affect the water level of the target water level station, and select the watershed surface rainfall calculation method. S20: Data acquisition and preprocessing, converting the processed water level data and areal rainfall into a time series format suitable for LSTM model input, and dividing it into several datasets, including training set and validation set; S30: Based on the physical characteristics and historical observation data of water level monitoring stations, construct an anomaly judgment rule system for target water level stations, and transform the rules into differentiable mathematical constraint terms through quantitative representation, and then embed them into the training target loss function of the LSTM model. S40: Construct a rule-constrained LSTM model, train the LSTM model using the dataset, determine whether the model has converged based on the trend of the loss function changes on the training and validation sets, correct the model parameters and rule weight coefficients, and output the trained rule-constrained LSTM model. S50: Collect water levels at the target water level station and the water levels at the upstream and downstream water level stations with the highest correlation, calculate the watershed surface rainfall, and input it into the trained rule-constrained LSTM model to detect water level anomalies and output the results.
2. The method for detecting water level data anomalies based on the fusion of rules and neural networks according to claim 1, characterized in that, Step S10 also includes the following specific steps: S11: Extract the watershed boundary of the river where the target water level station is located. Combine the river direction and the distribution of the water level station network to select all upstream and downstream water level stations located at the target water level station as candidate related stations. Extract the water level data of the target water level station and the candidate stations for the past 3 years in 5-minute increments. Use the Pearson correlation coefficient formula to calculate the correlation between the water levels of the two stations. S12: Based on the catchment area boundary of the target water level station, extend the buffer zone outward as the screening range; S13: The Thiessen polygon method is used to calculate the watershed surface rainfall, and the rainfall is allocated according to the spatial distribution weight of the rain gauge stations.
3. The method for detecting water level data anomalies based on the fusion of rules and neural networks according to claim 2, characterized in that, In step S12, a 5km buffer zone is extended outward as the screening range. National benchmark rain gauges within the catchment area are selected first, followed by regional automatic rain gauges within the catchment area, and finally stations within the buffer zone are selected. These stations are only added when the number of stations within the catchment area is ≤2.
4. The method for detecting water level data anomalies based on the fusion of rules and neural networks according to claim 3, characterized in that, Step S20 also includes the following specific steps: S21: Collect historical water level data of the target water level station. The data collection dimensions include water level value, collection time, and hydrological monitoring elements associated with the target water level station. S22: Complete missing values and label abnormal data for the collected target water level data. If the proportion of abnormal data is too low, use time-series oversampling or synthesize minority class samples to increase the proportion of abnormal data. S23: Perform missing data completion, abnormal data standardization, and time frequency unification operations on the associated water level and rainfall data, and calculate the watershed surface rainfall according to step S13; S24: Perform data normalization and windowing of the time series data on the processed data to transform it into a sample dataset suitable for training the LSTM model, and divide it into a training set and a validation set.
5. The method for detecting water level data anomalies based on the fusion of rules and neural networks according to claim 4, characterized in that, Step S30 also includes the following specific steps: S31: Design water level anomaly detection rules by combining the experience of experts in the field of hydrology with the actual hydrological characteristics of the target monitoring station; S32: Quantify and represent each rule, transform it into a differentiable mathematical constraint expression and embed it into the training framework of the LSTM model. Quantify the degree of deviation of each constraint by constructing a violation metric function.
6. The method for detecting water level data anomalies based on the fusion of rules and neural networks according to claim 5, characterized in that, In step S31, the water level anomaly detection rules include mean deviation rules, threshold rules, correlation rules, and rate of change rules, wherein: Mean deviation rule: Calculate the average water level within the most recent time window of the monitored water level. and standard deviation Set the deviation coefficient The water level exceeded [ , The range is abnormal; Threshold rule: The water level must not exceed the historical extreme value or safety threshold. The final water level threshold is determined by combining basic information and historical data. , ]; Association Rules: Based on the transmissibility of water flow and the principle of water balance, the water levels at upstream and downstream stations should maintain a reasonable difference at the same time. This is achieved by calculating the difference between the water level at the monitoring station and the upstream and downstream water levels, and setting reasonable differences for this difference as follows: [...]. , ]and[ , ]; Change rate rules: Based on the time series characteristics of water level, a multi-indicator system of change rate rules is constructed, including absolute / relative change rate / standard change rate. Three reasonable thresholds for the change rate are set as follows: […]. , ]、[ , ]and[ , ].
7. The method for detecting water level data anomalies based on the fusion of rules and neural networks according to claim 6, characterized in that, Step S40 further includes the following specific steps: S41: Based on the standard LSTM time series modeling capabilities, embed a quantitative constraint mechanism of hydrological rules to construct a rule-constrained LSTM model and determine the total loss function Loss; S42: Output layer, based on the Sigmoid activation function to calculate the probability of water level anomalies. Output to (0,1); S43: Initialize the core parameters of the rule-constrained LSTM model. The initialization process adopts the Xavier normal distribution initialization strategy. Input the time series sample dataset preprocessed in step S24 into the model. Minimize the total loss function Loss as the optimization objective. Use the F1 score as the evaluation index during the model training process to judge the model performance, carry out iterative training of the model, and complete the iterative update of parameters. S44: Set the convergence threshold for the loss function At the same time, the lower limit threshold for the F1 score is set as... In each training round, the total loss value (Loss) and F1 score of the model are calculated on the validation set. If the following conditions are met... or If the loss no longer decreases significantly, the model training is considered converged, the iteration process is terminated, and the currently trained rule-constrained LSTM model is output. Otherwise, the parameter adjustment phase is initiated to update the model parameters. With rule constraint weights Return to step S43 and restart model training based on the updated parameters until the convergence condition is met. S45: Adjust model parameters according to the gradient.
8. The method for detecting water level data anomalies based on the fusion of rules and neural networks according to claim 7, characterized in that, Step S50 further includes the following specific steps: S51: Collect real-time water level data from the target water level station and the upstream and downstream water level stations with the highest correlation, simultaneously collect real-time rainfall data from the associated rain gauge stations, and execute steps S22, S23 and S24 to perform data preprocessing, basin surface rainfall calculation and data normalization. S52: Input the data from step S51 into the rule-constrained LSTM model trained in step S44, and output the rule-constrained LSTM model, which outputs the probability of water level anomaly at time t for the target water level station. Correlation matrix with rule violation degree ; S53: Introducing scenario risk coefficients to address the hydrological characteristics, engineering importance, and disaster impact range of different scenarios involving reservoirs, rivers, and coastal tide levels. And by combining the anomaly probability and weighted violation degree, a comprehensive anomaly judgment index is calculated. ; Using comprehensive judgment indicators Classification of water level anomaly data ; S54: Output the result based on the above content. .
Citation Information
Cited By
Hydrological sequence missing data complementation and trend prediction system and method
CN121958786A