An abnormality detection method for drainage internet of things sensing data, an electronic device, and a storage medium

CN121743982BActive Publication Date: 2026-10-23HARBIN AEROSPACE STAR DATA SYST TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511923797.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-19
Publication Date
2026-10-23
Estimated Expiration
2045-12-19

AI Technical Summary

Technical Problem

[0006]本发明要解决的问题是城市排水物联网系统的数据异常检测中存在的准确性和时效性不足的问题,提出一种排水物联网感知数据的异常检测方法、电子设备及存储介质

Benefits of technology

[0068]本发明所述的一种排水物联网感知数据的异常检测方法,利用Transformer-Based模型对时序依赖关系、跨设备关联特征及深层语义信息的捕捉能力,结合异常标注数据集微调与动态增量优化,实现多源异构感知数据的精准异常识别与类型划分,解决排水物联网感知数据异常检测中存在的隐性异常(如数据缓慢漂移)识别难、高维异构数据适配差、动态工况适应性不足、实时响应滞后的问题,为排水物联网系统的数据质量管控、设备故障定位、管网运维决策提供精准技术支撑,保障城市排水管网安全稳定运行。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121743982B_ABST
    Figure CN121743982B_ABST
Patent Text Reader

Abstract

The application discloses an abnormality detection method for drainage Internet of Things sensing data, an electronic device and a storage medium, and belongs to the technical field of abnormality detection of city drainage Internet of Things sensing data. In order to solve the problems of insufficient accuracy and timeliness in the data abnormality detection of the city drainage Internet of Things system. The application comprises the following steps: constructing a multi-source original sensing data set, preprocessing the original sensing data set to obtain a preprocessed time series data sequence, converting the preprocessed time series data sequence into an input text of a Transformer-Based model, capturing data features by using a time series large model based on a Transformer architecture, introducing an abnormality scoring mechanism and an abnormality data classification method to perform abnormality identification, and obtaining an abnormality labeled data set of the drainage Internet of Things sensing data; and adopting a labeled data set fine-tuning-incremental learning optimization method, fine-tuning the Transformer-Based model by using the abnormality labeled data set, introducing an incremental learning mechanism to optimize the performance of the model, and outputting an abnormality detection result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of urban drainage Internet of Things (IoT) sensing data anomaly detection technology, specifically involving an anomaly detection method, electronic device, and storage medium for drainage IoT sensing data. Background Technology

[0002] With the acceleration of urbanization and the increasing frequency of extreme weather events, the safe and stable operation of urban drainage networks has become crucial to ensuring urban flood control and drainage capabilities. Drainage Internet of Things (IoT) systems, through the deployment of numerous sensing terminals such as flow sensors, water level sensors, and water quality monitoring equipment, collect real-time network operation data, providing core data support for drainage scheduling, fault diagnosis, and network maintenance. They are an important infrastructure for modern urban water management.

[0003] However, during the collection and transmission of data from the drainage IoT system, data anomalies are easily affected by various factors: First, at the equipment level, sensor aging, voltage fluctuations, and installation deviations can cause data drift or sudden changes; second, at the environmental level, heavy rain, siltation, and electromagnetic interference can cause data noise or distortion; and third, at the transmission level, wireless signal attenuation and network latency can lead to data loss or corruption. If these anomalies are not identified in a timely manner, they will seriously affect the accuracy of drainage system operational status assessments, leading to problems such as incorrect scheduling decisions and delayed fault response.

[0004] Existing methods for detecting anomalies in drainage IoT data can be mainly divided into three categories: First, methods based on statistical models (such as thresholding and sliding window methods) rely on manually set rules, which are difficult to adapt to the temporal correlation and dynamic changes of data, and have weak ability to identify latent anomalies (such as slow drift); second, traditional machine learning methods (such as clustering and support vector machines) are not adaptable to high-dimensional, heterogeneous, multi-source sensing data, have long model training cycles, and cannot quickly respond to real-time changes in drainage conditions; third, conventional deep learning methods (such as CNN and LSTM) can capture some temporal features, but are difficult to effectively mine cross-device and cross-dimensional semantic information, and have limited accuracy and generalization ability in anomaly detection.

[0005] In addition, existing methods generally have two major challenges: on the one hand, they lack comprehensive capture of the "temporal dependence, spatial correlation and semantic consistency" of drainage data, resulting in a high rate of false positives and false negatives; on the other hand, model updates rely on full data retraining, which is not real-time enough and makes it difficult to adapt to the dynamic operation and maintenance needs of large-scale drainage IoT systems. Summary of the Invention

[0006] The problem this invention aims to solve is the lack of accuracy and timeliness in the detection of data anomalies in urban drainage Internet of Things (IoT) systems. It proposes an anomaly detection method, electronic device, and storage medium for drainage IoT sensing data.

[0007] To achieve the above objectives, the present invention provides the following technical solution:

[0008] A method for anomaly detection in drainage IoT sensing data includes the following steps:

[0009] S1. Collect raw sensing data of the target monitoring area from various sensing devices of the drainage Internet of Things system, construct a multi-source raw sensing dataset, perform preprocessing, and obtain a preprocessed time series data sequence;

[0010] S2. The time-series-association fusion coding method is used to transform the preprocessed time-series data sequence obtained in step S1 into a textual representation that can be recognized by the Transformer-Based model, thus obtaining the input text of the Transformer-Based model;

[0011] S3. Capture the data features of the input text of the Transformer-Based model obtained in step S2 by using a time-series large model based on the Transformer architecture, and introduce an anomaly scoring mechanism and anomaly data classification method to identify anomalies, thereby obtaining an anomaly labeled dataset of drainage IoT sensing data.

[0012] S4. The labeled dataset fine-tuning-incremental learning optimization method is adopted. The Transformer-Based model is fine-tuned using the labeled dataset of drainage IoT sensing data obtained in step S3. An incremental learning mechanism is introduced to optimize the model performance, output the anomaly detection results, and evaluate the anomaly detection results.

[0013] Furthermore, the specific implementation method of step S1 includes the following steps:

[0014] S1.1. The collected raw sensing data includes flow rate data Q, water level data H, water quality parameters pH value, dissolved oxygen DO, equipment operating voltage U, equipment operating signal strength S, and timestamp information T, constructing a multi-source raw sensing dataset:

[0015]

[0016] Where D is the multi-source raw sensing dataset;

[0017] S1.2. Perform preprocessing operations on the multi-source raw sensing dataset obtained in step S1.1, including missing value imputation, noise removal, and standardization, to obtain the preprocessed time-series data sequence. Then, basic statistical features are extracted;

[0018] The formula for interpolating missing values ​​is:

[0019]

[0020] in, Imputation values ​​for missing data. , These represent the valid data before the missing data and the valid data after the missing data, respectively. For timestamps of missing data, , They are respectively , timestamp;

[0021] The formula for basic statistical feature extraction is:

[0022]

[0023]

[0024]

[0025] in, It is a characteristic of the mean. For variance characteristics, For trend value characteristics, The amount of data within the time window. For the k-th data value, For the end timestamp of the time window, This is the starting timestamp of the time window.

[0026] Furthermore, the specific implementation method of step S2 includes the following steps:

[0027] S2.1. Encode the data values ​​of the time-series data sequence after preprocessing in step S1. The data value encoding formula is as follows:

[0028]

[0029] in, It is a text-encoded numeric string. , These are the minimum and maximum values ​​of the preprocessed time series data sequence, respectively.

[0030] S2.2. Perform time-series relation encoding on the time-series data sequence after preprocessing in step S1. The time-series relation encoding formula is as follows:

[0031]

[0032]

[0033] in, Trend coding symbols, The threshold for trend judgment Encoding for time intervals, This is the current data timestamp. This is the timestamp of the previous data.

[0034] S2.3. Perform device association coding on the time-series data sequence after preprocessing in step S1. The device association coding formula is as follows:

[0035]

[0036] in, For device association coding, As a unique identifier for the device, For the association of monitoring points;

[0037] S2.4. Construct the input text based on the data encoded in steps S2.1, S2.2, and S2.3. The formula for constructing the input text is:

[0038]

[0039] in, Input text into the Transformer-Based model. These are the start and end timestamps of the time segment. Encode the string concatenation result of the data sequence. It is a combination of basic statistical characteristics.

[0040] Furthermore, the specific implementation method of step S3 includes the following steps:

[0041] S3.1. A time-series large model based on the Transformer architecture is used to extract features from the input text obtained in step S2.

[0042] The core formula for feature extraction from the Transformer encoder is:

[0043]

[0044]

[0045] in, Output features for the attention mechanism. The word embedding vectors of the input text. For position encoding functions, As a multi-head attention mechanism, For layer normalization operation, Features weighted by attention weights It is a feedforward neural network. This is a deep semantic feature vector;

[0046] S3.2. Perform anomaly scoring on the deep semantic feature vector obtained in step S3.1. The anomaly scoring formula is as follows:

[0047]

[0048]

[0049] in, Cosine similarity of feature vectors For normal mode feature vectors, Let L2 norm be the vector. For abnormal scoring, This is an adjustment coefficient, with a value ranging from 0.1 to 0.3. The rate of change over time;

[0050] S3.3. Based on the anomaly score obtained in step S3.2, perform anomaly classification. The anomaly classification formula is as follows:

[0051]

[0052] in, It is an exception type. , , The first anomaly scoring threshold, the second anomaly scoring threshold, and the third anomaly scoring threshold are set to 0.8, 0.5, and 0.2 respectively, to obtain the drainage IoT sensing data anomaly annotation dataset.

[0053] Furthermore, the specific implementation method of step S4 includes the following steps:

[0054] S4.1. Fine-tune the Transformer-Based model using the anomaly-labeled dataset of drainage IoT sensing data obtained in step S3. The model fine-tuning loss function formula is as follows:

[0055]

[0056] in, To fine-tune the loss value, To determine the sample size of the labeled dataset, , These are the output layer weights and biases, respectively. For activation function, Let cross-entropy be the loss function. The true label of the m-th sample;

[0057] S4.2. Based on the fine-tuned Transformer-Based model obtained in step S4.1, update the parameters. The incremental learning parameter update formula is as follows:

[0058]

[0059] in, For the updated model parameters, These are the model parameters before the update. The parameter is the attenuation coefficient, with a value range of 0.95 to 0.99. The learning rate, with a value ranging from 0.0001 to 0.001. The gradient of the incremental learning loss function, For the newly added data sample set;

[0060] S4.3. Output the anomaly detection results using the updated Transformer-Based model obtained in step S4.2. The formula for outputting the anomaly detection results is as follows:

[0061]

[0062] in, This is a collection of anomaly detection results. For timestamps of abnormal data Confidence level for anomaly identification;

[0063] ;

[0064] S4.4. Evaluate the anomaly detection results output in step S4.3, and select precision, recall and F1 score as performance metrics.

[0065] An electronic device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the method for anomaly detection of drainage Internet of Things sensing data.

[0066] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned method for anomaly detection of drainage Internet of Things (IoT) sensing data.

[0067] The beneficial effects of this invention are:

[0068] This invention discloses an anomaly detection method for drainage IoT sensing data. It utilizes the Transformer-Based model's ability to capture temporal dependencies, cross-device correlation features, and deep semantic information. Combined with fine-tuning of the anomaly-labeled dataset and dynamic incremental optimization, it achieves accurate anomaly identification and type classification of multi-source heterogeneous sensing data. This solves the problems of difficulty in identifying latent anomalies (such as slow data drift), poor adaptation to high-dimensional heterogeneous data, insufficient adaptability to dynamic operating conditions, and delayed real-time response in drainage IoT sensing data anomaly detection. It provides precise technical support for data quality control, equipment fault location, and pipeline network operation and maintenance decisions in drainage IoT systems, ensuring the safe and stable operation of urban drainage networks. Attached Figure Description

[0069] Figure 1 This is a flowchart of an anomaly detection method for drainage IoT sensing data according to the present invention. Detailed Implementation

[0070] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only for explaining the invention and are not intended to limit the invention; that is, the described specific embodiments are merely a part of the embodiments of the invention, and not all of them. The components of the specific embodiments of the invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations, and the invention may also have other embodiments.

[0071] Therefore, the following detailed description of specific embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected specific embodiments of the invention. All other specific embodiments obtained by those skilled in the art based on these specific embodiments without inventive effort are within the scope of protection of this invention.

[0072] To further understand the invention's content, features, and effects, the following specific embodiments are provided, along with accompanying drawings. Figure 1 Detailed explanation is as follows:

[0073] Example 1:

[0074] A method for anomaly detection in drainage IoT sensing data includes the following steps:

[0075] S1. Collect raw sensing data of the target monitoring area from various sensing devices of the drainage Internet of Things system, construct a multi-source raw sensing dataset, perform preprocessing, and obtain a preprocessed time series data sequence;

[0076] Furthermore, the specific implementation method of step S1 includes the following steps:

[0077] S1.1. The collected raw sensing data includes flow rate data Q, water level data H, water quality parameters pH value, dissolved oxygen DO, equipment operating voltage U, equipment operating signal strength S, and timestamp information T, constructing a multi-source raw sensing dataset:

[0078]

[0079] Where D is the multi-source raw sensor dataset;

[0080] S1.2. Perform preprocessing operations on the multi-source raw sensing dataset obtained in step S1.1, including missing value imputation, noise removal, and standardization, to obtain the preprocessed time-series data sequence. Then, basic statistical features are extracted;

[0081] The formula for interpolating missing values ​​is:

[0082]

[0083] in, Imputation values ​​for missing data. , These represent the valid data before the missing data and the valid data after the missing data, respectively. For timestamps of missing data, , They are respectively , timestamp;

[0084] The formula for basic statistical feature extraction is:

[0085]

[0086]

[0087]

[0088] in, It is a characteristic of the mean. For variance characteristics, For trend value characteristics, The amount of data within the time window. For the k-th data value, For the end timestamp of the time window, This is the starting timestamp of the time window.

[0089] Furthermore, the noise determination and removal formula is as follows:

[0090] Noise determination criteria, for a certain data point If any of the following conditions are met, it is determined to be noise: or ,in For a single data point to be determined, The lower threshold of normal data Upper threshold for normal data; noise replacement / removal rules: for data points identified as noise, use the mean to replace them with the mean of that type of data. The formula for replacing noise points is:

[0091] The standardized formula is:

[0092]

[0093] in, For standardized data, The original data, The mean of the data. The standard deviation of the data;

[0094] S2. The time-series-association fusion coding method is used to transform the preprocessed time-series data sequence obtained in step S1 into a textual representation that can be recognized by the Transformer-Based model, thus obtaining the input text of the Transformer-Based model;

[0095] Furthermore, the specific implementation method of step S2 includes the following steps:

[0096] S2.1. Encode the data values ​​of the time-series data sequence after preprocessing in step S1. The data value encoding formula is as follows:

[0097]

[0098] in, This is a text-encoded numeric string. , These are the minimum and maximum values ​​of the preprocessed time series data sequence, respectively.

[0099] S2.2. Perform time-series relation encoding on the time-series data sequence after preprocessing in step S1. The time-series relation encoding formula is as follows:

[0100]

[0101]

[0102] in, Trend coding symbols, The threshold for trend judgment Encoding for time intervals, This is the current data timestamp. This is the timestamp of the previous data.

[0103] S2.3. Perform device association coding on the time-series data sequence after preprocessing in step S1. The device association coding formula is as follows:

[0104]

[0105] in, For device association coding, As a unique identifier for the device, For the association of monitoring points;

[0106] S2.4. Construct the input text based on the data encoded in steps S2.1, S2.2, and S2.3. The formula for constructing the input text is:

[0107]

[0108] in, Input text into the Transformer-Based model. These are the start and end timestamps of the time segment. Encode the string concatenation result of the data sequence. It is a combination of basic statistical characteristics.

[0109] S3. Capture the data features of the input text of the Transformer-Based model obtained in step S2 by using a time-series large model based on the Transformer architecture, and introduce an anomaly scoring mechanism and anomaly data classification method to identify anomalies, thereby obtaining an anomaly labeled dataset of drainage IoT sensing data.

[0110] Furthermore, the specific implementation method of step S3 includes the following steps:

[0111] S3.1. A temporal large-scale model based on the Transformer architecture is used to extract features from the input text obtained in step S2.

[0112] The core formula for feature extraction from the Transformer encoder is:

[0113]

[0114]

[0115] in, Output features for the attention mechanism. The word embedding vectors of the input text. For position encoding functions, As a multi-head attention mechanism, For layer normalization operation, Features weighted by attention weights It is a feedforward neural network. This is a deep semantic feature vector;

[0116] S3.2. Perform anomaly scoring on the deep semantic feature vector obtained in step S3.1. The anomaly scoring formula is as follows:

[0117]

[0118]

[0119] in, Cosine similarity of feature vectors For normal mode feature vectors, Let L2 norm be the vector. For abnormal scoring, This is an adjustment coefficient, with a value ranging from 0.1 to 0.3. The rate of change over time;

[0120] S3.3. Based on the anomaly score obtained in step S3.2, perform anomaly classification. The anomaly classification formula is as follows:

[0121]

[0122] in, It is an exception type. , , The first anomaly scoring threshold, the second anomaly scoring threshold, and the third anomaly scoring threshold are set to 0.8, 0.5, and 0.2 respectively, to obtain the drainage IoT sensing data anomaly annotation dataset.

[0123] S4. The labeled dataset fine-tuning-incremental learning optimization method is adopted. The Transformer-Based model is fine-tuned using the labeled dataset of drainage IoT sensing data obtained in step S3. An incremental learning mechanism is introduced to optimize the model performance, output the anomaly detection results, and evaluate the anomaly detection results.

[0124] Furthermore, the specific implementation method of step S4 includes the following steps:

[0125] S4.1. Fine-tune the Transformer-Based model using the anomaly-labeled dataset of drainage IoT sensing data obtained in step S3. The model fine-tuning loss function formula is as follows:

[0126]

[0127] in, To fine-tune the loss value, To determine the sample size of the labeled dataset, , These are the output layer weights and biases, respectively. For activation function, Let cross-entropy be the loss function. The true label of the m-th sample;

[0128] S4.2. Based on the fine-tuned Transformer-Based model obtained in step S4.1, update the parameters. The incremental learning parameter update formula is as follows:

[0129]

[0130] in, For the updated model parameters, These are the model parameters before the update. The parameter is the attenuation coefficient, with a value range of 0.95 to 0.99. The learning rate, with a value ranging from 0.0001 to 0.001. The gradient of the incremental learning loss function, For the newly added data sample set;

[0131] S4.3. Output the anomaly detection results using the updated Transformer-Based model obtained in step S4.2. The formula for outputting the anomaly detection results is as follows:

[0132]

[0133] in, This is a collection of anomaly detection results. For timestamps of abnormal data Confidence level for anomaly identification;

[0134] ;

[0135] S4.4. Evaluate the anomaly detection results output in step S4.3, and select precision, recall and F1 score as performance metrics.

[0136] Furthermore, the formula for precision is:

[0137]

[0138] in, For accuracy, This represents the number of drainage sensing data samples that the model identifies as abnormal and that are actually abnormal. The number of drainage sensing data samples that the model judged to be abnormal but were actually normal;

[0139] The formula for recall is:

[0140]

[0141] in, For recall rate, This represents the number of drainage sensing data samples that the model classifies as normal but are actually abnormal.

[0142] The formula for the F1 score is:

[0143]

[0144] in, The F1 score is a comprehensive indicator of the balance between precision and recall. Its value ranges from [0,1], and the closer it is to 1, the better the model's anomaly detection performance.

[0145] The following is a practical application example illustrating this embodiment:

[0146] This embodiment takes the drainage pipe network system of an old urban area of ​​a city as the target monitoring area, selects three key monitoring points (numbered Loc-01, Loc-02, and Loc-03), and deploys a flow sensor, water level sensor, water quality monitor, and equipment status monitoring module at each point. Multi-source sensing data is collected continuously for 72 hours (timestamp range: 2024-07-01 00:00:00~2024-07-03 23:59:59) to simulate abnormal data under scenarios such as equipment aging, rainstorm interference, and transmission fluctuations, and to verify the detection effect of this method.

[0147] A method for detecting anomalies in drainage IoT sensing data based on a Transformer-Based model includes the following steps:

[0148] S1. A multi-source drainage data preprocessing algorithm is adopted to collect raw sensing data of the target monitoring area from various sensing devices of the drainage Internet of Things system, construct a mathematical model, and preprocess the raw sensing data.

[0149] Furthermore, the specific implementation method of step S1 includes the following steps:

[0150] S1.1. The raw sensing data collected includes flow rate data Q, water level data H, water quality parameters (pH value, dissolved oxygen DO), equipment operating status data (voltage U, signal strength S), and time stamp information T. The mathematical model is constructed as follows:

[0151]

[0152] Where D represents the multi-source raw sensing data set. Seven types of raw data were collected from three monitoring points to construct the dataset. The following are some key data points (10 data points were extracted in chronological order, simulating 1 missing value and 2 noisy data points).

[0153] S1.2. Perform preprocessing operations on the multi-source raw sensing data set obtained in step S1.1, including missing value imputation, noise removal, standardization, and feature extraction. Taking the Loc-01 data as an example, the core formula is as follows:

[0154] Missing value interpolation formula:

[0155]

[0156] in, Imputation values ​​for missing data. , These are the valid data before and after the missing data, respectively. For timestamps of missing data, , These are the timestamps of the valid data before and after; the traffic at 02:00:00 on 2024-07-01. Missing data, valid data before and after. =13.2 (T=01:00:00) =14.1 (T=04:00:00), missing timestamp =02:00:00. Substitute into the formula:

[0157] Noise detection and removal formula:

[0158] Noise determination criteria, for a certain data point If any of the following conditions are met, it is determined to be noise: or ,in For a single data point to be determined, The lower threshold of normal data The upper limit threshold for normal data;

[0159] Noise replacement / removal rules: For data points identified as noise, the mean is used for replacement, replacing the data with the mean of that type of data. The formula for replacing noise points is: .

[0160] use Criteria for removing noise, mean of Q =13.9, standard deviation =2.1, 3 The pH range is [7.6, 20.2], excluding 89.3; =7.3、 =0.5, 3 The range is [5.8, 8.8]. 9.8 is removed and replaced with the column mean of 7.3, resulting in the corrected data.

[0161] Standardized formula:

[0162]

[0163] in, For standardized data, The original data, The mean of the data. The standard deviation of the data;

[0164] Taking Q as an example, =13.9、 =2.1, calculated using the standardized formula: ,

[0165] Basic statistical feature extraction formula:

[0166]

[0167]

[0168]

[0169] in, It is a characteristic of the mean. For variance characteristics, For trend value characteristics, The amount of data within the time window. For the k-th data value, , These are the start and end timestamps of the time window. (Retrieve the time window) =6 (Valid data for Loc-01), calculate:

[0170]

[0171]

[0172] S2. The temporal-association fusion coding algorithm is used to transform the preprocessed temporal data sequence into a textual representation that can be recognized by the Transformer-Based model. Combined with the basic statistical features extracted in S1, the input text of the Transformer-Based model is constructed.

[0173] Furthermore, the specific implementation method of step S2 includes the following steps:

[0174] S2.1. Encode the data values ​​based on the preprocessed data from step S1. The data value encoding formula is as follows:

[0175]

[0176] in, This is a text-encoded numeric string. For standardized data, , These are the minimum and maximum values ​​of the standardized data, respectively. Taking the standardized Q data as an example... =-0.67、 =0.10, encoding formula calculation:

[0177]

[0178]

[0179] The final Q sequence is encoded as "000-623-519-701-623-429";

[0180] S2.2. Perform time-series relation encoding based on the preprocessed data from step S1. The time-series relation encoding formula is as follows:

[0181]

[0182]

[0183] in, Trend coding symbols, The threshold for trend judgment (range 0.01~0.05). Encoding for time intervals, This is the current data timestamp. Use the previous data timestamp. Set the trend judgment threshold. =0.03, Q trend of Loc-01 =0.1 0.03, encoded as = The time intervals are all 1 hour. =”3600” ;

[0184] S2.3 Based on the data preprocessed in step S1, perform device association coding. The device association coding formula is as follows:

[0185]

[0186] in, For device association coding, As a unique identifier for the device, This is an identifier associated with the monitoring point.

[0187] Configure device IDs: Flow sensor as "Flow-01 / 02 / 03", water level sensor as "Water-01 / 02 / 03", and associate with location IDs, such as the flow sensor code for Loc-01. =”Flow-01-Loc-01”;

[0188] S2.4 Construct the input text based on the data encoded in steps S2.1, S2.2, and S2.3. The input text construction formula is as follows:

[0189]

[0190] in, Input text into the Transformer-Based model. These are the start and end timestamps of the time segment. Encode the string concatenation result of the data sequence. It is a combination of basic statistical characteristics.

[0191] Example of input text for the Loc-01 flow sensor, constructed according to the formula:

[0192] S3. Employ Transformer-Based deep feature extraction and anomaly scoring algorithms. Use a dedicated time-series large model based on the Transformer architecture to capture the data features of the input text used to construct the Transformer-Based model in step S2, and introduce anomaly scoring mechanisms and anomaly data classification methods for anomaly identification.

[0193] Furthermore, the specific implementation method of step S3 includes the following steps:

[0194] S3.1. Based on the input text of the Transformer-Based model constructed in step S2, feature extraction is performed using Transformer-Based deep feature extraction. The core formula for feature extraction by the Transformer encoder is:

[0195]

[0196]

[0197] in, Output features for the attention mechanism. The word embedding vectors of the input text. For position encoding functions, As a multi-head attention mechanism, For layer normalization operation, Features weighted by attention weights It is a feedforward neural network. This represents the deep semantic feature vector. Word embedding dimension. The multi-head attention mechanism has 8 heads (h=8), and the positional encoding uses a sine-cosine function. After word embedding, the input text is processed using the above formula to output a deep feature vector. (Dimension 128);

[0198] S3.2. Perform anomaly scoring based on the input text from step S3.1. The anomaly scoring formula is as follows:

[0199]

[0200]

[0201] in, Cosine similarity of feature vectors For normal mode feature vectors, Let L2 norm be the vector. For abnormal scoring, This is an adjustment coefficient (ranging from 0.1 to 0.3). This represents the rate of change over time. The preset normal mode feature vector... = Calculate the cosine similarity: Set adjustment coefficient =0.2, time series rate of change =0.1, anomaly score: ;

[0202] S3.3. Perform anomaly classification based on the input text from step S3.1. The anomaly classification formula is as follows:

[0203]

[0204] in, It is an exception type. , , The abnormality scoring thresholds are set at values ​​of 0.8, 0.5, and 0.2 respectively. =0.8, =0.5, =0.2, Determined as = .

[0205] S4. The labeled dataset fine-tuning-incremental learning optimization algorithm is adopted. The Transformer-Based model is fine-tuned using the labeled dataset of drainage IoT sensing data obtained in step S3. The incremental learning mechanism is introduced to optimize the model performance, output the anomaly detection results, and select the comprehensive measurement method of anomaly detection accuracy as the performance measurement index to evaluate the model.

[0206] Furthermore, the specific implementation method of step S4 includes the following steps:

[0207] S4.1. Based on the drainage IoT sensing data anomaly labeled dataset obtained in step S3, the model is fine-tuned using the labeled dataset. The model fine-tuning loss function formula is as follows:

[0208]

[0209] in, To fine-tune the loss value, To determine the sample size of the labeled dataset, , These are the output layer weights and biases, respectively. For activation function, Let cross-entropy be the loss function. Let m be the true label of the m-th sample. Construct the labeled dataset. =1000 samples (including 400 outlier samples), output layer weights bias Fine-tuning the loss function calculation: ;

[0210] S4.2. Based on the fine-tuned model obtained in step S4.1, update the parameters using the incremental learning parameter update formula:

[0211]

[0212] in, For the updated model parameters, These are the model parameters before the update. The parameter is the attenuation coefficient (with a value range of 0.95 to 0.99). The learning rate (ranging from 0.0001 to 0.001). The gradient of the incremental learning loss function, For the newly added data sample set, set the parameter attenuation coefficient. =0.97, learning rate =0.005, new data sample set =200 lines, gradient Update parameters: ;

[0213] S4.3 Output the anomaly detection results for the model after parameter updates in step S4.2. The formula for outputting the anomaly detection results is as follows:

[0214]

[0215] in, This is a collection of anomaly detection results. For timestamps of abnormal data Confidence level for anomaly identification Example of abnormal detection results for the Loc-01 flow sensor: Among them, confidence level ;

[0216] S4.4 Based on the anomaly detection results output in step S4.3, an evaluation is performed. A comprehensive method for measuring anomaly detection accuracy (based on precision, recall, and F1 score) is selected as the performance metric. The test set contains 150 samples, and the statistics are as follows: =45 (True anomaly) =3 (false anomaly) =2 (Leakage Anomaly) is calculated according to the following formula:

[0217] Precision formula:

[0218]

[0219] in, For accuracy, This represents the number of drainage sensing data samples that the model identifies as abnormal and that are actually abnormal. The number of drainage sensing data samples that the model judged to be abnormal but were actually normal;

[0220] Recall formula:

[0221]

[0222] in, For recall rate, This represents the number of drainage sensing data samples that the model classifies as normal but are actually abnormal.

[0223] F1 score formula:

[0224]

[0225] in, The F1 score is a comprehensive indicator of the balance between precision and recall, ranging from [0,1]. A value closer to 1 indicates better anomaly detection performance. The calculation... =0.94, , .

[0226] Example 2:

[0227] An electronic device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the method for anomaly detection of drainage Internet of Things sensing data.

[0228] The computer device of the present invention may include a processor and a memory, such as a microcontroller containing a central processing unit. The processor executes the computer program stored in the memory to implement the steps of the above-described method for anomaly detection of sensing data in a drainage IoT system. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created based on the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0229] Example 3:

[0230] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned method for anomaly detection of drainage Internet of Things (IoT) sensing data.

[0231] The computer-readable storage medium of the present invention can be any form of storage medium that can be read by the processor of a computer device, including but not limited to non-volatile memory, volatile memory, ferroelectric memory, etc. The computer-readable storage medium stores a computer program. When the processor of the computer device reads and executes the computer program stored in the memory, the steps of the above-mentioned method for anomaly detection of drainage Internet of Things sensing data can be implemented.

[0232] The computer program includes computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.

[0233] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0234] Although this application has been described above with reference to specific embodiments, various modifications can be made and components can be replaced with equivalents without departing from the scope of this application. In particular, as long as there is no structural conflict, the features in the specific embodiments disclosed in this application can be combined with each other in any way. The lack of an exhaustive description of these combinations in this specification is merely for the sake of brevity and resource conservation. Therefore, this application is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.

Claims

1. A method for anomaly detection in drainage IoT sensing data, characterized in that, Includes the following steps: S1. Collect raw sensing data of the target monitoring area from various sensing devices of the drainage Internet of Things system, construct a multi-source raw sensing dataset, perform preprocessing, and obtain a preprocessed time series data sequence; S2. The time-series-association fusion coding method is used to transform the preprocessed time-series data sequence obtained in step S1 into a textual representation that can be recognized by the Transformer-Based model, thus obtaining the input text of the Transformer-Based model; S3. Capture the data features of the input text of the Transformer-Based model obtained in step S2 by using a time-series large model based on the Transformer architecture, and introduce an anomaly scoring mechanism and anomaly data classification method to identify anomalies, thereby obtaining an anomaly labeled dataset of drainage IoT sensing data. The specific implementation method of step S3 includes the following steps: S3.

1. A time-series large model based on the Transformer architecture is used to extract features from the input text obtained in step S2. The core formula for feature extraction from the Transformer encoder is: in, Output features for the attention mechanism. The word embedding vectors of the input text. For position encoding functions, As a multi-head attention mechanism, For layer normalization operation, Features weighted by attention weights It is a feedforward neural network. This is a deep semantic feature vector; S3.

2. Perform anomaly scoring on the deep semantic feature vector obtained in step S3.

1. The anomaly scoring formula is as follows: in, Cosine similarity of feature vectors For normal mode feature vectors, Let L2 norm be the vector. For abnormal scoring, This is an adjustment coefficient, with a value ranging from 0.1 to 0.

3. The rate of change over time; S3.

3. Based on the anomaly score obtained in step S3.2, perform anomaly classification. The anomaly classification formula is as follows: in, It is an exception type. , , The first anomaly scoring threshold, the second anomaly scoring threshold, and the third anomaly scoring threshold are set to 0.8, 0.5, and 0.2 respectively, to obtain the drainage IoT sensing data anomaly annotation dataset; S4. The labeled dataset fine-tuning-incremental learning optimization method is adopted. The Transformer-Based model is fine-tuned using the labeled dataset of drainage IoT sensing data obtained in step S3. An incremental learning mechanism is introduced to optimize the model performance, output the anomaly detection results, and evaluate the anomaly detection results.

2. The anomaly detection method for drainage IoT sensing data according to claim 1, characterized in that, The specific implementation method of step S1 includes the following steps: S1.

1. The collected raw sensing data includes flow rate data Q, water level data H, water quality parameters pH value, dissolved oxygen DO, equipment operating voltage U, equipment operating signal strength S, and timestamp information T, constructing a multi-source raw sensing dataset: Where D is the multi-source raw sensing dataset; S1.

2. Perform preprocessing operations on the multi-source raw sensing dataset obtained in step S1.1, including missing value imputation, noise removal, and standardization, to obtain the preprocessed time-series data sequence. Then, basic statistical features are extracted; The formula for interpolating missing values ​​is: in, Imputation values ​​for missing data. , These represent the valid data before the missing data and the valid data after the missing data, respectively. For timestamps of missing data, , They are respectively , timestamp; The formula for basic statistical feature extraction is: in, It is a characteristic of the mean. For variance characteristics, For trend value characteristics, The amount of data within the time window. For the k-th data value, For the end timestamp of the time window, This is the starting timestamp of the time window.

3. The anomaly detection method for drainage IoT sensing data according to claim 2, characterized in that, The specific implementation method of step S2 includes the following steps: S2.

1. Encode the data values ​​of the time-series data sequence after preprocessing in step S1. The data value encoding formula is as follows: in, It is a text-encoded numeric string. , These are the minimum and maximum values ​​of the preprocessed time series data sequence, respectively. S2.

2. Perform time-series relation encoding on the time-series data sequence after preprocessing in step S1. The time-series relation encoding formula is as follows: in, Trend coding symbols, The threshold for trend judgment Encoding for time intervals, This is the current data timestamp. This is the timestamp of the previous data. S2.

3. Perform device association coding on the time-series data sequence after preprocessing in step S1. The device association coding formula is as follows: in, For device association coding, As a unique identifier for the device, For the association of monitoring points; S2.

4. Construct the input text based on the data encoded in steps S2.1, S2.2, and S2.

3. The formula for constructing the input text is: in, Input text into the Transformer-Based model. These are the start and end timestamps of the time segment. Encode the string concatenation result of the data sequence. It is a combination of basic statistical characteristics.

4. The anomaly detection method for drainage IoT sensing data according to claim 3, characterized in that, The specific implementation method of step S4 includes the following steps: S4.

1. Fine-tune the Transformer-Based model using the anomaly-labeled dataset of drainage IoT sensing data obtained in step S3. The model fine-tuning loss function formula is as follows: in, To fine-tune the loss value, To determine the sample size of the labeled dataset, , These are the output layer weights and biases, respectively. For activation function, Let cross-entropy be the loss function. The true label of the m-th sample; S4.

2. Based on the fine-tuned Transformer-Based model obtained in step S4.1, update the parameters. The incremental learning parameter update formula is as follows: in, For the updated model parameters, These are the model parameters before the update. The parameter is the attenuation coefficient, with a value range of 0.95 to 0.

99. The learning rate, with a value ranging from 0.0001 to 0.

001. The gradient of the incremental learning loss function, For the newly added data sample set; S4.

3. Output the anomaly detection results using the updated Transformer-Based model obtained in step S4.

2. The formula for outputting the anomaly detection results is as follows: in, This is a collection of anomaly detection results. For timestamps of abnormal data Confidence level for anomaly identification; ; S4.

4. Evaluate the anomaly detection results output in step S4.3, and select precision, recall and F1 score as performance metrics.

5. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the anomaly detection method for drainage Internet of Things sensing data according to any one of claims 1-4.

6. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the anomaly detection method for drainage Internet of Things sensing data according to any one of claims 1-4.

Citation Information

Patent Citations

  • Abnormality detection model training method and device, and electronic equipment

    CN118804040A

  • Thermal power plant equipment defect intelligent monitoring and early warning method and system based on multi-modal large model

    CN120449035A