Pesticide residue prediction method based on LSTM variant

By using the LSTM variant model of removing the output activation function in pesticide residue testing, and deploying on the edge equipment, combined with the dynamic threshold adjustment mechanism, the real -time and accuracy of pesticide residue detection in existing technologies has been solved. , Convenient pesticide residue management.

CN119359084AActive Publication Date: 2025-01-24GUIZHOU UNIV

Patent Information

Application Number
CN202411470340.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-01-24
Estimated Expiration
2044-10-21

AI Technical Summary

Technical Problem

The existing pesticide residue detection methods have problems such as long detection cycle, high cost, and professional operation, which are difficult to achieve real-time monitoring and prediction. In addition, traditional timing models show limitations when dealing with changes in complex pesticide residues, and it is difficult to capture nonlinear change characteristics.

Method used

Adopt pesticide residue prediction methods based on LSTM variants, to remove the output activation function and introduce the direct output channel of the cell status, enhance the ability to capture the non -linear change of pesticide residues, and deploy a model on the edge equipment to achieve real -time prediction, combined with the dynamic threshold value, combined with the dynamic threshold value The adjustment mechanism meets the residual standards of different pesticides.

Benefits of technology

It significantly improves the ability to capture non-linear changes in pesticide residues, realizes real-time prediction and alarm, improves the accuracy and applicability of prediction, reduces computing resource consumption, and is suitable for rapid response to needs in agricultural production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119359084A_ABST
    Figure CN119359084A_ABST
Patent Text Reader

Abstract

The invention discloses a pesticide residue prediction method based on an LSTM variant, and relates to the technical field of pesticide residue detection and prediction.The method comprises the steps that time sequence data such as temperature, humidity, soil pH value, rainfall and pesticide application concentration are collected through a sensor, and normalization, missing value filling and sliding window slicing treatment are conducted; an optimized LSTM variant model is adopted for modeling, and an output activation function is removed to enhance the capacity of capturing nonlinear changes of pesticide residues. The model is combined with a dynamic threshold adjustment mechanism, adapts to characteristics and residue standards of different pesticides, and can be deployed on edge equipment in real time to realize real-time alarm when residues exceed the standard. Compared with the prior art, the method has the remarkable advantages in the aspects of prediction precision, response speed and adaptability, and is suitable for pesticide residue monitoring in various agricultural scenes such as rice fields and orchards.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of pesticide residue detection and prediction, and in particular to a pesticide residue prediction method based on LSTM variant. Background Art

[0002] Pesticides are widely used in modern agriculture to increase crop yields and prevent and control pests and diseases, but their residues have always been a major challenge to food safety and environmental pollution. Existing pesticide residue detection mainly relies on laboratory analysis methods such as gas chromatography, high-performance liquid chromatography and mass spectrometry. Although these methods have high accuracy, they have problems such as long detection cycles, high costs, and professional operation requirements, making it difficult to achieve real-time monitoring and prediction of pesticide residues.

[0003] In order to make up for the limitations of traditional detection methods, a series of time series prediction technologies based on machine learning and deep learning have emerged in recent years. These technologies can model historical data and predict future residual trends. However, the existing prediction technologies mainly have the following problems: Insufficient nonlinear modeling capabilities: Traditional time series models (such as ARIMA, SARIMA, etc.) often show limitations when dealing with complex changes in pesticide residues. It is difficult to capture the nonlinear change characteristics of residues after application, resulting in low prediction accuracy.

[0004] Limited adaptability to multivariate data: Changes in pesticide residues are affected by many factors, including temperature, humidity, soil conditions, pesticide concentration, rainfall, etc. Most existing models have difficulty in effectively modeling pesticide residues under multivariate conditions, especially lacking the ability to respond to short-term residue fluctuations after pesticide application.

[0005] Poor real-time performance: Traditional prediction models usually rely on cloud computing for data processing and model reasoning, which not only increases the delay of network transmission, but may also affect the timeliness of prediction due to network instability, and cannot meet the demand for rapid response in agricultural production.

[0006] In view of the above problems, LSTM (Long Short-Term Memory Network), as a deep learning model that can capture long-term dependencies, has shown good performance in time series prediction. However, when dealing with complex time series such as pesticide residues, standard LSTM still has problems such as insufficient nonlinear processing capabilities and limited model generalization capabilities. In addition, existing LSTM models generally require high computing resource support and are difficult to deploy on site. Therefore, a pesticide residue prediction method based on LSTM variants is proposed. Summary of the invention

[0007] The purpose of the present invention is to provide a pesticide residue prediction method based on LSTM variants. By removing the output activation function, introducing the cell state direct output channel and other structural optimizations, the ability to capture nonlinear changes in pesticide residues is significantly improved. At the same time, the model can realize real-time prediction on edge devices and adapt to the residue standards of different pesticides through a dynamic threshold adjustment mechanism, which greatly improves the accuracy, real-time and applicability of the prediction. This innovative residue prediction method overcomes the limitations of the prior art and can provide agricultural producers with an efficient and convenient pesticide residue management solution to solve the problems raised in the above background technology.

[0008] In order to solve the above technical problems, the technical solution adopted by the present invention is: A pesticide residue prediction method based on LSTM variant, including: Obtain time series data from target farmland samples. The data includes parameters directly related to pesticide application, such as application frequency, application concentration, farmland moisture, soil temperature, soil pH, crop growth stage, climate change factors, etc. Use normalization and missing value filling to ensure the integrity of time series data; Convert time series data into input-output pairs through sliding window slicing technique; Build and train a deep learning model based on LSTM variants to output whether the predicted pesticide residue level meets the safety standard.

[0009] Preferred: LSTM variants are further specified to remove the output activation function to adapt to the nonlinear changes in pesticide residue concentrations and directly pass the cell state to the next time step, thereby more accurately capturing the complex temporal dependencies in the pesticide degradation process.

[0010] Preferred: The preprocessing of time series data is optimized for the residual changes in the short term after application, focusing on the data within 48 hours after application, and adopting a high-frequency sampling strategy to capture the rapid degradation characteristics of pesticides.

[0011] Preferably, the LSTM variant adopts a three-layer stacked structure, each layer contains at least 128 hidden units, and introduces a variable-length cell state retention mechanism to enhance adaptability to pesticide residue fluctuations.

[0012] Preferred: Normalization uses a specialized residue normalization factor to adjust the data to a distribution pattern that matches the specific physical and chemical properties of the target pesticide so that the model can more accurately understand the residue characteristics of the pesticide under different environmental conditions.

[0013] Preferred: The window length of the sliding window slice is dynamically adjusted according to the crop type, soil type and the physicochemical properties of the specific pesticide, and a shorter time step is set in the key degradation stage after application to enhance the model's responsiveness to residue dynamics.

[0014] Preferred: The model training process uses the Adam optimizer with an initial learning rate of 0.001, and a regularization term with a time decay factor is introduced to ensure the robustness of the model in handling pesticide residue prediction tasks.

[0015] Preferred: The evaluation phase of the model is optimized using a pesticide residue-specific loss function that takes into account the deviation between the predicted residue value and the actual detected value, the toxicity threshold of the pesticide, and the toxicological properties of different pesticides in crops and the environment.

[0016] Preferred: The data preprocessing process is optimized for specific pesticide residue standards, and a dynamic threshold adjustment strategy is used to meet the legal residue standards of different pesticides.

[0017] Preferably: the sliding window slices adopt an overlapping strategy, and the sliding step size is dynamically adjusted according to the half-life of different pesticides to better adapt to the degradation rate and residual variation of the pesticides.

[0018] Preferred: The cross-validation used in the model training process adopts a data segmentation method specific to the pesticide residue scenario to ensure that both the training data set and the test data set contain time points before and after application of the pesticide and during the degradation period.

[0019] Preferred: The hidden layer of the model introduces a pesticide degradation-specific attention mechanism to enhance the model's perception of residue changes within a specific time step.

[0020] Preferred: The quantization of the model adopts mixed precision training technology, which reduces the consumption of computing resources by converting some calculations into 16-bit floating point numbers and ensures the accuracy of pesticide residue prediction results at important thresholds.

[0021] Preferred: When the model is deployed to the edge device, it integrates the on-site real-time data processing module, including continuous monitoring of sensor data, dynamic prediction and residual over-limit alarm functions.

[0022] Preferred: Edge devices can achieve regular updates of the model and integration of new pesticide residue data through wireless synchronization with the central database, thereby improving the model's adaptability and prediction accuracy for new pesticides.

[0023] Due to the adoption of the above technical solution, the present invention has the following technical advances compared with the prior art: 1. The present invention provides a pesticide residue prediction method based on LSTM variants. By removing the output activation function of LSTM and directly outputting it on the cell state, the ability to capture nonlinear changes in pesticide residues is enhanced. Compared with traditional LSTM or other time series models (such as ARIMA, GRU), this LSTM variant is more suitable for processing the rapid changes and long-term dependence characteristics of pesticide residue concentrations, especially for the dynamic residue situation within 48 hours after application.

[0024] 2. The present invention provides a pesticide residue prediction method based on LSTM variants. By introducing a dynamic threshold adjustment mechanism, it can be personalized according to the physicochemical properties of specific pesticides and legal residue standards (such as EU MRL, EPA Tolerance, etc.). This flexibility not only improves the applicability to a variety of pesticides, but also accurately detects excess residues, significantly enhancing the adaptability of pesticide residue prediction in a variety of scenarios. Traditional models usually use fixed thresholds, which are difficult to accurately apply in multi-pesticide scenarios.

[0025] 3. The present invention provides a pesticide residue prediction method based on LSTM variants. By deploying the LSTM variant model on edge devices, real-time data processing and prediction are achieved. The edge device can not only quickly process the newly collected data on site, but also immediately issue an alarm when the residue exceeds the standard, thereby improving the efficiency of detection and response. This distributed real-time processing mode reduces the delay of network transmission, greatly shortens the prediction and response time, and is more suitable for application in agricultural scenarios that require rapid response.

[0026] 4. The present invention provides a pesticide residue prediction method based on LSTM variants, which adopts the overlapping strategy of sliding windows and mixed precision training technology. While improving data utilization, it also optimizes the consumption of computing resources. The sliding window slicing process can fully cover the details in the time series, and the mixed precision training reduces the memory usage and computing burden in the model reasoning process, making the present invention more efficient and cost-effective.

[0027] 5. The present invention provides a pesticide residue prediction method based on LSTM variants. Traditional time series prediction models usually require high computing resources to process complex long time series, while the present invention can achieve high-precision prediction on relatively low-configuration edge devices.

[0028] 6. The present invention provides a pesticide residue prediction method based on LSTM variants. In the data preprocessing and model training stages, the physical and chemical properties of specific pesticides (such as imidacloprid) and their residue patterns in specific crops (such as rice) are combined. The prediction accuracy of the model in specific pesticide application scenarios is improved through a special residue normalization factor and time series feature extraction method. Compared with the existing general residue prediction model, the present invention is customized according to the characteristics of different pesticides, and the applicability and prediction accuracy are significantly improved.

[0029] 7. The present invention provides a pesticide residue prediction method based on LSTM variants. Through the online update mechanism of the central server, the LSTM variant model can be dynamically adjusted and optimized with the introduction of new pesticides and the accumulation of data. This adaptive capability ensures the long-term effectiveness of the model and avoids the limitation of the prior art that the model needs to be frequently manually retrained. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 It is a framework diagram of the pesticide residue prediction method based on LSTM variant of the present invention; Figure 2 This is a data comparison diagram before and after normalization of the present invention; Figure 3 This is a diagram showing the effect of filling missing values ​​in the present invention; Figure 4 This is a sliding window slicing effect diagram of the present invention; Figure 5 Schematic diagram of input-output data flow of LSTM variant of the present invention; Figure 6 A comparison diagram of the predicted value and the dynamic threshold value of the present invention; Figure 7 This is a visualization diagram of the real-time prediction of data flow according to the present invention. DETAILED DESCRIPTION

[0031] The present invention is further described in detail below in conjunction with embodiments: like Figure 1 As shown, the present invention provides a pesticide residue prediction method based on LSTM variant, including: obtaining time series data from target farmland samples, the data including parameters directly related to pesticide application, such as application frequency, application concentration, farmland humidity, soil temperature, soil pH value, crop growth stage, climate change factors, etc.; using normalization processing and missing value filling to ensure the integrity of time series data; converting time series data into input-output pairs through sliding window slicing technology; constructing and training a deep learning model based on LSTM variant, and outputting whether the predicted pesticide residue level meets the safety standard.

[0032] The following is explained in conjunction with an embodiment: Example 1 like Figure 1-7 As shown, the present invention provides a pesticide residue prediction method based on LSTM variants, including: time series data collection and preprocessing, model construction and training based on LSTM variants, dynamic threshold adjustment and model optimization, model deployment and real-time prediction on edge devices, and model update and adaptive optimization. Through a series of optimization measures, the prediction model can more accurately and efficiently adapt to the residual characteristics of specific pesticides under different environmental conditions.

[0033] 1. Time series data collection and preprocessing Multi-parameter sensor nodes are deployed in the target farmland environment to monitor and collect time series data related to pesticide application in real time, including temperature, humidity, soil pH, rainfall, wind speed, and historical pesticide residue concentrations. The collection frequency is set to once every 15 minutes to capture rapid residue changes after pesticide application.

[0034] The preprocessing steps are as follows: Normalization: Perform Z-score standardization on the collected data to ensure that the mean of the model input is 0 and the standard deviation is 1, which facilitates the sensitivity and adaptability of the model to the data.

[0035] Missing value filling: Use interpolation, historical average filling or K nearest neighbor method (KNN) to fill missing values ​​to ensure the continuity and integrity of data. When selecting the filling method, dynamically adjust it according to the specific data collection conditions.

[0036] Sliding window slicing: Slice the time series data using the sliding window technique. The window length is set to 5 to 20 time steps based on the physical and chemical properties of the target pesticide, with each time step corresponding to a time span of 15 minutes. An overlapping strategy is used during the sliding process, with a step length of 1 time step, to improve data utilization and model training effects.

[0037] Attached Figures 2 to 4 The effects of raw data collection, normalization, missing value filling, and sliding window slicing are shown.

[0038] 2. Model construction and training based on LSTM variants The model adopts the LSTM variant architecture, specifically the LSTM without the output activation function, to better adapt to the nonlinear changes in pesticide residue concentration. The model structure is as follows: Three-layer stacked LSTM variant structure: Each layer contains 128 hidden units and introduces a Dropout mechanism (value is 0.2) to prevent overfitting. At the same time, the cell state is transmitted through the direct output channel to improve the ability to capture long-term dependencies.

[0039] Optimizer selection: The Adam optimizer is used with an initial learning rate of 0.001. The exponential decay strategy is used to dynamically adjust the learning rate during training to ensure that the model achieves a balance between convergence speed and stability.

[0040] Specific loss function: A loss function specific to pesticide residues is used for optimization. While considering the deviation between the predicted value and the actual value, the loss function introduces weighted terms of the pesticide toxicological properties and degradation rate to improve the adaptability to different pesticide residues.

[0041] Cross-validation: The generalization ability of the model was evaluated through 5-fold cross-validation. Each fold of validation data contained data before and after application and during the degradation period to ensure the prediction accuracy of the model at different degradation stages.

[0042] Attached Figure 5 Displays the changes in input feature values ​​and output prediction values ​​over hidden units and time steps in the form of a 3D heat map.

[0043] 3. Dynamic threshold adjustment and model optimization In order to adapt to the legal residue standards of different pesticides, the system introduces a dynamic threshold adjustment mechanism. The specific steps are as follows: According to the physical and chemical properties of the target pesticide, the residue threshold is set before training, such as EU MRL, EPATolerance and other standards, and it is used as a key focus during model training.

[0044] When the model outputs predicted values, it marks and alarms situations that exceed the threshold, ensuring that users receive accurate reminders and decision-making basis at the safety threshold.

[0045] Attached Figure 6 The changing trends of the model prediction values ​​and dynamic thresholds at different time steps are displayed through a two-dimensional line graph.

[0046] 4. Model deployment and real-time prediction on edge devices The LSTM variant model is deployed on edge devices to achieve real-time prediction of field data. The specific steps are as follows: Hardware configuration: Edge devices use multi-core processors and high-performance memory, support mixed-precision computing, and calculate some model parameters through 16-bit floating-point numbers to improve inference speed and reduce resource consumption.

[0047] Data processing module: The device integrates the data processing module, which is responsible for real-time monitoring and analysis of sensor data. The data is normalized and processed by sliding window slicing before being input into the LSTM variant model.

[0048] Real-time prediction and alarm: After receiving new input data, the model outputs the prediction results in real time and determines whether to trigger the alarm function based on the set residual threshold. If the residual level exceeds the standard, the device will upload the alarm information to the central monitoring system via the wireless network.

[0049] Attached Figure 7 Compare the dynamic changes of input feature values ​​and model output prediction values ​​over time steps in the form of a two-dimensional line graph.

[0050] 5. Model update and adaptive optimization To ensure the adaptability of the LSTM variant model to new pesticides, the system supports online updating and dynamic optimization of the model. The specific steps are as follows: Data synchronization: Edge devices regularly upload data collected on-site to the central database and obtain the latest pesticide residue data from the database.

[0051] Retraining: Retrain the LSTM variant model on the central server, using new pesticide residue data for parameter optimization and architecture adjustment to ensure the latest adaptability of the model.

[0052] Model push: The trained new model is pushed to the edge device via wireless network to update and improve the real-time prediction on site.

[0053] Example 2: Imidacloprid residue prediction in rice fields based on LSTM variants This example demonstrates the prediction of the residue of a commonly used pesticide, Imidacloprid, in a paddy field environment. Imidacloprid is a pesticide widely used in rice cultivation, but its residue in paddy fields has a significant impact on rice safety and the water environment. By analyzing and modeling the collected data, this example specifically describes how the LSTM variant predicts the residue of Imidacloprid in a paddy field scenario.

[0054] 1. Data collection and preprocessing Sensor nodes are deployed in rice fields to collect the following data: Temperature (°C): For example, daily minimum 20°C and maximum 30°C; Humidity (%): such as between 70% and 90%; Soil pH: such as between 5.5 and 6.5; Rainfall (mm): 0 to 50 mm per day; Application concentration (mg / L): e.g. 10 to 30 mg / L; Historical imidacloprid residual concentration (mg / L): initial value is 10 mg / L.

[0055] The specific steps are as follows: Normalization: All data are Z-score normalized so that the mean of each feature is 0 and the standard deviation is 1.

[0056] Missing value filling: Linear interpolation is used to fill missing values. If the temperature data at a certain moment is missing, it is filled with the average of the two previous and subsequent measurements.

[0057] The corresponding pseudo code is as follows: import numpy as np from sklearn.preprocessing import StandardScaler # Data Collection data = { "temperature": [25, 26, np.nan, 28, 29], "humidity": [80, 82, 83, np.nan, 85], "soil_ph": [6.0, 5.9, 6.1, 6.2, 6.1], "rainfall": [10, 20, 15, 5, 0], "imidacloprid_conc": [15, 18, np.nan, 12, 10] } # Normalization scaler = StandardScaler() normalized_data = scaler.fit_transform(np.array(list(data.values())).T) # Missing value filling for i, feature in enumerate(normalized_data.T): if np.isnan(feature).any(): # Linear interpolation valid_idx = np.where(~np.isnan(feature))[0] filled_feature = np.interp(np.arange(len(feature)), valid_idx,feature[valid_idx]) normalized_data[:, i] = filled_feature 2. Sliding Window Slicing and LSTM Variant Model Training The sliding window was set to 48 hours (192 time steps), and each time step was 15 minutes; A three-layer stacked LSTM variant model is used, each layer contains 128 hidden units, and the Dropout value is set to 0.2; The optimizer uses Adam, and the initial learning rate is 0.001; The model generalization performance was evaluated through 5-fold cross validation.

[0058] The corresponding pseudo code is as follows: import tensorflow as tf # Sliding window slice window_size = 192 stride = 1 def create_windows(data, window_size, stride): windows = [] for i in range(0, len(data) - window_size, stride): windows.append(data[i:i + window_size]) return np.array(windows) windowed_data = create_windows(normalized_data, window_size, stride) # LSTM variant model construction model = tf.keras.Sequential([ tf.keras.layers.LSTM(128, return_sequences=True, dropout=0.2,input_shape=(window_size, windowed_data.shape[2])), tf.keras.layers.LSTM(128, return_sequences=True, dropout=0.2), tf.keras.layers.LSTM(128, dropout=0.2), tf.keras.layers.Dense(1, activation=None) # No output activation function ) # Model training model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.001), loss='mean_squared_error') history = model.fit(windowed_data, epochs=20, validation_split=0.2) import tensorflow as tf # Sliding window slicing window_size = 192 stride = 1 def create_windows(data, window_size, stride): windows = [] for i in range(0, len(data) - window_size, stride): windows.append(data[i:i + window_size]) return np.array(windows) windowed_data = create_windows(normalized_data, window_size, stride) # Construction of LSTM variant model model = tf.keras.Sequential( tf.keras.layers.LSTM(128, return_sequences=True, dropout=0.2,input_shape=(window_size, windowed_data.shape[2])), tf.keras.layers.LSTM(128, return_sequences=True, dropout=0.2), tf.keras.layers.LSTM(128, dropout=0.2), tf.keras.layers.Dense(1, activation=None) # No output activation function ) # Model training model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.001), loss='mean_squared_error') history = model.fit(windowed_data, epochs=20, validation_split=0.2) import tensorflow as tf # Sliding window slicing window_size = 192 stride = 1 def create_windows(data, window_size, stride): windows = [] for i in range(0, len(data) - window_size, stride): windows.append(data[i:i + window_size]) return np.array(windows) windowed_data = create_windows(normalized_data, window_size, stride) # Construction of LSTM variant model model = tf.keras.Sequential( tf.keras.layers.LSTM(128, return_sequences=True, dropout=0.2,input_shape=(window_size, windowed_data.shape[2])), tf.keras.layers.LSTM(128, return_sequences=True, dropout=0.2), tf.keras.layers.LSTM(128, dropout=0.2), tf.keras.layers.Dense(1, activation=None) # No output activation function ] # Model training model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.001), loss='mean_squared_error') history = model.fit(windowed_data, epochs=20, validation_split=0.2) 3. Dynamic threshold adjustment and real-time prediction The safety threshold of imidacloprid is set at 5 mg / L. When the model predicts the output, if the predicted value exceeds the threshold, the alarm mechanism will be triggered to remind the user to take prevention and control measures.

[0059] # Dynamic threshold setting threshold = 5.0 # mg / L # Real-time prediction and alarm mechanism predictions = model.predict(windowed_data) for i, pred in enumerate(predictions): if pred > threshold: print(f"Alert: High imidacloprid residue detected at step {i},value: {pred} mg / L") 4. Model deployment on edge devices Edge devices are installed in rice fields, real-time monitoring and processing modules of sensor data are integrated, and LSTM variant models are deployed to realize real-time prediction and alarm functions on site.

[0060] Hardware configuration: The edge device is equipped with a multi-core processor and 2GB of memory, supporting 16-bit mixed precision computing to improve reasoning speed and resource efficiency; Data processing: The device collects and preprocesses data every 15 minutes, using the normalization and sliding window slicing process described above; Real-time prediction: After receiving new input data, the model outputs the prediction results in real time. If the residual exceeds the standard, the device will upload the alarm information to the central monitoring system via the wireless network.

[0061] import time # Edge device data processing and real-time prediction def edge_device_prediction(new_data): new_data = scaler.transform(new_data) # Data normalization window = create_windows(new_data, window_size, stride) pred = model.predict(window) if pred[-1] > threshold: print(f"Alert: Imidacloprid residue exceeded threshold: {pred[-1]} mg / L") # Upload alarm information to the central monitoring system upload_to_server(pred[-1]) # Simulate real-time data collection and processing while True: new_data = np.random.rand(1, 5) # simulate newly collected data edge_device_prediction(new_data) time.sleep(900) # Collect data every 15 minutes The above embodiment describes in detail the full-process prediction and application of imidacloprid residues in a paddy field environment, covering data collection, preprocessing, model training, real-time prediction and the realization of alarm functions.

[0062] In summary, the effects of the present invention are: 1. Specially adapted to the time series characteristics of pesticide residues The present invention enhances the ability to capture nonlinear changes in pesticide residues by removing the output activation function of LSTM and directly outputting it on the cell state. Compared with traditional LSTM or other time series models (such as ARIMA, GRU), this LSTM variant is more suitable for processing the rapid changes and long-term dependence characteristics of pesticide residue concentration, especially for the dynamic residue situation within 48 hours after application.

[0063] 2. Dynamic threshold adjustment, flexibility for different pesticides The present invention introduces a dynamic threshold adjustment mechanism, which can be personalized according to the physical and chemical properties of specific pesticides and legal residue standards (such as EU MRL, EPA Tolerance, etc.). This flexibility not only improves the applicability to a variety of pesticides, but also accurately detects excess residues, significantly enhancing the adaptability of pesticide residue prediction in a variety of scenarios. Traditional models usually use fixed thresholds, which are difficult to accurately apply in multi-pesticide scenarios.

[0064] 3. Real-time prediction and alerting capabilities on edge devices Unlike existing models that rely on cloud computing, the present invention achieves real-time data processing and prediction by deploying the LSTM variant model on edge devices. Edge devices can not only quickly process newly collected data on site, but also immediately issue an alarm when residual excess is detected, improving the efficiency of detection and response. This distributed real-time processing mode reduces the delay of network transmission, greatly shortens the prediction and response time, and is more suitable for application in agricultural scenarios that require rapid response.

[0065] 4. Efficient use of data and optimization of computing resources The present invention adopts the overlapping strategy of sliding windows and mixed precision training technology, which improves data utilization while optimizing the consumption of computing resources. The sliding window slicing process can fully cover the details in the time series, and the mixed precision training reduces the memory usage and computing burden in the model reasoning process, making the present invention more efficient and cost-effective.

[0066] 5. Traditional time series prediction models usually require high computing resources to process complex long time series, while the present invention can achieve high-precision predictions on relatively low-configuration edge devices.

[0067] 6. Optimization modeling for specific pesticides The present invention combines the physical and chemical properties of specific pesticides (such as imidacloprid) and their residue patterns in specific crops (such as rice) during data preprocessing and model training. The prediction accuracy of the model in specific pesticide application scenarios is improved through a special residue normalization factor and time series feature extraction method. Compared with the existing general residue prediction model, the present invention is customized according to the characteristics of different pesticides, and its applicability and prediction accuracy are significantly improved.

[0068] 7. Online update and adaptability of the model Through the online update mechanism of the central server, the LSTM variant model can be dynamically adjusted and optimized with the introduction of new pesticides and the accumulation of data. This adaptive capability ensures the long-term effectiveness of the model and avoids the limitation of the existing technology that requires frequent manual retraining of the model.

[0069] The above generally describes the present invention in detail, but it is obvious to a person skilled in the art that some modifications or improvements can be made to the present invention. Therefore, modifications or improvements that do not depart from the spirit of the present invention are within the scope of protection of the present invention.

Claims

1. A pesticide residue prediction method based on LSTM variant, characterized by: include: Obtain time series data from target farmland samples. The data includes parameters directly related to pesticide application, such as application frequency, application concentration, farmland moisture, soil temperature, soil pH, crop growth stage, climate change factors, etc. Use normalization and missing value filling to ensure the integrity of time series data; Convert time series data into input-output pairs through sliding window slicing technique; Build and train a deep learning model based on LSTM variants to output whether the predicted pesticide residue level meets the safety standard.

2. A pesticide residue prediction method based on LSTM variant according to claim 1, characterized in that: The LSTM variant is further specified to remove the output activation function to adapt to the nonlinear changes in pesticide residue concentrations and directly pass the cell state to the next time step, thereby more accurately capturing the complex temporal dependencies in the pesticide degradation process.

3. A pesticide residue prediction method based on LSTM variant according to claim 1, characterized in that: The preprocessing of the time series data is optimized for the residual changes in the short term after application of pesticides, focusing on processing the data within 48 hours after application of pesticides, and adopting a high-frequency sampling strategy to capture the rapid degradation characteristics of pesticides.

4. A pesticide residue prediction method based on LSTM variant according to claim 1, characterized in that: The LSTM variant adopts a three-layer stacked structure, each layer contains at least 128 hidden units, and introduces a variable-length cell state retention mechanism to enhance adaptability to pesticide residue fluctuations.

5. The pesticide residue prediction method based on LSTM variant according to claim 1, characterized in that: The normalization uses a special residue standardization factor to adjust the data to a distribution form that matches the specific physical and chemical properties of the target pesticide so that the model can more accurately understand the residual characteristics of the pesticide under different environmental conditions. The data preprocessing process is optimized for specific pesticide residue standards and a dynamic threshold adjustment strategy is used to meet the statutory residue standards for different pesticides.

6. A pesticide residue prediction method based on LSTM variant according to claim 1, characterized in that: The window length of the sliding window slice is dynamically adjusted according to the crop type, soil type and the physical and chemical properties of the specific pesticide, and a shorter time step is set in the key degradation stage after application to enhance the model's responsiveness to residual dynamics. The sliding window slice adopts an overlapping strategy, and each sliding step is dynamically adjusted according to the half-life of different pesticides to better adapt to the degradation rate of the pesticide and the law of residual changes.

7. The pesticide residue prediction method based on LSTM variant according to claim 1, characterized in that: The training process of the model adopts the Adam optimizer with an initial learning rate of 0.

001. A regularization term with a time decay factor is introduced to ensure the robustness of the model when processing pesticide residue prediction tasks. The cross-validation used in the model training process adopts a data segmentation method specific to the pesticide residue scenario to ensure that both the training data set and the test data set contain time points before, after and during the degradation period of the pesticide application. The hidden layer of the model introduces an attention mechanism specific to pesticide degradation to enhance the model's perception of residue changes within a specific time step.

8. The pesticide residue prediction method based on LSTM variant according to claim 1, characterized in that: The evaluation phase of the model is optimized using a pesticide residue-specific loss function that takes into account the deviation between the predicted residue value and the actual detected value, the toxicity threshold of the pesticide, and the toxicological properties of different pesticides in crops and the environment.

9. A pesticide residue prediction method based on LSTM variant according to claim 7, characterized in that: The quantization of the model adopts mixed precision training technology, which reduces the consumption of computing resources by converting some calculations into 16-bit floating-point numbers and ensures the accuracy of pesticide residue prediction results at important thresholds. When the model is deployed to edge devices, it integrates the on-site real-time data processing module, including continuous monitoring of sensor data, dynamic prediction and residue exceeding alarm functions.

10. A pesticide residue prediction method based on LSTM variant according to claim 9, characterized in that: The edge device realizes regular updating of the model and integration of new pesticide residue data through wireless synchronization with the central database, thereby improving the model's adaptability and prediction accuracy for new pesticides.

Citation Information

Patent Citations

  • Pesticide residue measurement method based on LightGBM-XGBoost integrated learning

    CN116957164A

  • Multi-sample detection system applied to food pesticide residue detection

    CN117390499A

  • Intelligent detection method for vegetable pesticide residues

    CN118779829A

Cited By

  • Method for predicting natural abundance of ammonia volatile nitrogen isotope based on environment and soil factors

    CN120087567A

  • Pesticide residue monitoring device and method based on Beidou short message and PID sensing

    CN120427855A

  • Pesticide residue monitoring device and method based on beidou short message and PID sensor

    CN120427855B