Abnormality detection method for multi-sensor signals, electronic equipment and medium
The integration of KAN networks and Transformer encoding with confidence intervals addresses inefficiencies in multi-sensor anomaly detection, enhancing accuracy and reliability in identifying complex patterns and anomalies.
Patent Information
- Application Number
- CN202411349609.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-09-26
AI Technical Summary
Existing anomaly detection methods struggle with handling diverse scenarios, require large datasets, or rely on empirical formulas, leading to inefficiencies in identifying complex patterns and anomalies in multi-sensor signals.
A method combining KAN networks and Transformer encoding layers to process multi-sensor signals, utilizing position-encoded data, confidence intervals, and dynamic thresholds to accurately identify anomalies, reducing false positives and negatives.
Enhances anomaly detection accuracy by capturing complex patterns and quantifying uncertainty, improving the reliability of abnormality judgments across multiple sensors.
Smart Images

Figure CN119202994A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data anomaly detection, and in particular to an anomaly detection method, electronic equipment, and medium for multi-sensor signals. Background Art
[0002] At present, the main methods in the field of data anomaly detection mainly include statistical methods, machine learning-based methods and deep learning-based methods. Statistical methods such as Z-Score, IQR and Grubbs'test detect outliers through mathematical formulas, but they need to build models in advance and cannot cope with different scenarios and conditions; machine learning-based methods include isolation forest, support vector machine (SVM) and K-Means clustering, etc., which identify abnormal patterns through training data models, but require a large amount of data to build models and have a single scenario; deep learning-based methods such as autoencoders and long short-term memory networks (LSTM) can process complex high-dimensional data and capture anomalies in time series, but they are often based on empirical formulas in the judgment of outliers. Summary of the invention
[0003] In view of the deficiencies in the prior art, the present invention provides a method for detecting anomalies of multi-sensor signals, electronic equipment and a medium.
[0004] In a first aspect, an embodiment of the present invention provides a method for detecting anomalies of multi-sensor signals, characterized in that the method comprises:
[0005] Obtain historical measurement data of the target sensor and preprocess it to obtain time series data;
[0006] Position-encode the time series data, add the position-encoded data to the time series data, and use them as the first input data; set the batch size, and randomly extract from the first input data according to the batch size to obtain the first tensor;
[0007] The first input data is processed by the first KAN network, the Transformer encoding layer, the first Transformer decoding layer, and the second KAN network to obtain the first output data;
[0008] The difference between the first tensor and the first output data is used as the second input data;
[0009] The second input data is processed by the second Transformer decoding layer, the linear layer, and the activation function to obtain the second output data;
[0010] Calculate the 2-norm of the first output data and the 2-norm of the difference between the second output data and the first tensor and sample them to obtain first sample data and second sample data respectively;
[0011] Calculate the sample mean, sample variance, and standard error corresponding to the first sample data and the second sample data, thereby obtaining a first confidence interval and a second confidence interval; and use the sum of the first confidence interval and the second confidence interval as the overall dynamic threshold interval;
[0012] When the sum of the 2-norm of the first output data corresponding to the to-be-detected data of the sensor and the 2-norm of the difference between the second output data and the first tensor does not belong to the overall dynamic threshold interval, a first abnormal label is output;
[0013] and / or,
[0014] Obtain historical measurement data of T sensors around the target sensor;
[0015] Calculate the sample mean, sample standard deviation, and standard error corresponding to the historical measurement data of T sensors to obtain the confidence interval;
[0016] When the data to be detected of the i-th sensor around the target sensor does not belong to the confidence interval, the i-th sensor at that moment is judged to be abnormal, and the second abnormal label is output.
[0017] In a second aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the above-mentioned multi-sensor signal anomaly detection method.
[0018] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the above-mentioned method for detecting anomalies of multi-sensor signals.
[0019] In a fourth aspect, an embodiment of the present invention provides a computer program product, including a computer program / instruction, which implements the above-mentioned multi-sensor signal anomaly detection method when executed by a processor.
[0020] Compared with the prior art, the present invention has the following beneficial effects:
[0021] (1) The present invention combines the KAN network and Transformer encoding to better capture the complex patterns and features in the data, reduce false positives and false negatives, and improve the accuracy of anomaly detection.
[0022] (2) The present invention sets the overall dynamic threshold interval in combination with the confidence interval, which can quantify the uncertainty of the model prediction results and improve the accuracy of abnormal judgment.
[0023] (3) The present invention calculates the sample mean, sample standard deviation, and standard error corresponding to the historical measurement data of T sensors around the target sensor through the historical measurement data of T sensors, thereby obtaining a confidence interval; the abnormal sensor among all sensors can be determined in the same time period. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0025] Figure 1 A schematic diagram of a first embodiment of a method for detecting abnormality of multi-sensor signals provided by an embodiment of the present invention;
[0026] Figure 2 A schematic diagram of a second embodiment of the method for detecting abnormality of multi-sensor signals provided by an embodiment of the present invention;
[0027] Figure 3 A schematic diagram of an anomaly detection network provided by an embodiment of the present invention;
[0028] Figure 4 A schematic diagram of a KAN network provided by an embodiment of the present invention;
[0029] Figure 5 A schematic diagram of applying the multi-sensor signal anomaly detection method provided in an embodiment of the present invention to tobacco mildew detection;
[0030] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0031] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0032] It should be noted that, in the absence of conflict, the features in the following embodiments and implementations may be combined with each other.
[0033] like Figure 1 and Figure 2 As shown, an embodiment of the present invention provides a method for detecting anomalies of multi-sensor signals, and the method specifically includes the following steps:
[0034] Step S101, acquiring historical measurement data of a target sensor and preprocessing the data to obtain time series data.
[0035] Furthermore, the historical measurement data of the target sensor is obtained and cleaned. If missing data is encountered, the mean of the recorded data before and after is taken to fill in the missing data, and X = {x(1), x(2), .., x(L)} is obtained. For each point x(i)∈R m is an m-dimensional vector, in this example m=2.
[0036] The data X is standardized using Min-Max to obtain y={y(1), y(2), .., y(L)}.
[0037] Use a sliding window to divide the time series data y, set the window size to w=100, the step size s=1, and divide the time series data Y={Y(1), Y(2), .., Y=(K)}, where K=L-99, and Y(i) is a 100*2 matrix.
[0038] Step S102, position-encode the time series data Y, add the position-encoded data PE to the time series data Y as the first input data T; set the batch size, and randomly extract from the first input data according to the batch size to obtain the first tensor.
[0039] Furthermore, using sine and cosine function encoding, for the p-th position in the sequence and the i-th dimension in the feature dimension, the position encoding formula is as follows:
[0040]
[0041] Furthermore, BatchSize is 64, and random batches are taken from Y to obtain the first tensor B = {B(1), B(2), .., B(J)}, where Where B(i) is a tensor of 64*100*2.
[0042] Furthermore, the position-encoded data PE is added to the timing data Y as the first input data T; T=PE+Y, T={T(1), T(2), .., T(K)}.
[0043] Step S103, as Figure 3 As shown, the first input data is processed by the first KAN network, the Transformer encoding layer, the first Transformer decoding layer, and the second KAN network to obtain the first output data P.
[0044] Among them, the structure of the first KAN network is as follows Figure 4As shown: the input is Feats, the input of the first and second layers is 2*Feats-1, the output of the third layer is Feats, and the activation function of each layer is the Spline activation function, and its formula is:
[0045]
[0046] where c i is the parameter that needs to be optimized during training, B i (x) is the B-spline basis function defined on the grid.
[0047] Step S104, taking the difference between the first tensor P and the first output data B as the second input data P1, that is, P1=BP; the second input data is processed by the second Transformer decoding layer, the linear layer, and the Sigmoid activation function to obtain the second output data P2.
[0048] Furthermore, the method further comprises:
[0049] Set the loss function, and optimize the first KAN network, Transformer encoding layer, first Transformer decoding layer, second KAN network, second Transformer decoding layer, and linear layer based on the loss function;
[0050] The expression of the loss function is as follows:
[0051] LOSS=MinMax(||P1||2)(||P2-B||2)
[0052] In the formula, P1 represents the first output data, P2 represents the second output data, and B represents the first tensor.
[0053] Step S105, calculate the 2-norm ||P1||2 of the first output data and the 2-norm ||P2-B||2 of the difference between the second output data and the first tensor and sample them to obtain first sample data and second sample data respectively.
[0054] Furthermore, for the 2-norm of the first output data ||P1||2 and the 2-norm of the difference between the second output data and the first tensor ||P2-B||2, a group of α points are randomly sampled, and a total of β groups are collected (in this example, a group of 30 points is randomly sampled, and a total of 100 groups are collected), and the average of each group of data is taken to obtain the first sample data G(1)={g1, g2, .., g β}, the second sample data G(2) = {g1, g2, .., g β}.
[0055] Step S106, calculate the sample mean, sample variance, and standard error corresponding to the first sample data and the second sample data, thereby obtaining a first confidence interval and a second confidence interval; and use the sum of the first confidence interval and the second confidence interval as the overall dynamic threshold interval.
[0056] Further, the first sample mean corresponding to the first sample data is calculated The first sample variance s 2 (1), first standard error SE(1);
[0057] in,
[0058]
[0059] Where n is the number of samples, i = 1, 2;
[0060] Calculate the second sample mean corresponding to the second sample data The second sample variance s 2 (2), second standard error SE(2);
[0061] Calculate the first confidence interval as follows:
[0062]
[0063] Calculate the second confidence interval as follows:
[0064]
[0065] In the formula, Z is the confidence level; it needs to be found in the table. For a 95% confidence level, the Z value is 1.96;
[0066] The sum of the first confidence interval and the second confidence interval is taken as the overall dynamic threshold interval CIA, that is, CIA=CI(1)+CI(2).
[0067] Step S107, processing the data to be detected by the sensor, when the sum of the 2-norm of the first output data corresponding to the data to be detected by the sensor and the 2-norm of the difference between the second output data and the first tensor does not belong to the overall dynamic threshold interval, that is Then output the first abnormal label.
[0068] and / or,
[0069] Step S100, obtaining historical measurement data X of T sensors around the target sensor T ={x 1 ,x 2 ,...,x T}.
[0070] Step S200 , calculating the sample mean, sample standard deviation, and standard error corresponding to the historical measurement data of T sensors, so as to obtain a confidence interval.
[0071] Furthermore, the sample mean corresponding to the historical measurement data of T sensors is calculated Calculate the sample standard deviation s and the standard error SE;
[0072]
[0073] The expression for calculating the confidence interval CI is as follows:
[0074]
[0075] Where t represents the t value found from the t distribution table for a 95% confidence level. For a 95% confidence level, t≈2.262.
[0076] Step S300: When the data to be detected of the i-th sensor around the target sensor does not belong to the confidence interval, it is determined that the i-th sensor at this moment is abnormal, and a second abnormal label is output.
[0077] Furthermore, when the data to be detected by the i-th sensor around the target sensor does not belong to the confidence interval, that is, Then the i-th sensor is judged to be abnormal at this moment, and the abnormal value is set to 1, γ i =1;
[0078] Continuously record the total number of abnormal values Y per unit time i =∑γ i ; When the sum of abnormal values is greater than the threshold, the i-th sensor in the unit time interval is determined to be abnormal.
[0079] Example 1
[0080] like Figure 5 As shown, an embodiment of the present invention provides a method for detecting abnormalities of multi-sensor signals, which is used to detect data abnormalities caused by mildew during the aging process of tobacco slices, thereby reducing the risk of mildew during the curing process of tobacco slices. The method specifically includes the following steps:
[0081] Step S101, acquiring historical measurement data of a target sensor and preprocessing the data to obtain time series data;
[0082] Step S102, position encoding the time series data, adding the position-encoded data to the time series data as first input data; setting a batch size, randomly extracting from the first input data according to the batch size, and obtaining a first tensor;
[0083] Step S103, the first input data is processed by the first KAN network, the Transformer encoding layer, the first Transformer decoding layer, and the second KAN network to obtain first output data;
[0084] Step S104, taking the difference between the first tensor and the first output data as the second input data; the second input data is processed by the second Transformer decoding layer, the linear layer, and the activation function to obtain the second output data;
[0085] Step S105, calculating the 2-norm of the first output data and the 2-norm of the difference between the second output data and the first tensor and sampling them to obtain first sample data and second sample data respectively;
[0086] Step S106, calculating the sample mean, sample variance, and standard error corresponding to the first sample data and the second sample data, thereby obtaining a first confidence interval and a second confidence interval; taking the sum of the first confidence interval and the second confidence interval as the overall dynamic threshold interval;
[0087] Step S107: when the sum of the 2-norm of the first output data corresponding to the to-be-detected data of the sensor and the 2-norm of the difference between the second output data and the first tensor does not belong to the overall dynamic threshold interval, outputting a first abnormal label;
[0088] and / or,
[0089] Step S100, acquiring historical measurement data of T sensors around the target sensor; the distance between the sensors does not exceed 10m.
[0090] Step S200, calculating the sample mean, sample standard deviation, and standard error corresponding to the historical measurement data of T sensors, thereby obtaining a confidence interval;
[0091] Step S300: When the data to be detected of the i-th sensor around the target sensor does not belong to the confidence interval, it is determined that the i-th sensor at this moment is abnormal, and a second abnormal label is output.
[0092] It should be noted that the first abnormal label indicates that a large number of sensor detections are involved in the aging process of tobacco leaves. Due to network transmission failures, internal failures or external interference, these data generate a series of abnormal data at the data level. These data are reflected in the time series as noise, collective anomalies and contextual anomalies. These data are not conducive to reflecting the real data of each dimension of the cigarette package, and the corresponding sensors need to be processed in a timely manner.
[0093] At the same time, because the internal tobacco leaves slowly mold, the sensor data of the moldy part will be different from other sensors. This kind of data anomaly is difficult to identify with the naked eye. It is necessary to identify the sensors with differences among all sensors in the same time period. The second abnormal label indicates the abnormality of the data caused by the chemical changes of the tobacco leaves inside the tobacco pack during the aging process.
[0094] Accordingly, the present application also provides an electronic device, comprising: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned abnormality detection method. Figure 6 As shown, it is a hardware structure diagram of any device with data processing capability where the abnormality detection method provided by the embodiment of the present invention is located, except Figure 6 In addition to the processor, memory and network interface shown, any device with data processing capability in which the apparatus in the embodiment is located may also include other hardware, generally based on the actual functions of the device with data processing capability, which will not be described in detail.
[0095] Accordingly, the present application also provides a computer-readable storage medium on which computer instructions are stored, and when the instructions are executed by a processor, the above-mentioned abnormality detection method is implemented. The computer-readable storage medium can be an internal storage unit of any device with data processing capabilities described in any of the aforementioned embodiments, such as a hard disk or a memory. The computer-readable storage medium can also be an external storage device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), an SD card, a flash card (Flash Card), etc. equipped on the device. Furthermore, the computer-readable storage medium can also include both an internal storage unit of any device with data processing capabilities and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by any device with data processing capabilities, and can also be used to temporarily store data that has been output or is to be output.
[0096] The above embodiments are only used to illustrate the design ideas and features of the present invention, and their purpose is to enable those skilled in the art to understand the content of the present invention and implement it accordingly. The protection scope of the present invention is not limited to the above embodiments. Therefore, any equivalent changes or modifications made based on the principles and design ideas disclosed by the present invention are within the protection scope of the present invention.
Claims
1. A method for detecting anomalies of multi-sensor signals, characterized in that: The method comprises: Obtain historical measurement data of the target sensor and preprocess it to obtain time series data; Position-encode the time series data, add the position-encoded data to the time series data, and use them as the first input data; set the batch size, and randomly extract from the first input data according to the batch size to obtain the first tensor; The first input data is processed by the first KAN network, the Transformer encoding layer, the first Transformer decoding layer, and the second KAN network to obtain the first output data; The difference between the first tensor and the first output data is used as the second input data; The second input data is processed by the second Transformer decoding layer, the linear layer, and the activation function to obtain the second output data; Calculate the 2-norm of the first output data and the 2-norm of the difference between the second output data and the first tensor and sample them to obtain first sample data and second sample data respectively; Calculate the sample mean, sample variance, and standard error corresponding to the first sample data and the second sample data, thereby obtaining a first confidence interval and a second confidence interval; and use the sum of the first confidence interval and the second confidence interval as the overall dynamic threshold interval; When the sum of the 2-norm of the first output data corresponding to the to-be-detected data of the sensor and the 2-norm of the difference between the second output data and the first tensor does not belong to the overall dynamic threshold interval, a first abnormal label is output; and / or, Obtain historical measurement data of T sensors around the target sensor; Calculate the sample mean, sample standard deviation, and standard error corresponding to the historical measurement data of T sensors to obtain the confidence interval; When the data to be detected of the i-th sensor around the target sensor does not belong to the confidence interval, the i-th sensor at that moment is judged to be abnormal, and the second abnormal label is output.
2. The method for detecting anomalies of multi-sensor signals according to claim 1, characterized in that: Obtain historical measurement data of the target sensor and preprocess it to obtain time series data including: The historical measurement data of the target sensor is cleaned, normalized, and processed using a sliding window to obtain time series data.
3. The method for detecting anomalies of multi-sensor signals according to claim 1, characterized in that: The method further comprises: Set the loss function, and optimize the first KAN network, Transformer encoding layer, first Transformer decoding layer, second KAN network, second Transformer decoding layer, and linear layer based on the loss function; The expression of the loss function is as follows: LOSS=MinMax(‖P1‖2)(‖P2-B‖2) In the formula, P1 represents the first output data, P2 represents the second output data, and B represents the first tensor.
4. The method for detecting abnormality of multi-sensor signals according to claim 1, characterized in that: Sampling the 2-norm of the first output data and the 2-norm of the difference between the second output data and the first tensor to obtain first sample data and second sample data respectively includes: The 2-norm of the first output data ‖P1‖2, and the 2-norm of the difference between the second output data and the first tensor ‖P2-B‖2, perform a random sampling of a group of α points, collect β groups in total, take the mean of each group of data, and obtain the first sample data G(1) = {g1, g2, .., g β }, the second sample data G(2) = {g1, g2, .., g β }.
5. The method for detecting anomalies of multi-sensor signals according to claim 1, characterized in that: Calculate the sample mean, sample variance, and standard error corresponding to the first sample data and the second sample data, thereby obtaining a first confidence interval and a second confidence interval; The sum of the first confidence interval and the second confidence interval is taken as the overall dynamic threshold interval including: Calculate the first sample mean corresponding to the first sample data The first sample variance s 2 (1), first standard error SE(1); Calculate the second sample mean corresponding to the second sample data The second sample variance s 2 (2), second standard error SE(2); Calculate the first confidence interval as follows: Calculate the second confidence interval using the following expression: Where Z is the confidence level; The sum of the first confidence interval and the second confidence interval is taken as the overall dynamic threshold interval CIA.
6. The method for detecting abnormality of multi-sensor signals according to claim 1, characterized in that: The process of calculating the sample mean, sample standard deviation, and standard error corresponding to the historical measurement data of T sensors to obtain the confidence interval includes: Calculate the sample mean corresponding to the historical measurement data of T sensors Calculate the sample standard deviation s and the standard error SE; The expression for calculating the confidence interval CI is as follows: Where t represents the t value found from the t distribution table for a 95% confidence level.
7. The method for detecting abnormality of multi-sensor signals according to claim 1, characterized in that: When the data to be detected of the i-th sensor around the target sensor does not belong to the confidence interval, the i-th sensor abnormality at that moment is determined to include: When the data to be detected of the i-th sensor around the target sensor does not belong to the confidence interval, the i-th sensor at that moment is considered abnormal, and the abnormal value is set to 1; The sum of abnormal values within a unit time is continuously recorded; when the sum of abnormal values is greater than the threshold, the i-th sensor within the unit time interval is determined to be abnormal.
8. An electronic device, comprising a memory and a processor, characterized in that: The memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the multi-sensor signal anomaly detection method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for detecting abnormalities of multi-sensor signals as described in any one of claims 1 to 7 is implemented.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the method for detecting anomalies of multi-sensor signals described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Large model compression method and system based on KAN network
CN118673969A
Abnormality detector of multisensor signal and abnormality detecting method of multisensor signal
JP2006317194A
Face detection method
US20210056293A1
Cited By
Anomaly processing system and warehousing management system
WO2026200465A1
