A method for detecting abnormality of heavy metal pollution of fertilizer and a storage medium
By constructing an anomaly detection model for heavy metal pollution in fertilizers, the problem of multi-source heterogeneous data fusion was solved, realizing multi-dimensional data fusion and risk trend early warning for heavy metal pollution in fertilizers, improving the accuracy and interpretability of monitoring, and providing a reliable intelligent monitoring and early warning solution.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WEIFANG UNIV OF SCI & TECH
- Filing Date
- 2026-03-05
- Publication Date
- 2026-04-24
AI Technical Summary
Existing technologies are unable to effectively integrate heavy metal monitoring data from multi-source heterogeneous fertilizers, and cannot systematically characterize the exposure intensity and evolution trend of heavy metals in the environment. This results in insufficient ability to identify abnormal pollution states, making it difficult to support accurate early warning and prevention and control decisions.
A fertilizer heavy metal pollution anomaly detection model is constructed, including a multi-source fertilizer heavy metal monitoring data processing module, a heavy metal load evolution and environmental disturbance joint feature analysis module, a fertilizer heavy metal risk trend unified modeling module, and an anomaly detection module. Through multi-dimensional data fusion, quantification of load evolution inertia, and characterization of environmental disturbance response, risk trend inference and adaptive anomaly detection are achieved.
It improves the accuracy, interpretability, and engineering applicability of fertilizer heavy metal pollution monitoring, realizes stable and interpretable anomaly detection of fertilizer heavy metal pollution risk, and provides a reliable and efficient intelligent monitoring and early warning solution.
Smart Images

Figure CN121768512B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data anomaly detection, specifically relating to a method and storage medium for detecting anomalies in heavy metal pollution in fertilizers. Background Technology
[0002] Currently, with the widespread use of fertilizers, heavy metals associated with fertilizers enter the soil crop system through application to farmland, becoming a significant source of pollution threatening agricultural product safety and the agricultural ecological environment. Multi-source fertilizer heavy metal monitoring data typically exhibit characteristics of being dimensionally dispersed, structurally inconsistent, and having complex spatiotemporal correlations. Traditional methods struggle to effectively integrate these multi-source heterogeneous data, failing to systematically characterize the exposure intensity and evolution trend of heavy metals in the environment. This results in insufficient ability to identify abnormal pollution states, making it difficult to support accurate early warning and prevention and control decisions.
[0003] Existing technologies can be mainly divided into three categories: first, the heavy metal concentration threshold discrimination method based on single medium and single time point, which ignores the synergistic effect of multiple media and the cumulative effect of time; second, the statistical model is used to classify monitoring data, but it fails to explicitly model key agronomic and environmental factors; and third, machine learning methods are used for classification and prediction. However, most models rely on artificial feature construction and are insufficient in representing the dynamic characteristics of the data, resulting in limited interpretability and stability of the models.
[0004] Furthermore, existing technologies have significant bottlenecks in multi-source data fusion, temporal evolution modeling, disturbance response analysis, and adaptive anomaly detection, lacking a systematic approach. Therefore, there is an urgent need for an intelligent method that can deeply integrate multi-dimensional monitoring information, quantify load evolution inertia, characterize environmental disturbance response, and realize risk trend projection and adaptive anomaly detection, in order to improve the accuracy, interpretability, and engineering applicability of fertilizer heavy metal pollution monitoring. Summary of the Invention
[0005] This invention provides a method for detecting anomalies in fertilizer heavy metal pollution. It proposes an anomaly detection model for fertilizer heavy metal pollution based on complex fertilizer heavy metal monitoring data. The model consists of a multi-source fertilizer heavy metal monitoring data processing module, a joint feature analysis module for heavy metal load evolution and environmental disturbance, a unified modeling module for fertilizer heavy metal risk trends, and an anomaly detection module.
[0006] The technical solution adopted by the present invention to achieve the above objectives specifically includes the following steps:
[0007] S1. Obtain fertilizer heavy metal monitoring data and construct the original dataset;
[0008] S2. Based on the original dataset, the fertilizer application rate quota coefficient is obtained by calculating the proportion of fertilizer application rate to the total application batch. The media-weighted exposure is calculated using importance weights. A time decay weight is introduced. The exposure intensity is calculated based on the fertilizer application rate quota coefficient and the media-weighted exposure to obtain the first dataset.
[0009] S3. Introduce the fertilization batch attenuation coefficient to process the first dataset to obtain the load evolution benchmark quantity, perform unified scaling and take the average to obtain the disturbance intensity factor, use the disturbance intensity factor, deviation response coefficient and disturbance suppression coefficient to construct the heavy metal analytical quantity, and integrate to obtain the second dataset.
[0010] S4. The second dataset uses the risk weight coefficient to obtain the heavy metal risk driving quantity, introduces the memory coefficient and the disturbance injection coefficient to calculate the risk mapping state, decomposes the trend advancement quantity based on the risk mapping state to construct the risk trend increment, and obtains the third dataset through the risk trend unfolding sequence. The third dataset is divided into a training set and a prediction set.
[0011] S5. Calculate the degree of deviation between the risk value and the mean of the training set to obtain the risk trend deviation. The risk trend deviation is mapped to continuous anomaly indication results to construct anomaly indication. Based on the anomaly judgment threshold, anomaly results are judged, and a loss function is designed to optimize the model training.
[0012] S6. The prediction set is input into the trained fertilizer heavy metal pollution anomaly detection model, and the final output is the anomaly detection value.
[0013] Preferably, in step S2, based on the original dataset, the fertilizer application rate quota coefficient is obtained by calculating the proportion of fertilizer application rate to the total application batch, the medium-weighted exposure is calculated using importance weight, time decay weight is introduced, and the exposure intensity is calculated based on the fertilizer application rate quota coefficient and the medium-weighted exposure to obtain the first dataset.
[0014] Under any combination of dimensions, obtain the corresponding heavy metal monitoring values. The ratio of the amount of fertilizer applied per unit area on the plot to the total amount applied is calculated, and a small positive number is introduced. To ensure the denominator is not zero, construct the fertilizer dosage quota coefficient. For each monitoring time window and each heavy metal, a weighted exposure value of the medium is constructed by weighted summation. Each environmental medium is assigned an importance weight. Introducing the concentration compression index To adjust the contribution of different medium concentrations to the overall exposure, the application time of each fertilizer batch on a specific plot was recorded as the baseline time point. The absolute value of the time interval between the baseline time point and each monitoring time window was used as the basis, and the time decay coefficient was applied. Construct an inverse proportional time decay weight function to obtain the time decay weight. The media-weighted exposure amounts for each monitoring time window are weighted and accumulated based on the time decay weight, and then multiplied by the fertilizer dosage quota coefficient to obtain the exposure intensity of each heavy metal. Finally, a multi-source fertilizer heavy metal monitoring dataset was obtained. This serves as the first dataset.
[0015] Furthermore, addressing the issue of scattered and inconsistent structures in raw fertilizer heavy metal monitoring data across multiple dimensions, this invention constructs a multi-source fertilizer heavy metal monitoring data processing module. First, it unifies the raw monitoring concentration values across four dimensions: batch, plot, time, and heavy metal type, forming a structured monitoring data foundation. Second, by calculating the fertilizer dosage quota coefficient, it quantifies the application intensity differences of the same batch in different plots to eliminate the influence of the total batch application on the exposure intensity. Next, it constructs a media-weighted exposure value for each monitoring time window and heavy metal type, integrating concentration information from different environmental media and introducing importance weights and concentration pressures. The module first uses a reduction index to adjust the contribution of each medium to the overall exposure. Then, it constructs a time decay weight function to characterize the decay effect of fertilization time and monitoring time interval on the exposure, reflecting the migration and dilution process of heavy metals in the environment. Finally, it weights and accumulates the time decay weight with the medium-weighted exposure and multiplies it by the fertilization dose quota coefficient to obtain the exposure intensity of each heavy metal. This forms a multi-source fertilizer heavy metal monitoring dataset indexed by application batch and plot as the first dataset. The module can uniformly encode multi-source and multi-dimensional monitoring data into a structured exposure intensity characterization, providing a comparable and multi-dimensional fusion input basis for subsequent modules.
[0016] Preferably, in step S3, the first dataset is processed by introducing a fertilization batch attenuation coefficient to obtain a load evolution baseline, which is then uniformly scaled and averaged to obtain a perturbation intensity factor. The perturbation intensity factor, deviation response coefficient, and perturbation suppression coefficient are used to construct a heavy metal analytical quantity, which is then integrated to obtain a second dataset.
[0017] For the current fertilization batch, using the exposure intensity as input, historical batches are assigned weights that decrease in reverse over time using an exponential decay function, with the decay rate determined by the decay coefficient of the fertilization batch. To control the load evolution baseline, sum the attenuation-weighted exposure intensities of all historical batches and divide by the sum of their corresponding weights. The difference between the exposure intensity of each heavy metal and the corresponding load evolution baseline is calculated sequentially, and the difference is divided by the load evolution baseline of the corresponding heavy metal and a minimum positive number. The sum of these values, taken as absolute values, yields the relative deviation of the heavy metals. The arithmetic mean of these relative deviations for all heavy metals is then calculated to obtain the disturbance intensity factor. Introducing the deviation response coefficient The relative deviation is weighted, 1 is added, and then multiplied by the base value to obtain the numerator. The disturbance intensity factor and the disturbance suppression coefficient are... The product of these factors plus 1, with 1 as the denominator, yields the ratio of the dissolved heavy metal amount. Ultimately, a joint feature set of heavy metal load evolution and environmental disturbance was obtained. This serves as the second dataset.
[0018] Furthermore, addressing the inertial patterns of heavy metal exposure intensity in fertilizer batch evolution and the load deviation caused by multi-source environmental disturbances, this invention constructs a joint feature analysis module for heavy metal load evolution and environmental disturbances. First, by constructing a load evolution benchmark, an exponential decay weighted average method is used to perform a moving average processing of historical batch exposure intensities to quantify the inertial evolution trend of each heavy metal in the batch dimension. Second, a disturbance intensity factor is constructed, and the relative deviation of each heavy metal exposure intensity from the evolution benchmark is calculated and averaged to characterize the environmental disturbance under the current batch and plot combination. The overall load deviation is measured. Finally, a joint modulation heavy metal analytical quantity is constructed. Based on the load evolution benchmark, a deviation response coefficient is introduced to fuse the relative deviation information of individual heavy metals. At the same time, the overall disturbance intensity is embedded as a constraint term in the analytical process through the disturbance suppression coefficient. This realizes the joint feature expression of the differentiated load evolution of heavy metals and the unified constraint of environmental disturbance. The module integrates the evolution inertia and disturbance response into a structured joint feature set of heavy metal load evolution and environmental disturbance, forming a second dataset, which provides a feature foundation with both historical memory and disturbance robustness for subsequent modeling.
[0019] Preferably, in step S4, the second dataset uses risk weight coefficients to obtain heavy metal risk driving quantities, introduces memory coefficients and disturbance injection coefficients to calculate risk mapping states, decomposes trend advancement quantities based on the risk mapping states to construct risk trend increments, and obtains a third dataset through risk trend unfolding sequences. The third dataset is divided into a training set and a prediction set.
[0020] Add 1 to the analytical value of each heavy metal, take the natural logarithm, and then multiply by the risk weighting coefficient. The weighted summation yields the heavy metal risk driver. The risk mapping state of the previous batch multiplied by the memory coefficient The historical risk retention term is obtained by multiplying the heavy metal risk driver amount of the current batch by the complement of the memory coefficient to obtain the current batch update term, and the absolute difference of the heavy metal risk driver amount of adjacent batches is multiplied by the disturbance injection coefficient. The explicit perturbation term is obtained. The historical risk retention term, the current batch update term, and the explicit perturbation term are added together to obtain the risk mapping state of the current batch. Calculate the risk mapping state difference between the current batch and the previous batch, and multiply the difference by the incremental smoothing coefficient. The complement of the previous batch's risk trend increment is added to the value obtained by multiplying the previous batch's risk trend increment by the increment smoothing coefficient; the result is the risk trend increment for the current batch. The risk mapping status of the current batch is matched with the step sequence index value. The sum of the results multiplied by the risk trend increment, followed by the negative, is used as the input to the exponential function. The reciprocal of the exponential value plus 1 is then calculated to obtain the risk expansion value. Ultimately, a risk trend set is obtained. The third dataset is divided into a training set and a prediction set in a 7:3 ratio.
[0021] Furthermore, addressing the challenges of unified representation of combined heavy metal load information and explicit modeling of risk evolution trends, this invention constructs a unified modeling module for heavy metal risk trends in fertilizers. First, by constructing heavy metal risk drivers, multiple heavy metal analytical features are weighted according to risk weight coefficients and logarithmically compressed, merging into a single-dimensional risk driver representation. Second, a risk mapping state is constructed, based on the state memory of the previous moment, integrating the current heavy metal risk drivers and explicitly introducing changes in drivers between adjacent batches as perturbation terms to simultaneously characterize the historical cumulative effect and sudden perturbation response of risk evolution. Next, a risk trend increment is constructed, smoothing the changes in the risk mapping state to extract the rate and direction of risk state change in the batch dimension. Finally, a risk trend unfolding sequence is constructed, using the current risk mapping state as a benchmark, performing multi-step temporal unfolding along the trend increment direction, mapping the unfolded values to the probability space, forming a structured and interpretable risk evolution trajectory representation. The module maps multi-metal combined loads into a unified risk trend set, forming a third dataset, providing a feature foundation for subsequent anomaly detection that combines state memory, trend perception, and unfolding prediction capabilities.
[0022] Preferably, in step S5, the degree of deviation between the risk value and the mean of the training set is calculated to obtain the risk trend deviation, the risk trend deviation is mapped to continuous anomaly indication results to construct anomaly indication, anomaly results are determined based on anomaly determination threshold, and a loss function is designed to optimize model training.
[0023] Calculate the mean of the risk trend set along the expanded dimension. Sum the absolute differences between the risk unfolded value and the mean, and divide by the number of trend unfolding steps. The risk trend deviation is obtained. Calculate the deviation of the risk trend from the abnormal benchmark value. The difference is multiplied by the steepness coefficient. The negative value is then obtained by inputting the exponential function, adding 1, and taking the reciprocal, which is the abnormality indicator. Calculate the specified quantile of all the aforementioned anomaly indicators as the anomaly determination threshold. Each abnormal indicator is compared with the threshold. If the abnormal indicator is greater than or equal to the threshold, the result is 1, indicating an abnormal state; if it is less than the threshold, the result is 0, indicating a normal state. The abnormal indicator and abnormal reference label are calculated for all fertilization batches and plots. The mean squared error is used as the basic loss term, and the discrimination steepness coefficient and the square of the outlier benchmark value are multiplied by the corresponding regularization coefficient. and As a regularization constraint, the basic loss term is added to the two regularization constraint terms to form the loss function. The model is trained and optimized to obtain the trained fertilizer heavy metal pollution anomaly detection model, and finally the anomaly detection value is output.
[0024] Furthermore, addressing the anomaly detection problem in the evolution trend of heavy metal pollution risks in fertilizers, this invention constructs an anomaly detection module. First, by constructing a risk trend deviation, the absolute deviation of each expanded value in the risk trend set from the mean is calculated and averaged to quantify the internal consistency of the risk trend during the expansion process. Second, an anomaly indicator is constructed, mapping the risk trend deviation to continuous anomaly probability values after linear shift, and controlling the sensitivity of the mapping through a discrimination steepness coefficient, using the anomaly benchmark value as a statistical reference for the normal deviation level. Next, an anomaly judgment threshold is constructed, setting an adaptive threshold based on the quantiles of the anomaly indicator set to achieve binary judgment of anomaly states. Finally, a total loss function including prediction bias and parameter regularization is constructed, using the anomaly reference label as a supervision signal, and jointly optimizing and training the discrimination steepness coefficient and the anomaly benchmark value through gradient descent to improve the model's discrimination stability and generalization ability. This achieves end-to-end computation and adaptive learning from risk trend sequence to anomaly state judgment, outputting anomaly detection results with clear semantics, and completing the trainable optimization of model parameters.
[0025] Preferably, in step S6, the prediction set is input into the trained fertilizer heavy metal pollution anomaly detection model, and the anomaly detection value is finally output.
[0026] In summary, this invention proposes a method for detecting anomalies in fertilizer heavy metal pollution. The method comprises a multi-source fertilizer heavy metal monitoring data processing module, a heavy metal load evolution and environmental disturbance joint feature analysis module, a fertilizer heavy metal risk trend unified modeling module, and an anomaly detection module. First, the multi-source fertilizer heavy metal monitoring data processing module uniformly encodes multi-source monitoring data into structured exposure intensity features, realizing the construction of a multi-dimensional fused exposure characterization from raw concentration. Next, the heavy metal load evolution and environmental disturbance joint feature analysis module performs batch inertial evolution modeling and environmental disturbance quantification of exposure intensity, completing the joint feature extraction of the evolutionary benchmark and disturbance response. Finally, leveraging the fertilizer heavy metal risk trend... The unified modeling module maps the joint features of multiple metals into a unified risk driver, and performs state memory, trend extraction, and sequence expansion to form a risk evolution trajectory that combines historical accumulation and trend extrapolation capabilities. Finally, the anomaly detection module performs consistency quantification, probabilistic mapping, and adaptive threshold determination on the risk trend sequence, and optimizes key discrimination parameters, ultimately achieving stable and interpretable anomaly detection of fertilizer heavy metal pollution risk. Through the progressive processing of the above modules, this invention systematically solves the key technical problems of multi-source data fusion, evolutionary inertia characterization, unified trend modeling, and adaptive anomaly discrimination, providing a reliable and efficient intelligent solution for monitoring and early warning of fertilizer heavy metal pollution in agricultural environments. Attached Figure Description
[0027] Figure 1 This is a flowchart illustrating the steps of a method for detecting abnormal heavy metal pollution in fertilizers.
[0028] Figure 2 This is a structural diagram of a fertilizer heavy metal pollution anomaly detection model.
[0029] Figure 3 This is a structural diagram of the heavy metal monitoring data processing module for multi-source fertilizers.
[0030] Figure 4 This is a structural diagram of the module for analyzing the joint characteristics of heavy metal load evolution and environmental disturbance.
[0031] Figure 5 Structure diagram of the unified modeling module for heavy metal risk trends in fertilizers.
[0032] Figure 6 This is a diagram of the model training process.
[0033] Figure 7 The fitting effect diagram for the model to achieve heavy metal anomaly detection. Detailed Implementation
[0034] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0035] Please see Figures 1-7 This invention provides a technical solution: a method for detecting anomalies in fertilizer heavy metal pollution, comprising a multi-source fertilizer heavy metal monitoring data processing module, a heavy metal load evolution and environmental disturbance joint feature analysis module, a fertilizer heavy metal risk trend unified modeling module, and an anomaly detection module. First, the multi-source fertilizer heavy metal monitoring data processing module uniformly encodes multi-dimensional monitoring data into exposure intensity features. Second, the heavy metal load evolution and environmental disturbance joint feature analysis module extracts the load evolution inertia and environmental disturbance response. Then, the fertilizer heavy metal risk trend unified modeling module constructs the risk evolution trajectory. Finally, the anomaly detection module achieves adaptive anomaly discrimination and model optimization. Specific steps are as follows: Figure 1 As shown.
[0036] Construct an anomaly detection model for heavy metal pollution in fertilizers, with the structure as follows: Figure 2 As shown.
[0037] S1. Obtain heavy metal monitoring data in fertilizers and construct the original dataset.
[0038] Furthermore, the dataset of this invention contains 3000 sets of multi-source monitoring data on fertilizer heavy metals, covering 10 fertilization batches, 20 farmland plots, 30 monitoring time windows, and five heavy metals: cadmium, lead, arsenic, chromium, and mercury. The original monitoring values include fertilizer application dosage, heavy metal concentrations in different environmental media, the correspondence between application time and monitoring time, and environmental media property information. Fertilizer application dosage is recorded in real-time during fertilization using an electronic weighing system. The total application amount is calculated for each fertilization batch, and the application amount per unit area of each plot is collected simultaneously, with a measurement accuracy of ±0.01 kg. The data is recorded in the fertilization management ledger. Heavy metal concentrations in each environmental medium are determined in the laboratory using inductively coupled plasma mass spectrometry. Fertilizer samples are randomly sampled before fertilization, and soil samples are divided into surface (0-20 cm) and deep (20-40 cm) layers. The samples were collected using the five-point method (cm). Irrigation water samples were collected at the field inlet during each irrigation period. Crop samples were randomly collected from edible parts of each plot during the harvest period. All samples were digested and then tested. The detection limit was 0.01 mg / kg. The recovery rate of the quality control samples was controlled between 85% and 95%. The application time and monitoring time were aligned with the farmland operation log and the clock record of the automatic monitoring station, with a time resolution of 1 day. The soil type, irrigation water source, and crop type in the environmental media attribute data were obtained through field surveys and agricultural records, and finally formed the original dataset.
[0039] S2. Based on the original dataset, the fertilizer application rate quota coefficient is obtained by calculating the proportion of fertilizer application rate to the total number of application batches. The media-weighted exposure is calculated using importance weights, and time decay weights are introduced. The exposure intensity is calculated based on the fertilizer application rate quota coefficient and the media-weighted exposure, resulting in the first dataset.
[0040] Furthermore, in step S2, in order to uniformly organize multi-source monitoring data across fertilizer application batches, farmland plots, environmental media, and monitoring time dimensions, this invention constructs a multi-source fertilizer heavy metal monitoring data processing module, the structure and flow of which are as follows: Figure 3 As shown, the number of fertilizer application batches is first determined to be... The number of farmland plots is The number of monitoring time windows is and the number of heavy metal types The heavy metals include cadmium, lead, arsenic, chromium, and mercury. The batch number of any fertilizer application will be recorded as follows: Any farmland plot is numbered as Any monitoring time window number is recorded as Any heavy metal type is denoted as In this example, , , and The values are 10, 20, 30, and 5 respectively, in any given combination. Next, obtain the corresponding raw heavy metal monitoring values, denoted as... , indicating in After the first fertilization, in the plot Time window The first one detected internally The measured concentrations of various heavy metals are used to form a structured dataset describing the monitoring results of heavy metals in multi-source fertilizers, providing a unified multi-dimensional input basis for subsequent anomaly detection.
[0041] Furthermore, to quantify the differences in application intensity of the same fertilizer batch across different plots, the ratio of the application rate per unit area of the fertilizer batch to the total application rate is calculated, introducing a small positive number. To ensure the denominator is not zero, construct the fertilizer dosage quota coefficient. The mathematical model is:
[0042] ;
[0043] In the formula, For application batch On the plot Application rate per unit area For application batch Total application amount, It is a very small positive number, used to prevent the denominator from being zero, and takes the value of This design effectively avoids the abnormal situation of zero denominator without changing the relative proportion of fertilizer dosage, and takes into account both numerical stability and engineering feasibility. Through the above design, the influence of batch total dosage difference on exposure intensity calculation can be eliminated, and the comparability and stability of the model can be enhanced.
[0044] Furthermore, for each monitoring time window and each heavy metal, a weighted exposure value of the medium is constructed by weighted summation. This is used to integrate concentration information from different environmental media, each of which has a specified importance weight. Introducing the concentration compression index The mathematical model for adjusting the contribution of different medium concentrations to the overall exposure is as follows:
[0045] ;
[0046] In the formula, The importance weights are assigned to five types of environmental media: fertilizer, topsoil, subsoil, irrigation water, and crops. Indicates in After the first fertilization, in the plot Time window The first one detected internally The first environmental medium Concentration values of various heavy metals, The concentration compressibility index of the environmental medium is used to adjust the contribution of heavy metal concentration in different media to the overall exposure. This refers to the quantity of environmental media.
[0047] Furthermore, in this embodiment, the sum of the importance weights of the five environmental media is 1. Fertilizer and topsoil are the main input and initial accumulation media for heavy metals entering the agricultural system; therefore, the importance weights of fertilizer and topsoil are set to 0.3 and 0.25, respectively. Deep soil, as the carrier medium for the downward migration of heavy metals from the surface in the agricultural system, exhibits both hysteresis and slow-release characteristics in the exposure formation mechanism; therefore, its importance weight is set to 0.2. Heavy metals in irrigation water mainly exist in dissolved and suspended states, and their impact on soil heavy metal levels is usually manifested as short-term input and dilution processes; therefore, the importance weight of irrigation water is set to 0.15, which can reflect the enhanced transport in the heavy metal migration path rather than the localization of long-term accumulation. Crop tissue belongs to the terminal medium in the heavy metal migration path, and its monitoring values are affected by various physiological and environmental factors. Setting the weight too high can easily amplify fluctuations caused by non-fertilization factors; therefore, the importance weight of crops is set to 0.1. The concentration compression index of the environmental media is... In this example, a value of 0.8 is used. This value maintains the relative magnitude of the monitored values while moderately suppressing abnormal peaks, thereby avoiding the dominant influence of a sudden increase in the concentration of a single medium on the overall exposure. The value is 5, representing five types of environmental media: fertilizer, topsoil, deep soil, irrigation water, and crops.
[0048] Furthermore, to characterize the impact of fertilization timing and monitoring interval on exposure levels, the application batches were... On the plot The application time is recorded as Using the time decay coefficient Construct an inverse proportional time decay weight function to obtain the time decay weight. The mathematical model is:
[0049] ;
[0050] In the formula, This is the time decay coefficient, used to characterize the degree of decay of the impact of fertilization on different monitoring time windows. In this example, it is set to 0.5. This value maintains a reasonable weight within several monitoring windows after fertilization, while gradually decaying with increasing time intervals, consistent with the characteristics of slow migration and gradual dilution of heavy metals in the agricultural environment. For monitoring time windows.
[0051] Furthermore, the media-weighted exposure amounts within each monitoring time window are weighted and accumulated using a time decay weighting method, and then multiplied by the fertilizer dosage quota coefficient to obtain the first... Heavy metals in application batches With the plot of land Exposure intensity under combination The mathematical model is:
[0052] ;
[0053] Through the above exposure intensity coding process, a feature vector is formed, indexed by application batch and plot, and composed of multiple heavy metal exposure intensities. Information on differences in application dose, differences in the importance of environmental media, and the interval between application time and monitoring time are uniformly embedded into the exposure characterization, ultimately yielding a multi-source fertilizer heavy metal monitoring dataset. As the first dataset, This is the transpose symbol.
[0054] S3. Introduce the fertilization batch attenuation coefficient to process the first dataset to obtain the load evolution benchmark quantity, perform unified scaling and take the average to obtain the disturbance intensity factor, use the disturbance intensity factor, deviation response coefficient and disturbance suppression coefficient to construct the heavy metal analytical quantity, and integrate to obtain the second dataset.
[0055] Furthermore, in step S3, to characterize the evolutionary inertia of heavy metal load at the application batch level and to uniformly map the load deviation intensity caused by environmental disturbances into an analytical joint feature expression, a joint feature analysis module for heavy metal load evolution and environmental disturbances is constructed, with the structure and flow as follows: Figure 4 As shown, the specific steps are as follows:
[0056] First, in order to characterize the evolutionary inertia of heavy metal load from the perspective of application batches, the exposure intensity output by the multi-source fertilizer heavy metal monitoring data processing module was used. As input, a load evolution baseline is constructed to characterize the load evolution at different plots. Upper The mathematical model for the inertial evolution trend of heavy metals in batch sequence is as follows:
[0057] ;
[0058] In the formula, For the plot of land Above, the first Baseline values for the loading evolution of various heavy metals across application batch sequences. The fertilization batch decay coefficient is set to 0.7 in this example. This value ensures that recent fertilization batches are dominant but still retain evolutionary memory, facilitating stable analysis of subsequent perturbations.
[0059] Furthermore, in this embodiment, the numerator... This is used for time-weighted accumulation of exposure intensity in the application batch sequence, giving higher contribution to the accumulation result from the exposure intensity of more recent batches. The denominator term is... This is used to normalize the amplitude of the weighted cumulative results, preventing the baseline value from growing unbounded with the batch size, thus ensuring the comparability of the evolved baseline values under different application batches. Through the above design, the load evolution baseline value is made... It possesses both recent sensitivity and historical retention evolutionary inertia characteristics, and provides a unified reference benchmark for subsequent disturbance deviation analysis.
[0060] Furthermore, in order to characterize the load deviation intensity caused by environmental disturbance under the same application batch and plot conditions, a disturbance intensity factor is constructed, and the mathematical model is as follows:
[0061] ;
[0062] In the formula, The disturbance intensity factor is used to represent the disturbance intensity factor in the context of disturbance intensity. The overall deviation of the multi-metallic loading under the combined conditions from the evolutionary baseline. To ensure the denominator is a very small positive number and prevent it from being zero, this embodiment uses... Through the above design, the relative deviations of different heavy metals are uniformly scaled and averaged, so that... It can stably characterize the overall disturbance level of the current application batch at the plot level, avoiding the dominance of single metal extreme value deviation on the disturbance intensity.
[0063] Furthermore, in order to jointly embed the load evolution baseline quantity and the perturbation intensity factor into the analytical results of each heavy metal, a jointly modulated heavy metal analytical quantity is constructed. The mathematical model is:
[0064] ;
[0065] In the formula, The deviation response coefficient is used to adjust the contribution of the relative deviation of the single metal in the joint analysis. This is the perturbation suppression coefficient, used to adjust the constraint of the overall perturbation intensity on the joint analytical quantity. It is a very small positive number, used to prevent the denominator from being zero, and takes the value of Through the above design, the amount of heavy metals analyzed after joint modulation is increased. While expressing the evolution of differentiated loads in single metals, it is subject to the unified constraint of the overall environmental disturbance intensity, thereby avoiding the irrational amplification of short-term abnormal deviations by the analysis results.
[0066] Furthermore, in this example, When the value is greater than 0.6, the amount of heavy metals extracted... It may be overly sensitive to short-term deviations in a single heavy metal, leading to increased fluctuations in the combined analysis results. When the value is less than 0.6, the deviation of a single metal is excessively suppressed, making it difficult to reflect the evolution of differentiated loads. Therefore... A value of 0.6 can make deviation information visible but not dominant; When the value is greater than 0.3, the disturbance intensity factor Applying excessive pressure to all metals will cause the overall resolution to collapse. When the value is less than 0.3, it will lead to insufficient perturbation constraints, making it easy for the joint analytical quantity to be abnormally deviated from its intended path. Therefore... A value of 0.3 is used to maintain the presence of the perturbation constraint without making it overly dominant. Through the above design, While preserving individual metal deviation information, and subject to moderate constraints on the overall perturbation level, the analytical values of each heavy metal are ultimately aggregated into the output set of this module, yielding a joint feature set of heavy metal load evolution and environmental perturbation. It serves as the input for subsequent modules as the second dataset.
[0067] S4. The second dataset uses risk weight coefficients to obtain heavy metal risk drivers, introduces memory coefficients and disturbance injection coefficients to calculate risk mapping states, decomposes trend advancements based on the risk mapping states to construct risk trend increments, and obtains the third dataset through risk trend unfolding sequences. The third dataset is divided into training set and prediction set.
[0068] Furthermore, in step S4, to map the combined load information of multiple heavy metals into a unified risk driver and to perform recursive modeling at the batch level, a unified modeling module for fertilizer heavy metal risk trends is constructed. This module forms a risk mapping state that simultaneously includes historical cumulative effects and disturbance change information. The structure and process are as follows: Figure 5 As shown, by uniformly mapping the combined load information of multiple heavy metals to a single risk-driven space, and explicitly characterizing the inertial characteristics and disturbance response properties of risk changes during the time-series evolution, a holistic modeling of the development trend of heavy metal pollution risk in fertilizers is achieved. The specific steps are as follows:
[0069] First, the joint feature set of heavy metal load evolution and environmental disturbance output from the previous module is combined. Mapped to a unified driving force that can be used for trend prediction, constructing a heavy metal risk driving force. The mathematical model is:
[0070] ;
[0071] In the formula, For the first In this example, the risk weight coefficients for the five heavy metals—cadmium, lead, arsenic, chromium, and mercury—are 0.35, 0.25, 0.2, 0.12, and 0.08, respectively, which satisfies the following conditions: By employing a decreasing weight allocation, the driving force retains multi-metal information while maintaining higher responsiveness to high-risk metals, thus balancing stability and interpretability. This is used to suppress the nonlinear amplification effect of a single heavy metal on risk drivers under high load conditions, so that risk drivers can maintain numerical stability and interpretability while retaining load difference information.
[0072] Furthermore, in order to establish a steady-state foundation for risk trends at the application batch dimension and explicitly embed perturbation memories, a risk mapping state is constructed. The mathematical model is:
[0073] ;
[0074] In the formula, For the plot of land Application batch Risk mapping status, For the plot of land Application batch Risk mapping status, The memory coefficient is used to control the proportion of historical risk states retained in the current mapping, in order to characterize the inertial characteristics of risk evolution. For the plot of land Application batch Heavy metal risk drivers This is the perturbation injection coefficient, used to explicitly incorporate the perturbation effects of changes in risk drivers between adjacent application batches, thereby enhancing the model's sensitivity to sudden changes in risk. For the plot of land Application batch Heavy metal risk drivers.
[0075] Furthermore, in this embodiment A value of 0.85 indicates that 85% of the current state comes from historical memory and 15% from current driving forces, thus maintaining the stability of risk evolution. A value of 0.35 is chosen to moderately amplify risk variations between adjacent batches, enhancing the response to sudden disturbances. When b=1, The initial value is 0. The initial value is 0, and the risk mapping state is constructed in the above manner. It also integrates historical risk memory and disturbance change response characteristics, which can effectively suppress short-term noise interference, highlight the true risk evolution trajectory, and make the risk state sequence have good stability and interpretability.
[0076] Furthermore, in order to further decompose the risk mapping state from a horizontal quantity into a trend advancement quantity, a risk trend increment is constructed. This is used to characterize the rate and direction of change of risk mapping status along the application batch dimension. The mathematical model is as follows:
[0077] ;
[0078] In the formula, This is the incremental smoothing coefficient, which is set to 0.7 in this example. This value strikes a balance between trend response sensitivity and noise suppression capability. For the plot of land Application batch The risk trend increment when b=1. The initial value is 0. Through the above design, the risk trend increment can reflect the true direction of change in the risk status, while avoiding the distortion of trend judgment due to short-term fluctuations.
[0079] Furthermore, in order to provide a unified temporal description of the risk evolution process based on the current risk mapping state and risk trend increments, a risk trend unfolding sequence is constructed based on the current application batch. Lower plot Risk mapping status and the increase in risk trends , for the Each trend unfolds step by step to construct a risk unfolding value. The current risk status and its changing trends are structurally represented to enhance the stability of risk evolution characteristics in subsequent anomaly detection and model optimization stages. The mathematical model is as follows:
[0080] ;
[0081] In the formula, The step index represents the unfolding of the risk trend, used to describe the position of the risk state along the trend direction. The number of steps for trend unfolding is set to 12, which strikes a balance between the completeness of trend representation and numerical stability, ensuring good interpretability of the risk evolution trajectory. Through the aforementioned trend unfolding process, a risk trend set is formed, starting from the current risk state and gradually expanding along the risk trend direction. As a third dataset, the third dataset is divided into a training set and a prediction set in a 7:3 ratio.
[0082] S5. Calculate the degree of deviation between the risk value and the mean of the training set to obtain the risk trend deviation. The risk trend deviation is mapped to continuous anomaly indication results to construct anomaly indication. Based on the anomaly judgment threshold, anomaly results are judged, and a loss function is designed to optimize the model training.
[0083] Furthermore, in step S5, an anomaly detection module is constructed to perform anomaly discrimination processing on the risk trend set, and adaptive optimization and update of the anomaly discrimination parameters are performed during the training phase to output the judgment result of fertilizer heavy metal pollution anomaly status. The specific steps are as follows:
[0084] First, to characterize the overall inconsistency of risk trends during the unfolding process, the mean of the risk trend set along the unfolding dimension is calculated, and the deviation between the risk value at each unfolding step and the mean is statistically analyzed to construct a risk trend deviation quantity based on the overall consistency of trends. The mathematical model is:
[0085] ;
[0086] In the formula, the deviation of risk trend This value represents the average deviation from the overall level during the unfolding of risk trends. A larger value indicates weaker consistency within the risk trend set. It is the mean of the set of risk trends, used to characterize the overall level of that risk trend.
[0087] Furthermore, the deviation of the aforementioned risk trend The mapping is transformed into continuous anomaly indication results, and an anomaly indication quantity is constructed. The mathematical model is as follows:
[0088] ;
[0089] In the formula, This indicates an anomaly indicator; a larger value indicates a higher degree of anomaly. The steepness coefficient is used to control the strength of the response of anomaly indicators to deviations. In this example, A value of 10 ensures that the anomaly indicator maintains sufficient resolution around the threshold without becoming overly sensitive. As an abnormal baseline value, it is obtained by analyzing the set of deviations from risk trends. The median is used to characterize the statistical center of the normal deviation level, thus making the mapping process of the outlier indicator insensitive to extreme outlier samples.
[0090] Furthermore, in order to measure the abnormal indication quantity Convert the results into explicit anomaly determinations and construct anomaly determination thresholds based on the distribution characteristics of the anomaly indicator set. The mathematical model is:
[0091] ;
[0092] In the formula, Describes the quantile operator. The quantile ratio is used to control the sensitivity level of anomaly detection. In this example, A value of 0.85 strikes a balance between covering sufficient anomalous samples and preventing the spread of false alarms, while ensuring that the threshold adapts to data distribution and avoids the failure of a fixed threshold under different monitoring scales. Based on this anomaly determination threshold... Output anomaly detection results The mathematical model is:
[0093] ;
[0094] in, This indicates that the risk trend of the corresponding application batch and plot has been determined to be abnormal. This indicates that the corresponding risk trend is in a normal state.
[0095] Furthermore, during the training phase, to minimize the deviation between the anomaly indicator and the anomaly reference label, and to avoid unstable discrimination due to excessively large parameter values, the anomaly indicator... Reference tags for exceptions The mean squared error is used as the basic loss term to measure the deviation between the anomaly indication result output by the model and the actual anomaly state. The anomaly reference label is derived based on historical anomaly records and is used to provide a supervision signal during the model training phase. A value of 1 indicates an anomaly state, and a value of 0 indicates a normal state. A discrimination steepness coefficient is also introduced. Compared with abnormal baseline values The regularization constraint term is used to limit the range of parameter values and suppress the risk of model overfitting. The basic loss term and the regularization constraint term are weighted and summed to construct the loss function. The mathematical model is:
[0096] ;
[0097] In the formula, and The steepness coefficient and the regularization coefficient of the anomaly baseline value, respectively, are used to suppress unconstrained parameter growth during model training, improving the numerical stability and generalization ability of the anomaly indicator function. Excessively large regularization coefficients will restrict parameter updates and reduce the model's adaptive ability; excessively small values will result in insufficient constraints and instability. Therefore... and All values are This approach balances stability and adjustability. Through the training method described above, the accuracy and generalization ability of the fertilizer heavy metal pollution anomaly detection model can be further improved. In this example, the optimizer is Adam with gradient descent, and the learning rate is set to 0.001. The training process is as follows: Figure 6 As shown in the figure, the number of training rounds is 1000. It can be seen from the figure that as the number of training rounds increases, the model converges and stabilizes during the training process. Finally, a well-trained fertilizer heavy metal pollution anomaly detection model is obtained.
[0098] S6. The prediction set is input into the trained fertilizer heavy metal pollution anomaly detection model, and the final output is the anomaly detection value.
[0099] Furthermore, the fitting effect of the fertilizer heavy metal pollution anomaly detection model on heavy metal anomaly detection is shown in the figure below. Figure 7 As shown in the figure, the horizontal axis represents the sample number, the vertical axis represents the anomaly indicator, the solid dotted line represents the anomaly indicator detected by the model, the dashed line represents the anomaly judgment threshold, the box represents the real anomaly reference label, and the star represents the model's prediction of anomaly. It can be seen from the figure that the samples predicted as anomalies are consistent with the real anomaly reference labels. The experimental results show that the fertilizer heavy metal pollution anomaly detection model can detect fertilizer heavy metal pollution well.
[0100] In an optional embodiment, this application also provides a computer-readable storage medium storing a fertilizer heavy metal pollution anomaly detection program S1 to S6. The program includes computer-executable instructions, which, when executed by a computer's processor, can be used to implement any of the aforementioned fertilizer heavy metal pollution anomaly detection methods. The fertilizer heavy metal pollution anomaly detection program can be developed in a computing platform using the Python programming language and built based on the PyTorch framework, and can be deployed in a processing device with computing capabilities.
Claims
1. A method for detecting abnormal heavy metal pollution in fertilizers, characterized in that: Obtain fertilizer heavy metal monitoring data and construct an original dataset. The original dataset includes fertilizer application dosage, heavy metal concentration in different environmental media, the correspondence between application time and monitoring time, and environmental media attribute information. The environmental media include five categories: fertilizer, topsoil, deep soil, irrigation water, and crops. The original dataset is obtained using the above parameters. Based on the original dataset, the fertilizer dosage quota coefficient is obtained by calculating the proportion of the application amount per unit area of the fertilizer batch on the plot to the total application amount of the fertilizer batch. The media-weighted exposure is calculated using importance weights, and time decay weights are introduced. The exposure intensity is calculated based on the fertilizer dosage quota coefficient and the media-weighted exposure to obtain the first dataset. A fertilizer batch decay coefficient is introduced to process the first dataset to obtain a load evolution baseline. This baseline is then uniformly scaled and averaged to obtain a perturbation intensity factor. This perturbation intensity factor, along with the deviation response coefficient and perturbation suppression coefficient, is used to construct a heavy metal analytical quantity. These are then integrated to obtain a second dataset. For the current fertilizer batch, using the exposure intensity as input, historical batches are assigned weights that decrease inversely over time using an exponential decay function. The decay rate is determined by the fertilizer batch decay coefficient. To control the load evolution baseline, sum the attenuation-weighted exposure intensities of all historical batches and divide by the sum of their corresponding weights. The difference between the exposure intensity of each heavy metal and the corresponding load evolution baseline is calculated sequentially, and the difference is divided by the load evolution baseline of the corresponding heavy metal and a minimum positive number. The sum of these values, taken as absolute values, yields the relative deviation of the heavy metals. The arithmetic mean of these relative deviations for all heavy metals is then calculated to obtain the disturbance intensity factor. Introducing the deviation response coefficient The relative deviation is weighted, 1 is added, and then multiplied by the base value to obtain the numerator. The disturbance intensity factor and the disturbance suppression coefficient are... The product of these factors plus 1, with 1 as the denominator, yields the ratio of the dissolved heavy metal amount. Ultimately, a joint feature set of heavy metal load evolution and environmental disturbance was obtained. As the second dataset, any fertilizer application batch number is denoted as... Any farmland plot is numbered as Any heavy metal type is denoted as ; The second dataset uses risk weighting coefficients to obtain heavy metal risk drivers, introduces memory coefficients and perturbation injection coefficients to calculate risk mapping states, and decomposes trend advancements based on these risk mapping states to construct risk trend increments. A third dataset is obtained by expanding the risk trend sequence. This third dataset consists of a training set and a prediction set. For each heavy metal, the resolution value is incremented by 1, the natural logarithm is taken, and then multiplied by the risk weighting coefficient. The weighted summation yields the heavy metal risk driver. The risk mapping state of the previous batch multiplied by the memory coefficient The historical risk retention term is obtained by multiplying the heavy metal risk driver amount of the current batch by the complement of the memory coefficient to obtain the current batch update term, and the absolute difference of the heavy metal risk driver amount of adjacent batches is multiplied by the disturbance injection coefficient. The explicit perturbation term is obtained. The historical risk retention term, the current batch update term, and the explicit perturbation term are added together to obtain the risk mapping state of the current batch. ; The risk trend deviation is obtained by calculating the degree of deviation between the risk value and the mean of the training set. The risk trend deviation is mapped to the continuous anomaly indication result to calculate the anomaly indication. Anomaly results are judged based on the anomaly judgment threshold. A loss function is designed to optimize the model training. The prediction set is input into the trained fertilizer heavy metal pollution anomaly detection model, and the final output is the anomaly detection value.
2. The method for detecting abnormal heavy metal pollution in fertilizers according to claim 1, characterized in that, Under any combination of dimensions, obtain the corresponding heavy metal monitoring values. The ratio of the amount of fertilizer applied per unit area on the plot to the total amount applied is calculated, and a small positive number is introduced. To ensure the denominator is not zero, construct the fertilizer dosage quota coefficient. For each monitoring time window and each heavy metal, a weighted exposure value of the medium is constructed by weighted summation. Each environmental medium is assigned an importance weight. Introducing the concentration compression index Adjusting the contribution of different medium concentrations to the overall exposure, wherein any monitoring time window is numbered as follows: , Indicates in After the first fertilization, in the plot Time window The first one detected internally Measured concentration values of several heavy metals.
3. The method for detecting abnormal heavy metal pollution in fertilizers according to claim 2, characterized in that, The application time of each fertilizer batch on a specific plot is recorded as the baseline time point. The absolute value of the time interval between the baseline time point and each monitoring time window is used as the basis, and the time decay coefficient is applied. Construct an inverse proportional time decay weight function to obtain the time decay weight. The media-weighted exposure amounts for each monitoring time window are weighted and accumulated based on the time decay weight, and then multiplied by the fertilizer dosage quota coefficient to obtain the exposure intensity of each heavy metal. Finally, a multi-source fertilizer heavy metal monitoring dataset was obtained. This serves as the first dataset.
4. The method for detecting abnormal heavy metal pollution in fertilizers according to claim 1, characterized in that, Calculate the risk mapping state difference between the current batch and the previous batch, and multiply the difference by the incremental smoothing coefficient. The complement of the previous batch's risk trend increment is added to the value obtained by multiplying the previous batch's risk trend increment by the increment smoothing coefficient; the result is the risk trend increment for the current batch. The risk mapping status of the current batch is matched with the step sequence index value. The sum of the results multiplied by the risk trend increment, followed by the negative, is used as the input to the exponential function. The reciprocal of the exponential value plus 1 is then calculated to obtain the risk expansion value. Ultimately, a risk trend set is obtained. The third dataset is divided into a training set and a prediction set in a 7:3 ratio.
5. The method for detecting abnormal heavy metal pollution in fertilizers according to claim 1, characterized in that, Calculate the mean of the risk trend set along the unfolded dimension. Sum the absolute differences between the risk unfolded value and the mean, and divide by the number of trend unfolding steps. The risk trend deviation is obtained. Calculate the deviation of the risk trend from the abnormal baseline value. The difference is multiplied by the steepness coefficient. Take the negative value, input the exponent into the exponent function to obtain the exponent value, add 1 and take the reciprocal to get the abnormal indication value. Calculate the specified quantiles of all the aforementioned anomaly indicators as the anomaly determination threshold. Each abnormal indicator is compared with the threshold. If the abnormal indicator is greater than or equal to the threshold, the result is 1, indicating an abnormal state; if it is less than the threshold, the result is 0, indicating a normal state.
6. The method for detecting abnormal heavy metal pollution in fertilizers according to claim 5, characterized in that, Calculate the aforementioned anomaly indicators and anomaly reference labels for all fertilization batches and plots. The mean squared error is used as the basic loss term, and the discrimination steepness coefficient and the square of the outlier benchmark value are multiplied by the corresponding regularization coefficient. and As a regularization constraint, the basic loss term is added to the two regularization constraint terms to form the loss function. The model is trained and optimized to obtain the trained fertilizer heavy metal pollution anomaly detection model, and finally the anomaly detection value is output.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a fertilizer heavy metal pollution anomaly detection program, which can implement the steps of a fertilizer heavy metal pollution anomaly detection method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
System, method and device for tissue-based diagnosis
CN102395881A
Soil heavy-metal accumulation predicting method employing emission inventory and receptor model
WO2025148550A1