Sensor anomaly detection method and device based on long short-term memory network, electronic equipment and medium

By combining attention mechanism and long-term memory network (LSTM), the problem of insufficient capture of sensor data timing characteristics and lack of prediction capabilities is solved, and high-precision sensor abnormality detection is achieved, and powerful adaptability is achieved.

CN120105302APending Publication Date: 2025-06-06SHANGHAI INST OF TECH
View PDF 0 Cites 6 Cited by

Patent Information

Application Number
CN202510209746.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-25
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

When existing sensor detection methods process complex timing data, it is difficult to capture the time correlation and dynamic change characteristics of sensor data, resulting in insufficient recognition of complex anomaly patterns and lack of prediction and adaptability.

Method used

The sensor abnormality detection method based on long and short-term memory network (LSTM) is adopted, combined with the attention mechanism, and the detection accuracy and efficiency are significantly improved by pre-processing of sensor data, timing feature learning and prediction.

Benefits of technology

It significantly improves the accuracy and reliability of sensor abnormality detection, has prediction capabilities and adaptability, and can adapt to the characteristics of different sensors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120105302A_ABST
    Figure CN120105302A_ABST
Patent Text Reader

Abstract

The invention provides a sensor anomaly detection method and device based on a long short-term memory network, electronic equipment and a medium, which are applied to the technical field of fault detection, and effectively reduce data noise and improve the input quality of a model by performing preprocessing of null value removal and feature screening on acquired sensor data. Inputting the preprocessed sensor data into an improved attention mechanism-long and short-term memory network model, capturing a long-term dependency relationship of a time sequence by utilizing a long and short-term memory network, and dynamically distributing weights and focusing on key information by virtue of an attention mechanism, so that the model prediction precision is remarkably improved; and finally, the prediction result is compared with historical data and real-time data, so that the sensor abnormality is accurately judged, the defects of a traditional method in processing complex time sequence data are effectively overcome, the accuracy and reliability of abnormality detection are remarkably improved, and meanwhile, the method has prediction capability and adaptivity and is suitable for popularization and application. And characteristic differences of different sensors can be adapted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of fault detection technology, and specifically to a sensor anomaly detection method and device based on a long short-term memory network, an electronic device, and a medium. Background Art

[0002] During long-term use, sensors are easily affected by environmental fluctuations, equipment aging, and contaminant corrosion, which can lead to performance degradation and data distortion or abnormality. To ensure the accuracy of sensors, regular calibration and cleaning are usually required.

[0003] However, existing sensor detection methods have the following shortcomings when processing complex time series data:

[0004] On the one hand, the dynamic characteristics of time series are not captured enough. Sensor data has strong time correlation and dynamic evolution characteristics. Existing detection methods are difficult to capture the time correlation and dynamic change characteristics of sensor data, and have insufficient ability to identify complex abnormal patterns (such as drastic data fluctuations, abnormal distribution or irregular mutations). In addition, isolated analysis of a single dimension can easily lead to misjudgment or missed judgment.

[0005] Secondly, due to the lack of predictive capabilities and adaptability, existing detection methods only rely on historical data or real-time data for judgment, which makes it difficult to provide timely warnings of potential faults.

[0006] Although time series models such as long short-term memory networks (LSTM) can partially alleviate the above problems, LSTM models still face the problem of information forgetting when processing long sequences.

[0007] Based on this, a new sensor anomaly detection scheme is needed. Summary of the invention

[0008] In view of this, the embodiments of this specification provide a sensor anomaly detection method and device, electronic device, and medium based on a long short-term memory network. By combining the attention mechanism with the long short-term memory network (LSTM) model, the accuracy and efficiency of sensor anomaly detection are significantly improved.

[0009] The embodiments of this specification provide the following technical solutions:

[0010] The embodiment of this specification provides a sensor anomaly detection method based on a long short-term memory network, including:

[0011] Get sensor data;

[0012] Preprocessing the sensor data to obtain processed sensor data; wherein the preprocessing includes: removing null value processing and feature screening;

[0013] The processed sensor data is input into the attention mechanism-long short-term memory network model to perform temporal feature learning and prediction to obtain a prediction result;

[0014] Compare the prediction result with historical data and real-time data to determine whether the sensor is abnormal and obtain the sensor detection result;

[0015] The attention mechanism-long short-term memory network model combines the attention mechanism with the long short-term memory network model, including:

[0016] Use the input gate, forget gate, output gate and memory unit of the long short-term memory network model to calculate the hidden state at the current moment;

[0017] Based on the hidden states of all time steps, weights are dynamically assigned through the attention mechanism to generate a weighted context vector;

[0018] The context vector is combined with the final hidden state of the long short-term memory network model to output the prediction result.

[0019] The embodiment of this specification also provides a sensor abnormality detection device based on a long short-term memory network, including:

[0020] A data acquisition module, used to acquire sensor data;

[0021] A data preprocessing module is used to preprocess the sensor data to obtain processed sensor data; wherein the preprocessing includes: removing null value processing and feature screening;

[0022] A model prediction module, used for inputting the processed sensor data into the attention mechanism-long short-term memory network model to perform temporal feature learning and prediction to obtain a prediction result;

[0023] The attention mechanism-long short-term memory network model includes:

[0024] Use the input gate, forget gate, output gate and memory unit of the long short-term memory network model to calculate the hidden state at the current moment;

[0025] Based on the hidden states of all time steps, weights are dynamically assigned through the attention mechanism to generate a weighted context vector;

[0026] Combining the context vector with the final hidden state of the long short-term memory network model and outputting a prediction result;

[0027] The comprehensive judgment module is used to compare the prediction result with the historical data and the real-time data to judge whether the sensor is abnormal and obtain the detection result of the sensor.

[0028] An embodiment of the present specification also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute: a sensor anomaly detection method based on a long short-term memory network as described in any embodiment of the present application.

[0029] An embodiment of this specification also provides a computer storage medium, which stores computer executable instructions. When the computer executable instructions are executed by a processor, they execute: a sensor anomaly detection method based on a long short-term memory network as described in any embodiment of the present application.

[0030] Compared with the prior art, the at least one technical solution adopted in the embodiments of this specification can achieve the following beneficial effects:

[0031] By preprocessing the acquired sensor data by removing null values ​​and screening features, the data noise is effectively reduced and the input quality of the model is improved. The preprocessed sensor data is then input into the attention mechanism-long short-term memory network model. The long short-term memory network is used to capture the long-term dependencies of the time series. At the same time, the attention mechanism is used to dynamically allocate weights and focus on key information, thereby significantly improving the accuracy of the model prediction. Finally, the prediction results are compared with historical data and real-time data to achieve accurate judgment of sensor anomalies, effectively solving the shortcomings of traditional methods in processing complex time series data, and significantly improving the accuracy and reliability of anomaly detection. At the same time, it has predictive ability and adaptability, and can adapt to the characteristic differences of different sensors. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0033] Figure 1 is a flow chart of a sensor anomaly detection method based on long short-term memory network in this application;

[0034] Figure 2 It is an overall flow chart of a sensor anomaly detection method based on long short-term memory network in this application;

[0035] Figure 3 This is a sensor anomaly detection model framework diagram in this application. DETAILED DESCRIPTION

[0036] The embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0037] The following describes the implementation methods of the present application through specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, in the absence of conflict, the features in the following embodiments and embodiments can be combined with each other. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work belong to the scope of protection of the present application.

[0038] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present application, it should be understood by those skilled in the art that an aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number and aspect described herein can be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this device and / or practice this method.

[0039] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application. The drawings only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0040] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the examples can be practiced without these specific details.

[0041] Sensors need to be calibrated and cleaned regularly to ensure their accuracy. However, there is currently no unified standardized early warning mechanism to detect sensor failures, and sensors from different manufacturers may have different performance and failure characteristics. Traditional sensor anomaly detection methods based on long short-term memory networks usually rely on fixed thresholds or simple statistical features, and cannot effectively deal with complex anomalies caused by environmental changes, equipment aging, or emergencies. These methods are prone to false positives or false negatives, especially when dealing with systematic failures and occasional disturbances, changes in data distribution, severe volatility, or null value problems, and lack flexibility and adaptability.

[0042] In view of this, the inventors discovered through research and improvement exploration that the Long Short-Term Memory Network (LSTM) is a deep learning model specifically used to process time series data. Although it can effectively capture long-term dependencies in the data, the LSTM model may be limited by the problem of information forgetting when processing long time series, and it is difficult to focus on the characteristic information of key time points.

[0043] Based on this, the embodiment of this specification proposes a sensor anomaly detection method based on a long short-term memory network: Figure 1 As shown in the figure, the overall idea is: first, obtain the sensor data and preprocess it, including removing null values ​​and feature screening, so as to reduce data noise and improve input quality; then input the processed data into the attention mechanism-long short-term memory network (Attention-LSTM) model, use LSTM to capture the long-term dependencies of the time series, and dynamically allocate weights through the attention mechanism to focus on key information, so as to improve the prediction accuracy. Finally, compare the prediction results with historical data and real-time data, comprehensively judge whether the sensor is abnormal, and output the final detection results, thereby improving the reliability of sensor fault judgment.

[0044] The technical solutions provided by various embodiments of the present application are described below in conjunction with the accompanying drawings.

[0045] like Figure 1 and Figure 2 As shown, the embodiment of this specification provides a sensor anomaly detection method based on a long short-term memory network, including:

[0046] Step S1, obtaining sensor data.

[0047] Step S2: preprocess the sensor data to obtain processed sensor data; wherein the preprocessing includes: removing null value processing and feature screening.

[0048] Step S3, inputting the processed sensor data into the attention mechanism-long short-term memory network model to perform temporal feature learning and prediction to obtain a prediction result;

[0049] The attention mechanism-long short-term memory network model combines the attention mechanism with the long short-term memory network model, including:

[0050] Use the input gate, forget gate, output gate and memory unit of the long short-term memory network model to calculate the hidden state at the current moment;

[0051] Based on the hidden states of all time steps, weights are dynamically assigned through the attention mechanism to generate a weighted context vector;

[0052] The context vector is combined with the final hidden state of the long short-term memory network model to output the prediction result.

[0053] Specifically, if Figure 3 As shown in the figure, the processed data is used as the input of the Attention-LSTM model, the trained Attention-LSTM model is run, and the predicted value is directly output.

[0054] The Attention-LSTM model is as follows: By combining the LSTM model with Attention, the temporal dependency of data can be better captured. For LSTM, the input gate is updated according to the input at the current moment and the output at the previous moment, the forget gate controls the retention ratio of information, and the memory unit is updated according to the memory information c at the previous moment. t-1 , the current input information and the output information of the previous moment are used to update the memory unit state, and finally the output gate controls the output of the current moment information h t The calculation formula is as follows:

[0055] i t =σ(W i [h t-1 ,x t ]+b i );

[0056] f t =σ(W f [h t-1 ,x t ]+b f );

[0057] c t =f t c t-1 +i t tanh(W c [h t-1 ,x t ]+b c );

[0058] o t =σ(W o [h t-1 ,xt ]+b o );

[0059] h t =o t tanh(c t );

[0060] where i t , f t , o t , c t They refer to the states of the input gate, forget gate, output gate, and memory unit at time t respectively; W i , W f , W o , W c They refer to the weight matrices corresponding to the input vectors; b ia , b f , b c , b o They refer to the corresponding bias vectors respectively; σ refers to the Sigmoid activation function, tanh refers to the tanh activation function, and h t-1 is the output information of the previous moment, x t The input information at the current moment.

[0061] Regarding the attention mechanism: its core idea is to enable the model to focus on the most important part when processing data, and ignore or weaken irrelevant information. After obtaining the hidden state of all time steps of the above LSTM, the attention mechanism is applied to selectively focus on the hidden state. The specific calculation formula is as follows:

[0062] u t =tanh(W h h t +b h );

[0063]

[0064] where α t is the weighted coefficient of the proportion of each hidden layer state in the new hidden layer state; u s is a randomly initialized attention matrix, h t is the hidden layer output vector of LSTM, b h is the bias coefficient, and c is the output vector of the attention mechanism.

[0065] The output of LSTM combined with the attention mechanism is:

[0066] y=tanh(W c [c;h T ]+b c );

[0067] Where W c is the weight matrix used to combine the attention mechanism output vector and the last hidden state h T Projected to the output space, b c is the bias vector.

[0068] The y mentioned above is only a prediction data, which needs to be combined with historical data and real-time data, and a comprehensive judgment through multiple discrimination methods is used to give the final detection result.

[0069] Step S4: Compare the prediction result with the historical data and the real-time data to determine whether the sensor is abnormal and obtain the detection result of the sensor.

[0070] In some embodiments, the judgment includes 4 judgment methods: including the presence of a large number of null values, errors between actual values ​​and predicted values, drastic and irregular data fluctuations, and abnormal data distribution.

[0071] A large number of null values ​​appear: The number of null values ​​in the statistical data record N null and distribution, and compared with historical normal range for comparison.

[0072] The error between the actual value and the predicted value is: read and process real-time data, use the Attention-LSTM prediction model trained based on historical data to generate a predicted value, calculate and save the relative error between the actual value and the predicted value, and if the error continues to exceed the preset threshold, it is judged as a systematic anomaly. If the error occasionally exceeds the predicted value, it is judged as an occasional anomaly.

[0073] The data fluctuates violently and irregularly: Calculate the short-term fluctuation difference value of the data (Δx t =x t -x t-1 ) and compare it with the normal historical fluctuation range.

[0074] Data distribution anomaly is: using the statistical characteristic kurtosis of data distribution to compare with the historical normal data distribution to determine whether the current data deviates from the normal distribution range.

[0075] It should be noted that the determination of whether the number of null values ​​in the data exceeds the normal range, if so, determines it to be abnormal and directly outputs the abnormal information, if not, proceeds to the next step; if the error between the actual value and the predicted value is determined to be a systematic error, it indicates that the sensor has an abnormality and the process is directly determined and ended, if it is an occasional abnormality, continues to use other methods to determine, if the short-term fluctuation differential value of the data exceeds the normal fluctuation, determines it to be abnormal and outputs it together with the occasional abnormal information, otherwise proceeds to the next step to determine whether the data distribution deviates from the normal range, if deviates, determines it to be abnormal and outputs it together with the occasional abnormal information, otherwise the data is normal.

[0076] In the embodiments of this application, the Pytorch framework can be used. This framework is an open-source deep learning framework prioritizing Python, for Windows systems (CUDA, CPU), with powerful GPU accelerated computing performance. The model reads data from the interface and converts it into a list format for subsequent processing, and then performs null value processing and feature screening.

[0077] In some embodiments, when preprocessing the sensor data, the forward filling method is used to remove null values.

[0078] Specifically, the null values are processed by the forward filling method. For each null value in the data, it is filled with the previous valid non-null value to ensure the correlation and continuity of the time series.

[0079] The formula for the forward filling method is:

[0080] Where represents the i-th data point of the c-th feature at time t; represents the i-th data point of the c-th feature at time t - m, where m is the time span of forward filling; t > m means that time t must be greater than m, that is, the current time t must be after the time span m to perform the forward filling operation; i < c means that the filling operation is only for the first c features (i.e., features where i is less than c). The role of the formula is to fill in the missing values with the same feature data at the previous m moments when the data is missing.

[0081] In some embodiments, when preprocessing the sensor data, the random forest method is used for feature screening, including: evaluating the importance of features using the Gini coefficient; screening out key features based on the feature importance scores to reduce the data dimension.

[0082] Specifically, the data after null value processing is input into the random forest model to evaluate the data and obtain several features with the highest contribution to the prediction.

[0083] Feature screening is performed using the characteristics of the random forest method, and the contribution of features to the model prediction is measured by the Gini coefficient. In the first stage, the random forest model constructs multiple decision trees, performs multiple random samplings and feature selections on the input data, and generates multiple model results; at the same time, in each decision tree, the contribution of each feature to the node split is calculated based on the Gini coefficient. The importance score of a feature is the weighted average of the contributions of each feature to the Gini coefficient in all decision trees. Y represents the variable importance score, G represents the Gini index, X = {X 1 , X 2 , X 3 , …, X m} means there are m features, and now we need to calculate each feature X m Gini index score That is, the mth feature is the average variable of the node split impurity in all decision trees in the random forest. The formula of the Gini index of the i-th tree node n is as follows:

[0084]

[0085] Among them, k means there are k categories, P nk Indicates the proportion of category k in node n.

[0086] Feature X m The importance of node n in the ith tree, that is, the change in the Gini index before and after the node n branches is: in, and Respectively represent the Gini index of the two new nodes after branching. m The set of nodes that appear in decision tree i is N, then X m The importance of the i-th tree is:

[0087] Assuming there are I trees in the random forest, then: Finally, the importance score is normalized, and the formula is: Finally, the random forest feature screening method effectively identified the most critical features for the prediction task and reduced the feature dimension through feature importance evaluation based on the Gini coefficient.

[0088] In some embodiments, the results show the top features, such as the top five features, from high to low feature importance.

[0089] It should be noted that random forest is a non-parametric model that does not require any specific distribution assumptions for the data. Compared with some statistical methods, random forest can flexibly handle various types of data, including nonlinear relationships, noise, missing values, etc., and random forest can effectively handle high-dimensional data, and can automatically capture nonlinear relationships between features and identify key features during feature screening.

[0090] In some embodiments, the method of comparing the prediction result with historical data and real-time data includes the following:

[0091] Null value determination method, actual value and predicted value error determination method, data fluctuation abnormality determination method and data distribution abnormality determination method;

[0092] When any method determines that the sensor is abnormal, the abnormal determination result is directly output; if the current method cannot determine the abnormality, the next method is entered in turn for judgment, until all methods indicate that the sensor is normal, then the normal result of the sensor is output.

[0093] Specifically, the number of null values ​​N in the statistical data record null and distribution, and compared with historical normal range By comparison, if the number of null values ​​increases significantly (N null >T, T is the historical normal range null value threshold, set to 5%) or concentrated in a certain period of time, it is considered abnormal. The record details include timestamp, N null , Δx t And output sensor abnormal results.

[0094] If the data is normal after the null value determination, the second step of actual value and predicted value error determination is performed: the actual value y is read from the data interface to determine whether the actual value is a null value. If it is a null value, the relative error calculation step is skipped. If it is not a null value, the actual value y is calculated normally. t With the predicted value Relative error E: The actual value, predicted value and error are recorded in the database for subsequent analysis. The dynamic threshold T is calculated based on historical data, and the mean error μ is calculated according to the time window. E and standard deviation σ E , threshold T = μ E +3σ E If E>T, the current data is considered abnormal, otherwise the data is normal. For the data that is considered abnormal, detailed information is recorded, including timestamp, actual value, predicted value, error, and threshold.

[0095] It should be noted that if the error E exceeds the threshold continuously, it indicates sensor failure or environmental changes, and it is judged that a systematic abnormality occurs. If the error E occasionally exceeds the threshold, it is judged to be noise or short-term disturbance, and it is judged to be an occasional abnormality. If it is a systematic abnormality, the sensor abnormality result is directly output; if it is an occasional abnormality, it is judged in combination with data fluctuation abnormality and distribution abnormality.

[0096] The method for distinguishing abnormal data fluctuation in this embodiment is as follows: Calculate the short-term fluctuation difference value (Δx t =x t -x t-1 ) and compared with the historical normal fluctuation range. t ∈[Δx min ,Δx max ], if the fluctuation exceeds the normal range and has no periodic pattern, it is judged as abnormal fluctuation, and the detailed information recorded includes timestamp, Δx min, Δx max , Δx t , and combine the actual value and the predicted value error to determine the occasional abnormality and output information. If there is no abnormality, proceed to the next step.

[0097] Data distribution abnormality judgment method: Use the statistical characteristic kurtosis of data distribution to compare with the historical normal data distribution to determine whether the current data deviates from the normal distribution range. Calculate the kurtosis K of the current data distribution and compare it with the kurtosis K of the historical normal data distribution. n For comparison: If|KK n |>T, the data distribution is considered abnormal, where T is a fixed threshold of 10%, and the record details include timestamp, current data distribution kurtosis K, and historical normal data distribution kurtosis K n , combined with the actual value and the predicted value error, the occasional abnormality judgment result output information is used, otherwise the output sensor is normal.

[0098] In some embodiments, when comparing the prediction results with historical data and real-time data, the null value determination method is preferentially used.

[0099] In some embodiments, after the sensor data is subjected to feature screening, normalization processing is performed.

[0100] Specifically, the filtered and processed data are normalized using Min-Max: And input it into the trained Attention-LSTM model to ensure that the model weights are consistent with the training stage. By combining the time series modeling capability of LSTM and the attention mechanism, the model can focus on the most representative part of the data, thereby improving the accuracy of the prediction.

[0101] It should be noted that the long short-term memory network (LSTM) is a special recurrent neural network (RNN). By designing complex gating units: input gate, forget gate, and output gate, it solves the gradient vanishing and gradient exploding problems in traditional RNNs, and performs well in time-dependent problems. However, it still has some limitations, such as global information focusing. In order to solve the above problems, Attention is introduced to form the Attention-LSTM model. The Attention mechanism dynamically selects the most relevant part of the LSTM output, and weights the hidden state of the LSTM output to avoid LSTM over-reliance on long-term memory or premature forgetting of key information. The output of LSTM combined with the attention mechanism is: y=tanh(W c [c;h T ]+b c ), W c is the weight matrix used to combine the attention mechanism output vector and the last hidden state hT Projected to the output space, b c is the bias vector.

[0102] In some embodiments, the sensor acquires data in the following manner:

[0103] Data is read through a fixed interface, and the read data is stored as a list according to a preset time interval and window length.

[0104] Specifically, the .json format data is read through a fixed interface and stored in the same list. For example, the data read from the interface is in JSON format, the time interval can be set to 20 minutes, and the data within 48 hours before the current time can be read at once and converted into a list format.

[0105] Based on the same inventive concept, the present application also provides a sensor anomaly detection device based on a long short-term memory network, comprising:

[0106] A data acquisition module, used to acquire sensor data;

[0107] A data preprocessing module is used to preprocess the sensor data to obtain processed sensor data; wherein the preprocessing includes: removing null value processing and feature screening;

[0108] A model prediction module, used for inputting the processed sensor data into the attention mechanism-long short-term memory network model to perform temporal feature learning and prediction to obtain a prediction result;

[0109] The attention mechanism-long short-term memory network model includes:

[0110] Use the input gate, forget gate, output gate and memory unit of the long short-term memory network model to calculate the hidden state at the current moment;

[0111] Based on the hidden states of all time steps, weights are dynamically assigned through the attention mechanism to generate a weighted context vector;

[0112] Combining the context vector with the final hidden state of the long short-term memory network model and outputting a prediction result;

[0113] The comprehensive judgment module is used to compare the prediction result with the historical data and the real-time data to judge whether the sensor is abnormal and obtain the detection result of the sensor.

[0114] Based on the same inventive concept, the present application also provides an electronic device, including:

[0115] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute: a sensor anomaly detection method based on a long short-term memory network as described in any one of the embodiments of the present application.

[0116] Based on the same inventive concept, the present application also provides a computer storage medium, which stores computer executable instructions. When the computer executable instructions are executed by a processor, they execute: a sensor anomaly detection method based on a long short-term memory network as described in any embodiment of the present application.

[0117] It should be noted that the computer storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination thereof.

[0118] In a possible implementation, the present invention may also provide a form of a program product that implements data processing, which includes program code. When the program product runs on a terminal device, the program code is used to enable the terminal device to execute several steps of the method described in any of the aforementioned embodiments.

[0119] The program code for executing the present invention may be written in any combination of one or more programming languages, and may be executed entirely on a user device, partially on a user device, as an independent software package, partially on a user device and partially on a remote device, or entirely on a remote device.

[0120] The present application discloses a sensor anomaly detection method based on a long short-term memory network. The method obtains sensor-related information data through an interface, and inputs the processed data into an improved LSTM model to output prediction information through null value processing and feature screening. The method combines historical data with real-time data, and uses four methods, namely, a large number of null values, errors between actual values ​​and predicted values, drastic and irregular data fluctuations, and abnormal data distribution, to comprehensively judge abnormal information in multiple dimensions, and feeds back the information to the front-end display.

[0121] This application uses the Attention-LSTM model to predict data: the filtered and processed data is input into the Attention-LSTM model. By combining the time series modeling capability and attention mechanism of LSTM, the model can focus on the most representative part of the data, thereby improving the accuracy of the prediction. In the sensor fault warning process in different working environments, the present invention predicts data by using the corresponding data according to the characteristics of different scenarios.

[0122] Multi-dimensional comprehensive judgment: For abnormal situations in sensor data, the present invention proposes a specific data-driven judgment method. For situations such as a large number of null values, a huge gap between actual values ​​and predicted values, drastic and irregular data fluctuations, and a large number of abnormal values, the present invention uses multi-dimensional detection methods to make judgments, thereby improving the reliability of sensor fault judgment.

[0123] Result output: The present invention uses comprehensive analysis from multiple detection methods to ultimately determine whether the sensor is faulty. Combining the results of multiple detection methods, it can comprehensively evaluate the abnormality of sensor data, thereby reducing the risk of misjudgment that may be caused by a single method.

[0124] In this specification, the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the embodiments described later, the description is relatively simple, and the relevant parts can be referred to the partial description of the previous embodiments.

[0125] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A sensor anomaly detection method based on long short-term memory network, characterized in that: include: Get sensor data; Preprocessing the sensor data to obtain processed sensor data; wherein the preprocessing includes: removing null value processing and feature screening; The processed sensor data is input into the attention mechanism-long short-term memory network model to perform temporal feature learning and prediction to obtain a prediction result; Compare the prediction result with historical data and real-time data to determine whether the sensor is abnormal and obtain the sensor detection result; The attention mechanism-long short-term memory network model combines the attention mechanism with the long short-term memory network model, including: Use the input gate, forget gate, output gate and memory unit of the long short-term memory network model to calculate the hidden state at the current moment; Based on the hidden states of all time steps, weights are dynamically assigned through the attention mechanism to generate a weighted context vector; The context vector is combined with the final hidden state of the long short-term memory network model to output the prediction result.

2. The sensor anomaly detection method based on long short-term memory network according to claim 1 is characterized in that: When preprocessing the sensor data, a random forest method is used for feature screening, including: Use the Gini coefficient to assess feature importance; Filter out key features based on feature importance scores and reduce data dimensions.

3. The sensor anomaly detection method based on long short-term memory network according to claim 1 is characterized in that: When preprocessing the sensor data, a forward filling method is used to remove null values.

4. The sensor anomaly detection method based on long short-term memory network according to claim 1 is characterized in that: The method of comparing the prediction result with historical data and real-time data includes the following: Null value determination method, actual value and predicted value error determination method, data fluctuation abnormality determination method and data distribution abnormality determination method; When any method determines that the sensor is abnormal, the abnormality determination result is directly output; If the current method cannot determine the abnormality, the next method will be entered in turn for judgment until all methods indicate that the sensor is normal, then the result of the sensor being normal is output.

5. The sensor anomaly detection method based on long short-term memory network according to claim 4 is characterized in that: When comparing the prediction results with historical data and real-time data, the null value determination method is preferably used.

6. The sensor anomaly detection method based on long short-term memory network according to claim 1 is characterized in that: After the sensor data is subjected to feature screening, normalization processing is performed.

7. The sensor anomaly detection method based on long short-term memory network according to claim 1 is characterized in that: The sensor acquires data in the following ways: Data is read through a fixed interface, and the read data is stored as a list according to a preset time interval and window length.

8. A sensor anomaly detection device based on long short-term memory network, characterized in that: include: A data acquisition module, used to acquire sensor data; A data preprocessing module is used to preprocess the sensor data to obtain processed sensor data; wherein the preprocessing includes: removing null value processing and feature screening; A model prediction module, used for inputting the processed sensor data into the attention mechanism-long short-term memory network model to perform temporal feature learning and prediction to obtain a prediction result; The attention mechanism-long short-term memory network model includes: Use the input gate, forget gate, output gate and memory unit of the long short-term memory network model to calculate the hidden state at the current moment; Based on the hidden states of all time steps, weights are dynamically assigned through the attention mechanism to generate a weighted context vector; Combining the context vector with the final hidden state of the long short-term memory network model and outputting a prediction result; The comprehensive judgment module is used to compare the prediction result with the historical data and the real-time data to judge whether the sensor is abnormal and obtain the detection result of the sensor.

9. An electronic device, characterized in that: include: at least one processor; And, a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute: the sensor anomaly detection method based on the long short-term memory network as described in any one of claims 1-7.

10. A computer storage medium, characterized in that: The computer storage medium stores computer executable instructions, and when the computer executable instructions are executed by the processor, the sensor anomaly detection method based on long short-term memory network as described in any one of claims 1-7 is performed.

Citation Information

Cited By

  • Cross-application sandbox penetration protection system and method based on hardware assistance

    CN120449149A

  • Hybrid fault-tolerant control method and system for multi-sensor simultaneous fault scene

    CN120491421A

  • Online monitoring method and system for magnesium powder production process

    CN120595695A

  • Chip data detection method and system based on artificial intelligence

    CN120629905A

  • Abnormal feature analysis method for complex metering sensor based on long-term accumulated data

    CN120832626A