Agricultural machine operation data cleaning method based on Bi-LSTM-AE attention mechanism
By adopting the Bi-LSTM-AE attention mechanism in the processing of agricultural machinery operation data, combining the bidirectional LSTM network and the self-encoder, the self-attention mechanism is introduced, which solves the abnormality and noise problems in agricultural machinery operation data, and improves the data quality and Accuracy of abnormal detection.
Patent Information
- Application Number
- CN202411410058.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-02-07
AI Technical Summary
Due to the influence of field environment, operating conditions and agricultural machinery itself, agricultural machinery operation data often contains a large amount of abnormal and noise data, which affects the accuracy and reliability of subsequent data analysis and application.
Using the Bi-LSTM-AE attention mechanism, the data cleaning method of agricultural machinery operation is combined with the autoencoder AE through a bidirectional LSTM network, and the self-attention mechanism module is introduced to build the Bi-LSTM-AE abnormality detection model and perform data pre-data Process and model training to detect and remove exception data.
Effectively process timing characteristics, adapt to the complexity and characteristics of agricultural machinery operation data, improve data quality, improve the accuracy and robustness of abnormal detection, and solve the problem of relatively few abnormal data and no labels.
Smart Images

Figure CN119396812A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of agricultural machinery operation data processing, and specifically relates to an agricultural machinery operation data cleaning method based on a Bi-LSTM-AE attention mechanism. Background Art
[0002] In the field of digital agriculture, the collection and analysis of agricultural machinery operation data has become the key to improving agricultural production efficiency and intelligent decision-making. Accurate and efficient data cleaning methods can improve the reliability and timeliness of platform analysis and decision-making, and are an important cornerstone for the development of agricultural machinery big data platforms. However, the complex field operation conditions increase the probability of data anomalies. In actual work, due to the field environment, operating conditions, agricultural machinery's own factors affecting sensor detection accuracy, and the field environment affecting the quality of information upload, agricultural machinery operation data often contains a large amount of anomalies and noise. These abnormal data may affect the accuracy and reliability of subsequent data analysis and application.
[0003] Traditional methods for detecting anomalies in agricultural machinery operation data mainly include rule-based, statistical-based, and traditional machine learning methods. When the data volume is small and the dimension is low, these methods can provide a certain degree of anomaly detection, but they cannot fully explore the potential characteristics of the data, capture insufficient time series features, or make significant changes to the original data. There are often limitations when processing large-scale, high-dimensional, and strongly spatiotemporally correlated data such as agricultural machinery operation data.
[0004] Therefore, a data processing method is needed that can better handle time series characteristics and adapt to the complexity and characteristics of agricultural machinery operation data. Summary of the invention
[0005] In view of this, in order to solve the shortcomings of the above-mentioned prior art, the purpose of the present invention is to provide an agricultural machinery operation data cleaning method based on the Bi-LSTM-AE attention mechanism, construct a Bi-LSTM-AE anomaly detection model, add an attention module, and use the characteristics of LSTM in processing time series and the advantages of AE in extracting the essential features of data for agricultural machinery data anomaly detection tasks, which can better adapt to the complexity and characteristics of agricultural machinery operation data.
[0006] To achieve the above purpose, the technical solution adopted by the present invention is: A method for cleaning agricultural machinery operation data based on Bi-LSTM-AE attention mechanism, comprising the following steps: S1. Obtain the time series data of agricultural machinery operation and divide the original data into a training data set and a test data set; S2, perform data preprocessing and use the isolation forest algorithm to clean the training set data; S3, using a bidirectional LSTM network combined with an autoencoder AE, and introducing a self-attention mechanism module to build a Bi-LSTM-AE anomaly detection model; S4, input the preprocessed training set data into the Bi-LSTM-AE model for training, reconstruct the training set, and save the optimal parameters of the Bi-LSTM-AE anomaly detection model; S5, input the standardized test set data into the best trained model, calculate the reconstruction error, and judge the abnormal data according to the set threshold, and output the test results; S6: Verification of algorithm effectiveness.
[0007] Furthermore, the data set is specifically divided as follows: Select a time point in the time series data as the dividing line, select the last 30% of the time series data as the test set, and use the previous part as the training set.
[0008] Furthermore, the S2 specifically includes the following sub-steps: S21, standardize the two data sets respectively; S22, using the isolation forest algorithm to mine and clean the training data set to obtain a training set after removing abnormalities; S23. Use a sliding window to segment the training set output by S22 into sequences of fixed length.
[0009] Furthermore, the S22 specifically includes the following contents: A. To deal with missing values in data, use interpolation method to replace missing values with mean; B. Processing of data outliers: iForest algorithm is used to quickly detect outliers in data;
[0010] Specifically, step B includes the following sub-steps: B1. Randomly select a feature from the data set and randomly select a value of the feature as the segmentation threshold; B2, split the data into two subsets using the selected features and thresholds to build an isolation tree; B3. Repeat steps B1-B2 to repeatedly build multiple isolated trees to build an isolation forest. B4. Traverse each isolated tree, calculate the path length in each isolated tree and calculate the anomaly score; B5. Set the anomaly score threshold and determine whether the data is abnormal based on the anomaly score.
[0011] As an option, the two subsets in step B2 have the following characteristics: One subset contains data points less than or equal to the split threshold, and the other subset contains data points greater than the split threshold.
[0012] Furthermore, the Bi-LSTM-AE anomaly detection model in S3 adopts an encoder-decoder structure, in which the encoder is composed of a bidirectional LSTM network, and an attention mechanism is added to the encoder to further enhance the model's attention to key time steps.
[0013] Furthermore, the S4 specifically includes the following sub-steps: S41, inputting the encoding result of the encoder into the decoder, performing reconstruction error analysis, and determining a preliminary threshold; S42, judging whether the reconstruction error is stable and whether the evaluation index is optimal, if yes, jump to step S46, otherwise proceed to step S43; S43. Adjust the number of model layers, training times, and the number of neurons in each layer. S44, using the back propagation algorithm to adjust the model parameters; S45, using the Adam optimizer to optimize the parameters, and inputting them into S41 again; S46. Stop training and save the current model as the best model.
[0014] Furthermore, during the model training process, the loss function is the average of the squares of the errors between the original data and the reconstructed data, as follows: Among them, N represents the amount of training data, y i represents the true value of the i-th input, Represents the predicted value corresponding to the i-th input.
[0015] Furthermore, the S5 includes the following contents: Input the test set into the best model to obtain the data reconstruction error and determine whether the data reconstruction error is greater than the final threshold: If the error exceeds the final threshold, it is considered as abnormal data, and the abnormal point data is replaced by the predicted value of the Bi-LSTM-AE model; Otherwise, there is no exception.
[0016] Furthermore, the determination of the final threshold value specifically includes the following steps: The average of the training set loss values is used as the initial threshold 1 ; Treat the training set loss as a set of sample data, fit the Gaussian mixture model, identify the different distribution patterns of the loss value, and then determine the GMM threshold2 ; The thresholds determined above are weighted to determine the final threshold threshold.
[0017] Furthermore, the algorithm effectiveness verification evaluation indicators include anomaly detection performance using accuracy, precision, recall rate and F1 score.
[0018] The beneficial effects of the present invention are: 1. In the prior art, anomaly detection usually faces the problems of scarcity of abnormal label data and constant changes in abnormal behavior patterns. The present invention adopts a method of modeling normal data to enable a neural network to learn the characteristics of normal data and then realize abnormal pattern recognition, which better solves the problem of relatively few and unlabeled abnormal data faced by agricultural machinery operation data; 2. By taking advantage of the long-term memory capacity of the LSTM deep model and the feature extraction and data reconstruction capabilities of the AE model, the LSTM-AE model is constructed by introducing LSTM neurons into the autoencoder architecture; the noise points in the original data are removed, the data quality is improved, the location, time, speed and other features contained in the agricultural machinery GPS data are mined, and the sequence is mapped to a unified low-dimensional vector; the spatiotemporal characteristics of the data are fully considered, which is more in line with the actual application scenario of anomaly detection of time series data generated during agricultural machinery operations; 3. During the modeling process, an attention mechanism module is added to the encoder, so that the model can pay more attention to the key time steps related to anomaly detection; the encoder part uses a bidirectional LSTM, which can simultaneously obtain information of the previous and next time steps at the current time step. The forward LSTM layer is responsible for sequential training and learning features in historical data; the backward LSTM layer is trained in reverse order to learn features in future data, so that a more accurate prediction effect can be obtained than a unidirectional LSTM neural network; 4. In the process of determining the threshold, the present invention combines the traditional threshold determination method with the Gaussian mixture model (GMM), making the threshold setting more accurate and improving the reliability and accuracy of anomaly detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 It is a schematic diagram of the process of cleaning agricultural machinery operation data of the present invention; Figure 2This is a flow chart of outlier processing using isolation forest in the training set preprocessing stage of the present invention; Figure 3 This is a schematic diagram of the normal points after the isolation forest isolating the normal points and abnormal points; Figure 4 This is a schematic diagram of the outliers after the isolation forest isolating the normal points and outliers. Figure 5 This is the Bi-LSTM-AE model architecture diagram of the present invention; Figure 6 This is the LSTM structure diagram of the present invention; Figure 7 This is the loss distribution diagram of the BLAE attention model training in Example 2 of the present invention; Figure 8 This is the loss distribution diagram of the BLAE attention model test in Example 2 of the present invention; Fig. 9 Schematic diagram of the results of anomaly detection using the BLAE attention model in Example 2 of the present invention. DETAILED DESCRIPTION
[0021] The following specific examples are given to further clearly, completely and in detail illustrate the technical solution of the present invention. This example is the best example based on the technical solution of the present invention, but the protection scope of the present invention is not limited to the following examples.
[0022] Example 1 A method for cleaning agricultural machinery operation data based on Bi-LSTM-AE attention mechanism. The specific steps are as follows: Step 1: Obtain the time series data of agricultural machinery operations and divide the original data into a training data set and a test data set; The time series data of the agricultural machinery working are collected from agricultural machinery sensors or recording devices, wherein the agricultural machinery working data consists of longitude, latitude, speed, altitude, heading deviation and lateral deviation.
[0023] Furthermore, the data set is divided specifically as follows: a time point is selected in the time series data as a dividing line, the last 30% of the time series data is selected as a test set, and the previous part is used as a training set.
[0024] Step 2: Perform data preprocessing and use the isolation forest algorithm to clean the training set data, which includes the following sub-steps: S21. Standardize the two data sets respectively. Considering the sensitivity of LSTM model to different data, it is necessary to normalize the original data. The linear transformation of the original data makes the result value mapped to [0,1]. The dimension effect is eliminated by normalization to facilitate the subsequent model processing. The conversion function is as follows: Among them, X is the original data set data, X max is the maximum value of the sample data, X min is the minimum value of the sample data, X n is the data after normalization; S22. Use the isolation forest algorithm to mine and clean the training data set to obtain a training set after removing abnormalities; specifically, the following contents are included: A. To deal with missing values in the data, we use interpolation to replace missing values with mean values; for the agricultural machinery operation data sequence x={x 0 ,x 1 ,x 2 ,nan,x 4 ,x 5 ...x n}, where nan is a missing value, and the method of filling nan is expressed by the formula: Among them, x j are the known non-missing data points, and n is the number of known data points. B. Processing of data outliers: iForest algorithm is used to quickly detect outliers in data; S23. Use a sliding window to segment the training set output by S22 into sequences of fixed length.
[0025] Furthermore, the step B for outlier processing includes the following sub-steps: B1. Randomly select a feature from the data set and randomly select a value of the feature as the segmentation threshold; B2. Build an isolated tree: Use the selected features and thresholds to split the data into two subsets, one subset contains data points less than or equal to the split threshold, and the other subset contains data points greater than the split threshold; after constructing a binary tree, perform the above process on the left and right subtrees respectively until one tree is built; B3. Repeat steps B1-B2 to repeatedly build multiple isolated trees to construct an isolation forest. Each isolated tree is built independently, using different randomly selected features and thresholds. B4. Traverse each isolated tree, let it traverse each isolated tree, calculate the path length in each isolated tree and calculate the anomaly score; For each data point, the average of its normalized path lengths in all isolated trees is calculated as the final anomaly score; this average anomaly score can indicate the degree of anomaly of the data point, the higher the score, the more abnormal it is; and the final average path length of the data is calculated. The anomaly score s(x) can be calculated using the following formula: Among them, E(h(x)) represents the average path length of the data point x in the isolation forest, and c(n) is the average path length of the isolation forest, and its value is determined by the following formula: H(i) is the harmonic number, n is the number of samples in the data set; B5. Set the anomaly score threshold and determine whether the data is abnormal based on the anomaly score.
[0026] Furthermore, the present invention uses a sliding window to divide the time series data into several fixed-length sequences, which helps capture the relationship and continuity between sequences and helps the model capture time dependencies. Assuming the sliding window width is W and the sliding step is S, if the sample sequence length is N, the number of subsequences is:
[0027] In the training and testing phases, through the sliding window, when the input D T-w To D T-1 When the data is D, the predicted value at time T is output (that is, the data D T ), each time sliding down with a step size S. In the experiment, the sequence length is a hyperparameter, and the window width can be adjusted to divide the sequence into different lengths to train and test the model to determine which sequence length can achieve the best model performance.
[0028] Step 3: Use a bidirectional LSTM network combined with an autoencoder AE to build a Bi-LSTM-AE anomaly detection model. Specifically, the Bi-LSTM-AE anomaly detection model uses an encoder-decoder structure, in which the encoder is composed of a bidirectional LSTM network to better capture the front-end dependency of the input sequence. An attention mechanism is added to the encoder to further enhance the model's attention to key time steps. The attention mechanism can dynamically assign weights so that the model pays more attention to the time points of abnormal features during the reconstruction process, thereby improving detection accuracy. This combination not only improves the model's ability to extract time series features, but also enhances the accuracy and robustness of anomaly detection.
[0029] Furthermore, the Bi-LSTM-AE anomaly detection model construction process is as follows: S31. In LSTM, there are three types of gated units: forget gate, input gate, and output gate. Through the synergy of these gates, information discarding and memorization are completed, thereby effectively processing long sequence data. The forward LSTM layer is responsible for sequential training and learning features in historical data. The backward LSTM layer performs reverse training and learns features in future data.
[0030] (1) The forward LSTM layer operation is as follows: Forget Gate: Input Gate: Update Gate: Cell Status: Output Gate: Hidden state:
[0031] (2) The backward LSTM layer operation is as follows: Forget Gate: Input Gate: Update Gate: Cell Status: Output Gate: Hidden state: Where σ represents the sigmoid activation function, W and b represent the weight and bias parameters respectively, and x represents the output of the unit module at time t-1 in the forward / backward layer. t represents the vector representation of the t-th time step of the input sequence, and Respectively represent the cell states of the forward layer and the backward layer at time step t, and They represent the hidden states of the forward layer and the backward layer at time step t respectively.
[0032] (3) Calculate the total output value of the Bi-LSTM network model: At time t, the total output value of the Bi-LSTM structure is the sum of the outputs of the forward LSTM layer and the backward LSTM layer. The calculation is as follows: Among them, x t , are the input data at time t, the forward LSTM hidden layer output, and the reverse LSTM hidden layer output; α and β are constant coefficients, representing The weight of .
[0033] S32. Autoencoder (AE) is an unsupervised neural network model, which is mainly used for data dimensionality reduction and feature extraction. The structure of the autoencoder model consists of two parts: encoder and decoder. The encoder maps the input data x to a set of latent variables, and then the decoder reconstructs the data from the latent space. In the encoder, the high-dimensional input data is compressed into a low-dimensional vector. The compressed low-dimensional vector can retain the typical characteristics of the input data. This process can be expressed as: h t =σ e (Wx+b); In the decoder, the low-dimensional vector h t is reconstructed into the original data, and the operation is: y t =σ d (W′h t + b′); Where x is the input data, y is the reconstructed output data, W and b are the weight and bias parameters during encoding, W′ and b′ are the weight and bias parameters for decoding, and σ e , σ d is the sigmoid activation function for encoding and decoding.
[0034] S33. Add attention mechanism: In the Bi-LSTM-AE model, the attention mechanism is added in the encoding stage to better capture the multi-dimensional time series dependencies and improve the reconstruction accuracy and anomaly detection accuracy. The specific process is as follows: First, the attention weight is calculated. Each hidden state sequence ht in the Bi-LSTM network is input into the attention layer, and the similarity with the global context vector is calculated through a feedforward neural network to obtain the attention weight: e t =v·tanh(W h ·h t +b h ); Among them, v, W h and b h are the parameters for learning. Then, the similarity scores are normalized using the softmax function to obtain the attention weight α for each time step t : Among them, t′ represents the index of all time steps; Finally, the attention weights are used to perform weighted averaging on the hidden states ht of all time steps to obtain the context vector c: c=∑ t α t h t ; In the encoding stage, the context vector c generated by the attention mechanism will be passed to the decoder as part of the encoding result.
[0035] Step 4: Input the preprocessed training set data into the Bi-LSTM encoder for training, perform reconstruction training of the training set, and save the Bi-LSTM-AE anomaly detection model and parameters. Specifically, it includes the following sub-steps: S41, inputting the encoding result of the encoder into the Bi-LSTM decoder, performing reconstruction error analysis, and determining a preliminary threshold; S42, judging whether the reconstruction error is stable and whether the evaluation index is optimal, if yes, jump to step S46, otherwise proceed to step S43; S43. Adjust the number of model layers, training times, and the number of neurons in each layer. S44, using a back propagation algorithm to adjust the parameters of the model. The back propagation algorithm starts from the loss function, reversely calculates the influence of each parameter in the model on the loss function, and obtains the gradient value of each parameter; S45, using the Adam optimizer to optimize the parameters, and inputting them into S41 again; After each round of training, the parameters are updated through the Adam optimizer, specifically the weights and bias parameters in the network model are adjusted. The Adam optimizer fine-tunes the learning rate according to the gradient information of the current parameters to ensure that a better solution can be converged during the training process and the loss function is minimized. S46. Get the fitting value, stop training, and save the current model as the best model.
[0036] Furthermore, during the model training process, the loss function is the average of the squares of the errors between the original data and the reconstructed data, as follows: Among them, N represents the amount of training data, y i represents the true value of the i-th input, Represents the predicted value corresponding to the i-th input.
[0037] Step 5: Input the preprocessed test set data into the trained model, calculate the reconstruction error, and output the test results, including the following: Determine the reconstruction error of the data and judge whether the data reconstruction error is greater than the final threshold. In the test set, when the loss value of a certain time step exceeds the final threshold, the point is marked as abnormal data: If the error exceeds the final threshold, it is considered as abnormal data, and the abnormal point data is replaced by the predicted value of the Bi-LSTM-AE model; Otherwise, there is no exception.
[0038] Furthermore, the determination of the final threshold value specifically includes the following steps: The average of the training set loss values is used as the initial threshold 1 ; Treat the training set loss as a set of sample data, fit the Gaussian mixture model, identify different distribution patterns of loss values, and then determine the threshold 2 ; The thresholds determined above are weighted to determine the final threshold threshold.
[0039] Step 6: Verify the effectiveness of the algorithm, including the effectiveness of abnormal data identification and repair: S61. Anomaly detection performance Precision (Precision, Pre), recall (Recall, Rec) and F1 score are used to evaluate the anomaly detection performance of the model. The calculation of the four evaluation indicators is as follows: Among them, TP represents the number of true positive examples, that is, the actual situation and the test result are both normal samples; FP represents the number of false positive examples, that is, the actual situation is an abnormal sample and the test result is a normal sample; TN represents the number of true negative examples, indicating that the actual situation and the test result are both abnormal samples; FN represents the number of false negative examples, indicating that the actual situation is a normal sample and the test result is an abnormal sample; S62, the effectiveness of data restoration is evaluated by the root mean square error, which is calculated as follows: Among them, n is the number of abnormal data, y i ′ is abnormal data, It is the abnormal data after repair.
[0040] Step 7: Send the real-time collected time series data into the trained anomaly detection model to determine whether anomalies occur.
[0041] Example 2 In this embodiment, based on the method in Embodiment 1, data is processed, including the following contents: Step 1: Collect the original data set; The original data set is a GPS data set collected by the original multi-dimensional agricultural machinery during operation. The data set was collected on a farm during the wheat harvest season in mid-June 2024. The data volume is sufficient and the source is reliable.
[0042] The original data set of this embodiment includes various data parameters, as shown in Table 1: Table 1 Field Name Parameter Type Parameter Description Time_stamp string Positioning time (UTC time zone) Lat double Latitude (degrees) Latdir string Latitude direction (N: North latitude, S: South latitude) Lon double Longitude (degrees) Londir string Longitude direction (E: East longitude, W: West longitude) Height double Altitude (m) Speed double Speed (km / h) Heading double Heading angle (0~360 degrees) Heading_error double Course deviation (degrees) Lateral_error double Lateral deviation(m) Step 2: Preprocess the original data set and obtain the standard data set; The agricultural machinery work data is divided into a training set and a test set. The training set is first tested for isolated points, and then the cleaned data set is normalized. The isolation forest algorithm is used to detect the number of isolated points in the training set data. Among them, the altitude, heading angle and lateral deviation are relatively stable, and there are a small number of isolated points. The longitude and latitude are affected by the external environment, and there are a large number of isolated points in the data. The isolated points in the speed and heading deviation data are more obvious, which seriously affects the data balance.
[0043] The isolated point detection results are shown in Table 2: Table 2 The detected isolated points are replaced by interpolation to obtain clean training set data. The data is scaled to the range of [0,1] using Min-Max normalization to obtain a standard data set.
[0044] Step 3: Training data; first divide the standardized data into different sequences using the sliding window technology. In this example, the time step time_step is set to 20; adjust the input data shape to three-dimensional data as the input of the LSTM-AE model. The hyperparameter settings of the LSTM-AE neural network model are shown in Table 3: Table 3 Parameter name Parameter meaning Parameter Value Optimizer Optimizer Adam Learning Rate Learning Rate Dynamic adjustment (0.0001~0.001) Batch size Batch training samples 64 Epochs Training rounds 150 Drop Rate Discard rate 0.2 L2_regularization_strength L2 Regularization 0.001
[0045] Step 4: Anomaly detection; First, determine the threshold. The specific method is: first set a preliminary threshold based on the average value of the training set loss value. Use the training set loss value as sample data and fit it using the Gaussian mixture model (GMM) to identify different distribution patterns of the loss value. For each Gaussian component, calculate its mean μ and standard deviation σ, and determine a new threshold by setting a confidence interval. Finally, combine the preliminary threshold and the threshold determined by GMM through a weighted method to obtain the final threshold.
[0046] Step 5: Input the data into the network model and evaluate the performance of the algorithm by calculating the accuracy, recall, accuracy and F1-Score. The method provided by this solution can effectively detect abnormal points and abnormal areas in agricultural machinery working data, which is significantly superior to other methods. The abnormal detection results are compared in Table 4: Table 4 By analyzing the above table, it can be seen that the BLAE proposed in the present invention attention The model shows significant superiority in anomaly detection. Specifically, BLAE attention The recall rate of the model reached 94.83%, which was 19.57%, 7.74% and 2.04% higher than that of the AE, LAE and BLAE models respectively. attention The F1 score of the model reached 94.05%, which was 21.67%, 9.86% and 1.7% higher than that of the AE, LAE and BLAE models, respectively. This shows that BLAE attention The model not only has higher accuracy in identifying anomalies, but also can achieve more comprehensive and accurate anomaly detection while maintaining a low false positive rate, reflecting its multi-dimensional advantages.
[0047] The above shows and describes the main features, basic principles and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited by the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements according to actual conditions, and these changes and improvements fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. The agricultural machinery operation data cleaning method based on Bi-LSTM-AE attention mechanism is characterized by: The following steps are involved: S1. Obtain the time series data of agricultural machinery operation and divide the original data into a training data set and a test data set; S2, perform data preprocessing and use the isolation forest algorithm to clean the training set data; S3, using a bidirectional LSTM network combined with an autoencoder and introducing a self-attention mechanism module to build an anomaly detection model with a Bi-LSTM-AE attention mechanism; S4, input the preprocessed training set data into the Bi-LSTM-AE model for training, reconstruct the training set, and save the optimal parameters of the Bi-LSTM-AE anomaly detection model; S5, input the standardized test set data into the best trained model, calculate the reconstruction error, and judge the abnormal data according to the set threshold, and output the test results; S6. Verification of algorithm effectiveness.
2. The agricultural machinery operation data cleaning method based on the Bi-LSTM-AE attention mechanism according to claim 1 is characterized in that: The S2 specifically includes the following sub-steps: S21, standardize the two data sets respectively; S22, using the isolation forest algorithm to mine and clean the training data set to obtain a training set after removing abnormalities; S23. Use a sliding window to segment the training set output by S22 into sequences of fixed length.
3. The agricultural machinery operation data cleaning method based on the Bi-LSTM-AE attention mechanism according to claim 2 is characterized in that: The S22 specifically includes the following contents: A. To deal with missing values in data, use interpolation method to replace missing values with mean; B. Processing of outliers in data: iForest algorithm is used to quickly detect outliers in data; specifically, the following sub-steps are included: B1. Randomly select a feature from the data set and randomly select a value of the feature as the segmentation threshold; B2, split the data into two subsets using the selected features and thresholds to build an isolation tree; B3. Repeat steps B1-B2 to repeatedly build multiple isolated trees to build an isolation forest. B4. Traverse each isolated tree, calculate the path length in each isolated tree and calculate the anomaly score; B5. Set the anomaly score threshold and determine whether the data is abnormal based on the anomaly score.
4. The agricultural machinery operation data cleaning method based on the Bi-LSTM-AE attention mechanism according to claim 3 is characterized in that: The two subsets in step B2 have the following characteristics: One subset contains data points less than or equal to the split threshold, and the other subset contains data points greater than the split threshold.
5. The agricultural machinery operation data cleaning method based on the Bi-LSTM-AE attention mechanism according to claim 1 is characterized in that: The Bi-LSTM-AE anomaly detection model in S3 adopts an encoder-decoder structure, in which the encoder is composed of a bidirectional LSTM network, and an attention mechanism is added to the encoder to further enhance the model's attention to key time steps.
6. The agricultural machinery operation data cleaning method based on Bi-LSTM-AE attention mechanism according to claim 1 is characterized in that: The S4 specifically includes the following sub-steps: S41, input the encoding result of the encoder into the decoder, perform reconstruction error analysis, and determine the initial threshold value threshol d1 ; S42, judging whether the reconstruction error is stable and whether the evaluation index is optimal, if yes, jump to step S46, otherwise proceed to step S43; S43, adjust the number of model layers, training times, and the number of neurons in each layer; S44, using the back propagation algorithm to adjust the model in reverse; S45, use Adam optimizer to optimize the parameters, adjust the weights and biases of the input gate and output gate, and input them into S41 again; S46. Stop training and save the current model as the best model.
7. The agricultural machinery operation data cleaning method based on Bi-LSTM-AE attention mechanism according to claim 6 is characterized in that: During model training, the loss function is the average of the squares of the errors between the original data and the reconstructed data, as follows: Among them, N represents the amount of training data, y i represents the true value of the i-th input, Represents the predicted value corresponding to the i-th input.
8. The agricultural machinery operation data cleaning method based on Bi-LSTM-AE attention mechanism according to claim 1 is characterized in that: The S5 includes the following contents: Input the test set into the best model to obtain the data reconstruction error and determine whether the data reconstruction error is greater than the final threshold: If the error exceeds the final threshold, it is considered as abnormal data, and the abnormal point data is replaced by the predicted value of the Bi-LSTM-AE model; Otherwise, there is no exception.
9. The agricultural machinery operation data cleaning method based on the Bi-LSTM-AE attention mechanism according to any one of claims 6 to 8, characterized in that: The determination of the final threshold value specifically includes the following steps: a. Take the average of the training set loss values as the initial threshold value d1 ; b. Treat the training set loss as a set of sample data, fit the Gaussian mixture model, set the confidence interval to identify different distribution patterns of the loss value, and then determine the GMM threshold threshold2; c. The preliminary threshold and GMM threshold are weighted to determine the final threshold: threshold=α·threshold1+(1-α)·threshold2; Here, α is a weight parameter used to balance the preliminary threshold based on the mean and the threshold determined by GMM.
10. The agricultural machinery operation data cleaning method based on Bi-LSTM-AE attention mechanism according to claim 1 is characterized in that: The algorithm effectiveness verification evaluation indicators include anomaly detection performance using accuracy, precision, recall rate and F1 score.
Citation Information
Cited By
Processing data quality monitoring system and method based on machine learning
CN120541730A
Memory bank test method and test machine
CN120544656A