A detection method for heavy metals in food based on big data

Through the combination of big data technology and multiple algorithms, the complexity and low efficiency of traditional food heavy metal detection methods are solved, and high-precision and efficient detection are achieved, which is suitable for the detection needs of different foods and standards.

CN118883859BActive Publication Date: 2025-01-03CHONGQING ACAD OF METROLOGY & QUALITY INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410912461.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2025-01-03
Estimated Expiration
2044-07-09

AI Technical Summary

Technical Problem

The heavy metal detection methods in traditional foods are complex in operation, high in cost, long in detection cycles, and have low detection efficiency for large batches of samples, making it difficult to realize real-time monitoring and data analysis of the entire process.

Method used

Using a detection method based on big data, the detection data and heavy metal data in food are collected and preprocessed, and the detailed level data is obtained, and the food heavy metal detection model is constructed, and the sliding window technology, convolutional neural network, autoencoder, long-term and short-term Memory algorithms and other technical means optimize the detection model to improve detection accuracy.

Benefits of technology

It improves the accuracy and efficiency of heavy metal detection in food, realizes automatic detection and real-time grading, adapts to the testing needs of different standards and food types, and is universal.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118883859B_ABST
    Figure CN118883859B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for detecting heavy metals in food based on big data, including collecting detection data and heavy metal data in food, preprocessing the detection data and the heavy metal data; the detection data includes measured data and image data; obtaining detail level data according to the detection data and the heavy metal data; the detail level data includes characteristic data, heavy metal amount and degree of change; selecting and combining the detail level data to obtain condition data, building a food heavy metal detection model according to the condition data; optimizing the food heavy metal detection model, inputting the data to be monitored into the food heavy metal detection model, and outputting the detection result. This method can not only improve the accuracy of heavy metal detection in food based on big data, but also has good interpretability, and can be directly applied to a detection system for heavy metals in food based on big data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of big data, and in particular to a method for detecting heavy metals in food based on big data. Background Art

[0002] With the acceleration of industrialization in modern society, environmental pollution is becoming increasingly serious, especially heavy metal pollution. Heavy metals such as lead, mercury, cadmium, chromium, etc. are difficult to degrade naturally in the environment due to their stability and toxicity, and may enter the human body through the food chain, posing a serious threat to human health. The detection and monitoring of heavy metals in food is of great significance to ensure food safety and maintain human health.

[0003] In recent years, the problem of heavy metal pollution in food has become increasingly serious due to industrial wastewater, pesticide residues, mining and other reasons. In particular, agricultural products such as rice, vegetables, and fruits are more susceptible to heavy metal pollution due to their long growth cycle and strong absorption capacity. In addition, heavy metal pollution may also be introduced during food processing, storage, and transportation. Therefore, the detection and monitoring of heavy metals in food has become an important task for food safety supervision.

[0004] Traditional methods for detecting heavy metals in food have the limitations of complex operation, high cost and long detection cycle. In addition, professional personnel are required to operate, and the detection efficiency of large batches of samples is low. Therefore, how to optimize the current heavy metal detection methods based on real-time monitoring and data analysis of the entire process of food production, processing, storage, and transportation, combined with a variety of detection methods and technologies, has become a problem to be solved. Summary of the invention

[0005] The purpose of the present invention is to provide a method for detecting heavy metals in food based on big data.

[0006] To achieve the above object, the present invention is implemented according to the following technical solutions:

[0007] The present invention comprises the following steps:

[0008] Collecting detection data and heavy metal data in food, and preprocessing the detection data and the heavy metal data; the detection data includes measured data and image data;

[0009] Obtaining detail level data according to the detection data and the heavy metal data; the detail level data includes characteristic data, heavy metal amount and degree of change; the characteristic data characterizes the characteristic manifestation of food changes caused by heavy metals; the heavy metal amount characterizes the weight of heavy metals contained in food; the degree of change characterizes the magnitude of food quality changes caused by heavy metals;

[0010] Selecting and combining the detailed level data to obtain conditional data, and constructing a food heavy metal detection model according to the conditional data;

[0011] Optimize the food heavy metal detection model, input the data to be monitored into the food heavy metal detection model, and output the detection results.

[0012] Furthermore, the method for obtaining the characteristic data includes:

[0013] The detection data and heavy metal data are sorted by time to obtain time series data, and the time series data are segmented using the sliding window technology to obtain sub-time series;

[0014] Determine the window size, the expression is:

[0015]

[0016] The sliding window size is M, the parameter quantity is s, and the time series data at the ιth time is f ι , data segment [t b ,t b +1] The fitting data of the time series data is The time of the bth item in the sliding window is t b , the discriminant formula of sliding window size M is

[0017] Determine the optimal sliding window size based on the sliding window size judgment formula combined with the Bayesian information criterion;

[0018] Calculate the change in time series data:

[0019]

[0020] The similarity tolerance parameter is The bth time series data is f b , the uth time series data is f u , the maximum value function is max{·}, the norm function is ‖·‖, and the i-th time series data value is f i , the vth time series data value is f v , the change between the i-th time series data and the v-th time series data is

[0021] The network adjacency matrix is ​​constructed by the distance between time series data, and the edge connection rule is:

[0022]

[0023] The distance threshold is The network density between the i-th time series data and the v-th time series data is h i,v, the edge rule is

[0024] Calculate the rate of change of network density:

[0025]

[0026] The network is G, the i-th time series data and the v-th time series data belong to the network G as i,v∈G, the number of time series data is m, and the change rate of network density is

[0027] Take the time series data as the child nodes of the network and calculate the degree association of the child nodes:

[0028]

[0029] Among them The remaining degree of a node is The remaining degree of the jth node is q j , the remaining degree is equal to the node The joint distribution probability of j is The standard deviation of the residual degree is ψ g , the degree of correlation is

[0030] Nodes with degree correlation greater than 0.463 are output as feature data.

[0031] Furthermore, the method for obtaining detail level data according to the detection data and the heavy metal data includes:

[0032] Convolutional neural network and autoencoder are used to extract features of detection data and heavy metal data respectively to obtain detection features;

[0033] Observe the detection features from multiple angles, decompose the detection features into consistent representation matrix, specific representation matrix and error matrix, and give the objective function of detection feature classification:

[0034]

[0035] The objective function is The F-block diagonal regularizer is ‖·‖ F , the L2 norm is ‖·‖2, and the error matrix of the ath angle is E a , the consistent representation matrix is ​​W, and the equilibrium parameter of the consistent representation matrix is ​​ζ W , specifically representing the equilibrium parameter of the matrix X as ζ X , the number of angles is

[0036] Update the consistent representation matrix, the expression is:

[0037]

[0038] The updated consistent representation matrix is ​​K, and the characteristic matrix of the ath angle is U a , the feature matrix U a The transpose of (U a ) T , the first Lagrange multiplier for the ath angle is The second Lagrange multiplier for the ath angle is The penalty parameter is τ, the auxiliary matrix of the consistent representation matrix is ​​S, and the auxiliary matrix of the a-th angle of the specific representation is Q a , the distance matrix of the ath angle is R a ;

[0039] Compute the adjuvant matrix of the consistent representation matrix:

[0040]

[0041] The first Lagrange multiplier is φ1, the balance parameter is β, the vector diagonalization matrix is ​​diag(·), and the non-negative elements are [·] + , the minimum feature distance matrix is ​​D;

[0042] Update the minimum feature distance matrix, the expression is:

[0043]

[0044] The Euclidean inner product of the matrix is ​​<·>, the diagonal matrix of the auxiliary matrix S is diag(S1)-S, and the updated minimum characteristic distance matrix is

[0045] Update the auxiliary matrix of a specific representation matrix. The expression is:

[0046]

[0047] The specific representation matrix of the ath angle is X a , the auxiliary matrix of the ath angle-specific representation matrix after updating is The third Lagrange multiplier is φ3;

[0048] Update the error matrix, the expression is:

[0049]

[0050] The error matrix of the ath angle after update is L 2,1 The norm of is ‖·‖ 2,1 , the auxiliary matrix of the updated specific representation matrix is

[0051] Update the specific representation matrix, the expression is:

[0052]

[0053] The specific representation matrix of the ath angle after update is The third Lagrange multiplier for the ath angle is The soft threshold operator is

[0054] Update the Lagrange multiplier, the expression is:

[0055]

[0056] The first Laplang multiplier of the ath angle after update is After updating, the second Laplang multiplier of the ath angle is After updating, the third Laplang multiplier of the ath angle is

[0057] Calculate the affinity matrix, the expression is:

[0058]

[0059] The affinity matrix is The adjustment constant is Spectral clustering is applied to the affinity matrix, and the clustering results are output as detail level data.

[0060] Furthermore, the method for obtaining the degree of change includes:

[0061] The long short-term memory algorithm is used to obtain the deviation between the detection data and the heavy metal data, and the deviation is output as the degree of change.

[0062] Furthermore, the method for obtaining conditional data by selecting and combining the detail level data includes:

[0063] The dynamic weighted majority algorithm is used to dynamically adjust the weights of the detail level data using the base classifier, and weighted majority voting is performed on the base classifier with the dynamically adjusted weights, and the voting results are output as conditional data.

[0064] Furthermore, a method for constructing a food heavy metal detection model according to the conditional data includes:

[0065] Food heavy metal detection models include random forest algorithm, long short-term memory network algorithm, matching algorithm, and deep learning algorithm;

[0066] The random forest algorithm divides the input data into training and test sets in a ratio of 5:1;

[0067] The long short-term memory network algorithm extracts the time series change characteristics of the training set, calculates the degree of change of the time series change characteristics, and selects key features based on the degree of change;

[0068] The matching algorithm compares the key features and condition data to obtain the matching degree, takes the key features with a matching degree less than 0.861 as special features, and calculates the deviation heavy metal content;

[0069] The deep learning algorithm learns the complex model of special features and deviation heavy metal content, automatically extracts special features and establishes mapping relationships, and predicts the heavy metal content based on the mapping relationships;

[0070] The test set is input into the food heavy metal detection model to obtain the predicted heavy metal amount, the variance of the actual heavy metal amount and the predicted heavy metal amount is calculated, and the parameters of the food heavy metal detection model are adjusted according to the variance.

[0071] Furthermore, the method for optimizing the food heavy metal detection model comprises:

[0072] Construct the initialization matrix based on the search subposition and calculate the balance factor:

[0073]

[0074] The balance factor is μ and the maximum number of iterations is t max , the current iteration number is t, and the random number between 0 and 1 is r o , the coefficient of deviation is

[0075] Select the dimension according to the odd and even numbers and update the position of the searcher. The expression is:

[0076]

[0077] The d-th dimension position of the c-th searcher at the t+1-th iteration is The d-th dimension position of the c-th searcher at the t-th iteration is The yth random integer selected from dimension d is α y , the searcher randomly selected from the population is r, the random numbers between 0 and 1 are r1 and r2 respectively, and the αth number of the cth searcher at the tth iteration y The dimension position is The αth value of the rth searcher at the tth iteration y The dimension position is

[0078] The Levy flight is used to update the search sub-position, and the expression is:

[0079]

[0080] The position of the cth searcher at the t+1th iteration after the Levy flight update is The optimal search subposition for the tth iteration is The random search subposition of the tth iteration is The random numbers from 0 to 1 are r3 and r4, the normal distribution random numbers are λ and ρ, the flight constant is γ, the probability function is H(·), and the minimum distance between searchers is l min , the flight coefficient is

[0081] Update the search sub-position according to the falling step length, the expression is:

[0082]

[0083] The position of the cth searcher at the tth iteration after the falling step length is updated The position of the cth searcher at the tth iteration after the Levy flight update is The position of the random search subiteration t after the Levy flight update is The random numbers from 0 to 1 are r5, r6, and r7 respectively, the step factor is χ, and the number of searchers is The search upper limit of the c-th searcher is L c , the search lower limit of the c-th searcher is v c , the natural constant is e;

[0084] Continue iterating until the maximum number of iterations is reached, otherwise update the balance factor.

[0085] In the second aspect, a detection system for heavy metals in food based on big data includes:

[0086] Data acquisition module: used to collect detection data and heavy metal data in food, and pre-process the detection data and heavy metal data; the detection data includes measured data and image data;

[0087] Data clustering module: used to obtain detail level data according to the detection data and the heavy metal data; the detail level data includes characteristic data, heavy metal amount and change degree; the characteristic data represents the characteristic performance of food changes caused by heavy metals; the heavy metal amount represents the weight of heavy metals contained in food; the change degree represents the magnitude of food quality change caused by heavy metals;

[0088] Model building module: used to obtain conditional data by selecting and combining the detailed level data, and to build a food heavy metal detection model according to the conditional data;

[0089] Optimization detection module: used to optimize the food heavy metal detection model, input the data to be monitored into the food heavy metal detection model, and output the detection results.

[0090] The beneficial effects of the present invention are:

[0091] The present invention is a method for detecting heavy metals in food based on big data. Compared with the prior art, the present invention has the following technical effects:

[0092] The present invention can improve the accuracy of heavy metal detection in food through preprocessing, obtaining detail level data, obtaining feature data, selecting combinations, model construction and model optimization steps, thereby improving the detection precision of heavy metal detection in food, optimizing the detection of heavy metals in food, greatly saving resources, and improving work efficiency, and can realize automatic detection of heavy metals in food, and perform combined grading of the detection of heavy metals in food in real time, which is of great significance to the detection of heavy metals in food, can adapt to the detection of heavy metals in food of different standards and the detection needs of heavy metals in different foods, and has a certain universality. BRIEF DESCRIPTION OF THE DRAWINGS

[0093] Figure 1 This is a flowchart of the steps of a method for detecting heavy metals in food based on big data of the present invention. DETAILED DESCRIPTION

[0094] The present invention is further described below by means of specific embodiments. The illustrative embodiments and descriptions of the present invention are used to explain the present invention but are not intended to limit the present invention.

[0095] The present invention provides a method for detecting heavy metals in food based on big data, comprising the following steps:

[0096] like Figure 1 As shown, in this embodiment, the following steps are included:

[0097] Collecting detection data and heavy metal data in food, and preprocessing the detection data and the heavy metal data; the detection data includes measured data and image data;

[0098] In the actual assessment, the measured data include food name, source, collection time, collection conditions, tissue state, texture, smell, temperature, humidity, moisture, protein, fat, carbohydrates, vitamins, minerals, drug residues, total colony count, pathogenic bacteria, mold, and yeast;

[0099] Obtaining detail level data according to the detection data and the heavy metal data; the detail level data includes characteristic data, heavy metal amount and degree of change; the characteristic data characterizes the characteristic manifestation of food changes caused by heavy metals; the heavy metal amount characterizes the weight of heavy metals contained in food; the degree of change characterizes the magnitude of food quality changes caused by heavy metals;

[0100] In the actual evaluation, the characteristic data of rice in the sampling area are tissue state, smell, minerals, total colony count, pathogenic bacteria, mold, and yeast;

[0101] Selecting and combining the detailed level data to obtain conditional data, and constructing a food heavy metal detection model according to the conditional data;

[0102] Optimizing the food heavy metal detection model, inputting the data to be monitored into the food heavy metal detection model, and outputting the detection results;

[0103] In the actual assessment, the entire growth cycle of rice from a certain production area was tested, and the test results showed that the rice was contaminated with heavy metals lead and cadmium during the jointing stage, with the heavy metal content being 0.21 mg / kg.

[0104] In this embodiment, the method for obtaining the characteristic data includes:

[0105] The detection data and heavy metal data are sorted by time to obtain time series data, and the time series data are segmented using the sliding window technology to obtain sub-time series;

[0106] Determine the window size, the expression is:

[0107]

[0108] The sliding window size is M, the parameter quantity is s, and the time series data at the ιth time is f ι , data segment [t b ,t b +1] The fitting data of the time series data is The time of the bth item in the sliding window is t b , the discriminant formula of sliding window size M is

[0109] Determine the optimal sliding window size based on the sliding window size judgment formula combined with the Bayesian information criterion;

[0110] Calculate the change in time series data:

[0111]

[0112] The similarity tolerance parameter is The bth time series data is f b, the uth time series data is f u , the maximum value function is max{·}, the norm function is ‖·‖, and the i-th time series data value is f i , the vth time series data value is f v , the change between the i-th time series data and the v-th time series data is

[0113] The network adjacency matrix is ​​constructed by the distance between time series data, and the edge connection rule is:

[0114]

[0115] The distance threshold is The network density between the i-th time series data and the v-th time series data is h i,v , the edge rule is

[0116] Calculate the rate of change of network density:

[0117]

[0118] The network is G, the i-th time series data and the v-th time series data belong to the network G as i,v∈G, the number of time series data is m, and the change rate of network density is

[0119] Take the time series data as the child nodes of the network and calculate the degree association of the child nodes:

[0120]

[0121] Among them The remaining degree of a node is The remaining degree of the jth node is q j , the remaining degree is equal to the node The joint distribution probability of j is The standard deviation of the residual degree is ψ g , the degree of correlation is

[0122] Nodes with degree correlation greater than 0.463 are output as feature data.

[0123] In this embodiment, the method for obtaining detail level data according to the detection data and the heavy metal data includes:

[0124] Convolutional neural network and autoencoder are used to extract features of detection data and heavy metal data respectively to obtain detection features;

[0125] Observe the detection features from multiple angles, decompose the detection features into consistent representation matrix, specific representation matrix and error matrix, and give the objective function of detection feature classification:

[0126]

[0127] The objective function is The F-block diagonal regularizer is ‖·‖ F , the L2 norm is ‖·‖2, and the error matrix of the ath angle is E a , the consistent representation matrix is ​​W, and the equilibrium parameter of the consistent representation matrix is ​​ζ W , specifically representing the equilibrium parameter of the matrix X as ζ X , the number of angles is

[0128] Update the consistent representation matrix, the expression is:

[0129]

[0130] The updated consistent representation matrix is ​​K, and the characteristic matrix of the ath angle is U a , the feature matrix U a The transpose of (U a ) T , the first Lagrange multiplier for the ath angle is The second Lagrange multiplier for the ath angle is The penalty parameter is τ, the auxiliary matrix of the consistent representation matrix is ​​S, and the auxiliary matrix of the a-th angle of the specific representation is Q a , the distance matrix of the ath angle is R a ;

[0131] Compute the adjuvant matrix of the consistent representation matrix:

[0132]

[0133] The first Lagrange multiplier is φ1, the balance parameter is β, the vector diagonalization matrix is ​​diag(·), and the non-negative elements are [·] + , the minimum feature distance matrix is ​​D;

[0134] Update the minimum feature distance matrix, the expression is:

[0135]

[0136] The Euclidean inner product of the matrix is ​​<·>, the diagonal matrix of the auxiliary matrix S is diag(S1)-S, and the updated minimum characteristic distance matrix is

[0137] Update the auxiliary matrix of a specific representation matrix. The expression is:

[0138]

[0139] The specific representation matrix of the ath angle is X a , the auxiliary matrix of the ath angle-specific representation matrix after updating is The third Lagrange multiplier is φ3;

[0140] Update the error matrix, the expression is:

[0141]

[0142] The error matrix of the ath angle after update is L 2,1 The norm of is ‖·‖ 2,1 , the auxiliary matrix of the updated specific representation matrix is

[0143] Update the specific representation matrix, the expression is:

[0144]

[0145] The specific representation matrix of the ath angle after update is The third Lagrange multiplier for the ath angle is The soft threshold operator is

[0146] Update the Lagrange multiplier, the expression is:

[0147]

[0148] The first Laplang multiplier of the ath angle after update is After updating, the second Laplang multiplier of the ath angle is After updating, the third Laplang multiplier of the ath angle is

[0149] Calculate the affinity matrix, the expression is:

[0150]

[0151] The affinity matrix is The adjustment constant is Spectral clustering is applied to the affinity matrix, and the clustering results are output as detail level data.

[0152] In this embodiment, the method for obtaining the degree of change includes:

[0153] The long short-term memory algorithm is used to obtain the deviation between the detection data and the heavy metal data, and the deviation is output as the degree of change.

[0154] In this embodiment, the method for obtaining conditional data by selecting and combining the detail level data includes:

[0155] The dynamic weighted majority algorithm is used to dynamically adjust the weights of the detail level data using the base classifier, and weighted majority voting is performed on the base classifier with the dynamically adjusted weights, and the voting results are output as conditional data.

[0156] In this embodiment, the method for constructing a food heavy metal detection model according to the conditional data includes:

[0157] Food heavy metal detection models include random forest algorithm, long short-term memory network algorithm, matching algorithm, and deep learning algorithm;

[0158] The random forest algorithm divides the input data into training and test sets in a ratio of 5:1;

[0159] The long short-term memory network algorithm extracts the time series change characteristics of the training set, calculates the degree of change of the time series change characteristics, and selects key features based on the degree of change;

[0160] The matching algorithm compares the key features and condition data to obtain the matching degree, takes the key features with a matching degree less than 0.861 as special features, and calculates the deviation heavy metal content;

[0161] The deep learning algorithm learns the complex model of special features and deviation heavy metal content, automatically extracts special features and establishes mapping relationships, and predicts the heavy metal content based on the mapping relationships;

[0162] The test set is input into the food heavy metal detection model to obtain the predicted heavy metal amount, the variance of the actual heavy metal amount and the predicted heavy metal amount is calculated, and the parameters of the food heavy metal detection model are adjusted according to the variance.

[0163] In this embodiment, the method for optimizing the food heavy metal detection model includes:

[0164] Construct the initialization matrix based on the search subposition and calculate the balance factor:

[0165]

[0166] The balance factor is μ and the maximum number of iterations is t max , the current iteration number is t, and the random number between 0 and 1 is r o , the coefficient of deviation is

[0167] Select the dimension according to the odd and even numbers and update the position of the searcher. The expression is:

[0168]

[0169] The d-th dimension position of the c-th searcher at the t+1-th iteration is The d-th dimension position of the c-th searcher at the t-th iteration is The yth random integer selected from dimension d is α y , the searcher randomly selected from the population is r, the random numbers between 0 and 1 are r1 and r2 respectively, and the αth number of the cth searcher at the tth iteration y The dimension position is The αth value of the rth searcher at the tth iteration y The dimension position is

[0170] The Levy flight is used to update the search sub-position, and the expression is:

[0171]

[0172] The position of the cth searcher at the t+1th iteration after the Levy flight update is The optimal search subposition for the tth iteration is The random search subposition of the tth iteration is The random numbers from 0 to 1 are r3 and r4, the normal distribution random numbers are λ and ρ, the flight constant is γ, the probability function is H(·), and the minimum distance between searchers is l min , the flight coefficient is

[0173] Update the search sub-position according to the falling step length, the expression is:

[0174]

[0175] The position of the cth searcher at the tth iteration after the falling step length is updated The position of the cth searcher at the tth iteration after the Levy flight update is The position of the random search subiteration t after the Levy flight update is The random numbers from 0 to 1 are r5, r6, and r7 respectively, the step factor is χ, and the number of searchers is The search upper limit of the c-th searcher is L c , the search lower limit of the c-th searcher is v c , the natural constant is e;

[0176] Continue iterating until the maximum number of iterations is reached, otherwise update the balance factor.

[0177] In the second aspect, a detection system for heavy metals in food based on big data includes:

[0178] Data acquisition module: used to collect detection data and heavy metal data in food, and pre-process the detection data and heavy metal data; the detection data includes measured data and image data;

[0179] Data clustering module: used to obtain detail level data according to the detection data and the heavy metal data; the detail level data includes characteristic data, heavy metal amount and change degree; the characteristic data represents the characteristic performance of food changes caused by heavy metals; the heavy metal amount represents the weight of heavy metals contained in food; the change degree represents the magnitude of food quality change caused by heavy metals;

[0180] Model building module: used to obtain conditional data by selecting and combining the detailed level data, and to build a food heavy metal detection model according to the conditional data;

[0181] Optimization detection module: used to optimize the food heavy metal detection model, input the data to be monitored into the food heavy metal detection model, and output the detection results.

[0182] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for detecting heavy metals in food based on big data, characterized in that: The following steps are involved: Collecting detection data and heavy metal data in food, and preprocessing the detection data and the heavy metal data; the detection data includes measured data and image data; Acquire detail level data according to the detection data and the heavy metal data; the detail level data includes characteristic data, heavy metal amount and degree of change; the characteristic data characterizes the characteristic manifestation of food changes caused by heavy metals; The amount of heavy metals represents the weight of heavy metals contained in food; the degree of change represents the extent of the quality change of food caused by heavy metals; including: The detection data and heavy metal data are sorted by time to obtain time series data, and the time series data are segmented using the sliding window technology to obtain sub-time series; Determine the window size, the expression is: The sliding window size is M, the parameter quantity is s, and the The time series data for each time period is , data fragment The fitting data of the internal time series data is , the b-th time in the sliding window is , the discriminant formula of sliding window size M is ; Determine the optimal sliding window size based on the sliding window size judgment formula combined with the Bayesian information criterion; Calculate the change in time series data: The similarity tolerance parameter is , the bth time series data is , the u-th time series data is , the maximum value function is , the norm function is , the i-th time series data value is , the vth time series data value is , the change between the i-th time series data and the v-th time series data is ; The network adjacency matrix is ​​constructed by the distance between time series data, and the edge connection rule is: The distance threshold is , the network density of the i-th time series data and the v-th time series data is , the edge rule is ; Calculate the rate of change of network density: The network is G, the i-th time series data and the v-th time series data belong to the network G , the number of time series data is m, and the change rate of network density is ; Take the time series data as the child nodes of the network and calculate the degree association of the child nodes: Among them The remaining degree of a node is , the remaining degree of the jth node is , the remaining degree is equal to the node The joint distribution probability of , j is The standard deviation of the residual degree is , the degree of correlation is ; Output nodes with degree correlation greater than 0.463 as feature data; Convolutional neural network and autoencoder are used to extract features of detection data and heavy metal data respectively to obtain detection features; Observe the detection features from multiple angles, decompose the detection features into consistent representation matrix, specific representation matrix and error matrix, and give the objective function of detection feature classification: The objective function is , the F-block diagonal regularizer is , The square norm of , the error matrix of the ath angle is , the consistent representation matrix is ​​W, and the balance parameter of the consistent representation matrix is , specifically representing the balance parameter of the matrix X as , the number of angles is ; Update the consistent representation matrix, the expression is: The updated consistent representation matrix is ​​K, and the characteristic matrix of the ath angle is , the feature matrix The transpose of , the first Lagrange multiplier for the ath angle is , the second Lagrange multiplier for the ath angle is , the penalty parameter is , the auxiliary matrix of the consistent representation matrix is ​​S, and the a-th angle auxiliary matrix of the specific representation is , the distance matrix of the ath angle is ; Compute the adjuvant matrix of the consistent representation matrix: The first Lagrange multiplier is , the equilibrium parameter is , the vector diagonal matrix is , retain the non-negative elements as , the minimum feature distance matrix is ​​D; Update the minimum feature distance matrix, the expression is: The Euclidean inner product of the matrix is , the diagonal matrix of the auxiliary matrix S is , the updated minimum feature distance matrix is ; Update the auxiliary matrix of a specific representation matrix. The expression is: The specific representation matrix of the ath angle is , the auxiliary matrix of the ath angle-specific representation matrix after updating is , the third Lagrange multiplier is ; Update the error matrix, the expression is: The error matrix of the ath angle after update is , The norm of , the auxiliary matrix of the updated specific representation matrix is ; Update the specific representation matrix, the expression is: The specific representation matrix of the ath angle after update is , the third Lagrange multiplier for the ath angle is , the soft threshold operator is ; Update the Lagrange multiplier, the expression is: The first Laplang multiplier of the ath angle after update is , the second Laplang multiplier of the ath angle after update is , the third Laplang multiplier of the ath angle after update is ; Calculate the affinity matrix, the expression is: The affinity matrix is , the adjustment constant is , spectral clustering is applied to the affinity matrix, and the clustering results are output as detail level data; Selecting and combining the detailed level data to obtain conditional data, and constructing a food heavy metal detection model according to the conditional data; Optimize the food heavy metal detection model, input the data to be monitored into the food heavy metal detection model, and output the detection results.

2. According to claim 1, a method for detecting heavy metals in food based on big data is characterized in that: The method for obtaining the degree of change includes: The long short-term memory algorithm is used to obtain the deviation between the detection data and the heavy metal data, and the deviation is output as the degree of change.

3. According to claim 1, a method for detecting heavy metals in food based on big data, characterized in that: The method for obtaining conditional data by selecting and combining the detail level data comprises: The dynamic weighted majority algorithm is used to dynamically adjust the weights of the detail level data using the base classifier, and weighted majority voting is performed on the base classifier with the dynamically adjusted weights, and the voting results are output as conditional data.

4. According to claim 1, a method for detecting heavy metals in food based on big data, characterized in that: The method for constructing a food heavy metal detection model according to the conditional data comprises: Food heavy metal detection models include random forest algorithm, long short-term memory network algorithm, matching algorithm, and deep learning algorithm; The random forest algorithm divides the input data into training and test sets in a ratio of 5:1; The long short-term memory network algorithm extracts the time series change characteristics of the training set, calculates the degree of change of the time series change characteristics, and selects key features based on the degree of change; The matching algorithm compares the key features and condition data to obtain the matching degree, takes the key features with a matching degree less than 0.861 as special features, and calculates the deviation heavy metal content; The deep learning algorithm learns the complex model of special features and deviation heavy metal content, automatically extracts special features and establishes mapping relationships, and predicts the heavy metal content based on the mapping relationships; The test set is input into the food heavy metal detection model to obtain the predicted heavy metal amount, the variance of the actual heavy metal amount and the predicted heavy metal amount is calculated, and the parameters of the food heavy metal detection model are adjusted according to the variance.

5. According to claim 1, a method for detecting heavy metals in food based on big data, characterized in that: The method for optimizing the food heavy metal detection model comprises: Construct the initialization matrix based on the search subposition and calculate the balance factor: The balance factor is , the maximum number of iterations is , the current number of iterations is , a random number from 0 to 1 is , the coefficient of deviation is ; Select the dimension according to the odd and even numbers and update the position of the searcher. The expression is: The d-th dimension position of the c-th searcher at the t+1-th iteration is , the d-th dimension position of the c-th searcher at the t-th iteration is , the yth random integer selected from dimension d is , the searcher randomly selected from the population is r, and the random numbers between 0 and 1 are , , the c-th searcher at the t-th iteration The dimension position is , the rth searcher at the tth iteration The dimension position is ; The Levy flight is used to update the search sub-position, and the expression is: The position of the cth searcher at the t+1th iteration after the Levy flight update is , the optimal search subposition for the tth iteration is , the random search subposition of the tth iteration is , the random numbers from 0 to 1 are , , the normally distributed random numbers are , , the flight constant is , the probability function is , the minimum distance between search items is , the flight coefficient is ; Update the search sub-position according to the falling step length, the expression is: The position of the cth searcher at the tth iteration after the falling step length is updated , the position of the c-th searcher at the t-th iteration after the Levy flight update is , the position of the random search sub-iteration t after the Levy flight update is , the random numbers from 0 to 1 are , , , the step size factor is , the number of searchers is , the search limit of the c-th searcher is , the search lower limit of the c-th searcher is , the natural constant is e; Continue iterating until the maximum number of iterations is reached, otherwise update the balance factor.

6. A detection system for heavy metals in food based on big data, characterized in that: include: Data acquisition module: used to collect detection data and heavy metal data in food, and pre-process the detection data and heavy metal data; the detection data includes measured data and image data; Data clustering module: used to obtain detail level data according to the detection data and the heavy metal data; the detail level data includes characteristic data, heavy metal amount and change degree; the characteristic data characterizes the characteristic performance of food changes caused by heavy metals; The amount of heavy metals represents the weight of heavy metals contained in food; the degree of change represents the extent of the quality change of food caused by heavy metals; including: The detection data and heavy metal data are sorted by time to obtain time series data, and the time series data are segmented using the sliding window technology to obtain sub-time series; Determine the window size, the expression is: The sliding window size is M, the parameter quantity is s, and the The time series data for each time period is , data fragment The fitting data of the internal time series data is , the b-th time in the sliding window is , the discriminant formula of sliding window size M is ; Determine the optimal sliding window size based on the sliding window size judgment formula combined with the Bayesian information criterion; Calculate the change in time series data: The similarity tolerance parameter is , the bth time series data is , the u-th time series data is , the maximum value function is , the norm function is , the i-th time series data value is , the vth time series data value is , the change between the i-th time series data and the v-th time series data is ; The network adjacency matrix is ​​constructed by the distance between time series data, and the edge connection rule is: The distance threshold is , the network density of the i-th time series data and the v-th time series data is , the edge rule is ; Calculate the rate of change of network density: The network is G, the i-th time series data and the v-th time series data belong to the network G , the number of time series data is m, and the change rate of network density is ; Take the time series data as the child nodes of the network and calculate the degree association of the child nodes: Among them The remaining degree of a node is , the remaining degree of the jth node is , the remaining degree is equal to the node The joint distribution probability of , j is The standard deviation of the residual degree is , the degree of correlation is ; Output nodes with degree correlation greater than 0.463 as feature data; Convolutional neural network and autoencoder are used to extract features of detection data and heavy metal data respectively to obtain detection features; Observe the detection features from multiple angles, decompose the detection features into consistent representation matrix, specific representation matrix and error matrix, and give the objective function of detection feature classification: The objective function is , the F-block diagonal regularizer is , The square norm of , the error matrix of the ath angle is , the consistent representation matrix is ​​W, and the balance parameter of the consistent representation matrix is , specifically representing the balance parameter of the matrix X as , the number of angles is ; Update the consistent representation matrix, the expression is: The updated consistent representation matrix is ​​K, and the characteristic matrix of the ath angle is , the feature matrix The transpose of , the first Lagrange multiplier for the ath angle is , the second Lagrange multiplier for the ath angle is , the penalty parameter is , the auxiliary matrix of the consistent representation matrix is ​​S, and the a-th angle auxiliary matrix of the specific representation is , the distance matrix of the ath angle is ; Compute the adjuvant matrix of the consistent representation matrix: The first Lagrange multiplier is , the equilibrium parameter is , the vector diagonal matrix is , retain the non-negative elements as , the minimum feature distance matrix is ​​D; Update the minimum feature distance matrix, the expression is: The Euclidean inner product of the matrix is , the diagonal matrix of the auxiliary matrix S is , the updated minimum feature distance matrix is ; Update the auxiliary matrix of a specific representation matrix. The expression is: The specific representation matrix of the ath angle is , the auxiliary matrix of the ath angle-specific representation matrix after updating is , the third Lagrange multiplier is ; Update the error matrix, the expression is: The error matrix of the ath angle after update is , The norm of , the auxiliary matrix of the updated specific representation matrix is ; Update the specific representation matrix, the expression is: The specific representation matrix of the ath angle after update is , the third Lagrange multiplier for the ath angle is , the soft threshold operator is ; Update the Lagrange multiplier, the expression is: The first Laplang multiplier of the ath angle after update is , the second Laplang multiplier of the ath angle after update is , the third Laplang multiplier of the ath angle after update is ; Calculate the affinity matrix, the expression is: The affinity matrix is , the adjustment constant is , spectral clustering is applied to the affinity matrix, and the clustering results are output as detail level data; Model building module: used to obtain conditional data by selecting and combining the detailed level data, and to build a food heavy metal detection model according to the conditional data; Optimization detection module: used to optimize the food heavy metal detection model, input the data to be monitored into the food heavy metal detection model, and output the detection results.