Disclosure of Invention
The invention aims to provide a method and a system for evaluating the quality of aquatic vegetables based on production place environment data, which are used for solving one or more technical problems in the prior art and at least providing a beneficial selection or creation condition.
Based on the enrichment rule of different vegetables on heavy metals in the producing area environment, a corresponding vegetable planting safety evaluation model is established for specific producing area environment characteristics and vegetable varieties, the producing area environment soil and water body heavy metal threshold values of the large variety of vegetables for planting aquatic vegetables are obtained through the data of the producing area environment soil and water body heavy metals of various aquatic vegetables, the heavy metal concentration of the aquatic vegetables under the threshold value condition does not exceed a certain upper limit, and the method has important significance for guiding the safe production of the vegetables in a specific area and reasonably evaluating the producing area environment quality.
The invention provides a method and a system for evaluating aquatic vegetable quality based on habitat environment data, which are characterized in that data of heavy metal concentrations of soil and water of various aquatic vegetables in different habitat are obtained through a sensor to serve as an environment data set, threshold values of the heavy metal concentrations of the various vegetables are obtained from a database to serve as a threshold value array, a numerical matrix of the heavy metal concentrations is initialized according to the environment data set, deviation between the environment data set and the threshold value array is obtained through calculation in combination with the numerical matrix and the threshold value array, the deviation is minimized through a gradient descent algorithm, so that the numerical matrix is subjected to gradient descent to obtain the numerical matrix subjected to gradient descent, and the upper limit value of the heavy metal concentrations of the various vegetables is obtained according to the numerical matrix subjected to gradient descent.
In order to accomplish the above object, according to an aspect of the present invention, there is provided a method for evaluating quality of aquatic vegetables based on habitat environmental data, the method comprising the steps of:
s100, acquiring data of heavy metal concentrations of soil and water of various aquatic vegetables in a plurality of different producing places through a sensor to be used as environmental data to collect the aquatic vegetables;
s200, obtaining threshold values of heavy metal concentrations of various vegetables from a database as threshold value arrays;
s300, initializing a numerical matrix of heavy metal concentration according to the environment data set;
s400, calculating to obtain the deviation of the environment data set and the threshold value array by combining the numerical matrix and the threshold value array;
s500, minimizing deviation by using a gradient descent algorithm so as to perform gradient descent on the numerical matrix and obtain the numerical matrix after gradient descent;
s600, obtaining the upper limit values of the heavy metal concentrations of various vegetables according to the numerical matrix after gradient reduction;
in S100, the method for acquiring data of heavy metal concentrations in soil and water of a plurality of aquatic vegetables in a plurality of different production places by using a sensor as an environmental data set includes: for different aquatic leaf vegetables, acquiring data of heavy metal concentration of soil and data of heavy metal concentration of water of each vegetable in each production place of each vegetable respectively through a sensor, wherein the data of heavy metal concentration of soil comprises numerical values of cadmium, chromium, lead, arsenic, mercury and pH value in the soil and is recorded as soil cadmium, soil chromium, soil lead, soil arsenic, soil mercury and soil pH value, the data of heavy metal concentration of water comprises numerical values of cadmium, chromium, lead, arsenic, mercury and pH value in the water and is recorded as water cadmium, water chromium, water lead, water arsenic, water mercury and water pH value, the data of heavy metal concentration of vegetables comprises numerical values of cadmium, chromium, lead, arsenic and mercury in the vegetables and is recorded as vegetable cadmium, vegetable chromium, vegetable lead, vegetable arsenic and vegetable mercury, the numerical values and the data are subjected to dimensionless chemical treatment, and the vegetables are aquatic vegetables, storing data of cadmium in vegetables, chromium in vegetables, lead in vegetables, arsenic in vegetables, mercury in vegetables, cadmium in water, chromium in water, lead in water, arsenic in water, mercury in water, pH value in water, cadmium in soil, chromium in soil, lead in soil, arsenic in soil, mercury in soil and pH value in soil in a form of table as an environment data set;
in S200, the method of obtaining the threshold values of the heavy metal concentrations of the various vegetables from the database as the threshold value array includes: the heavy metal limit value requirements of various aquatic vegetable varieties in the food pollutant limit (GB 2762-2017) are stored in the database, wherein the heavy metal limit value requirements comprise limit values of cadmium, chromium, lead, arsenic and mercury in each aquatic vegetable, the limit values of cadmium, chromium, lead, arsenic and mercury in each aquatic vegetable are respectively used as corresponding heavy metal content threshold values in the aquatic vegetable, and an array consisting of the limit values of cadmium, chromium, lead, arsenic and mercury in each aquatic vegetable is used as a threshold value array.
Further, in S300, the method for initializing the numerical matrix of the heavy metal concentration according to the environmental data set includes:
each row of the environment data set comprises data of vegetable cadmium, vegetable chromium, vegetable lead, vegetable arsenic, vegetable mercury, water cadmium, water chromium, water lead, water arsenic, water mercury, water pH value, soil cadmium, soil chromium, soil lead, soil arsenic, soil mercury and soil pH value collected by an aquatic vegetable in a producing area, wherein the vegetable cadmium, vegetable chromium, vegetable lead, vegetable arsenic and vegetable mercury are numerical values of the content and the pH value of cadmium, chromium, lead, arsenic and mercury contained in the vegetable, the water cadmium, water chromium, water lead, water arsenic, water mercury and water pH value are numerical values of the content and the pH value of cadmium, chromium, lead, arsenic and mercury contained in irrigation water of the vegetable producing area, and the soil cadmium, soil chromium, soil lead, soil arsenic, soil mercury and soil pH value are numerical values of the content and the pH value of cadmium, chromium, lead, arsenic and mercury contained in soil of the vegetable producing area;
the method comprises the following steps that (1) target heavy metal elements in vegetables to be detected are 5 numerical values of cadmium, chromium, lead, arsenic and mercury, data of cadmium, chromium, lead, arsenic and mercury in soil of a vegetable production place and irrigation water are detected, and 10 numerical values of cadmium, chromium, lead, arsenic, mercury, cadmium, chromium, lead, arsenic and mercury are obtained;
in the process of inputting the numerical values of the soil and irrigation water to be detected into a numerical value matrix after dimensionless treatment, the process of obtaining the numerical value matrix by defining and calculating is as follows:
s301, letting scd be a variable representing the water cadmium value, scr be a variable representing the water chromium value, spb be a variable representing the water lead value, sas be a variable representing the water arsenic value, and shg be a variable representing the water mercury value;
s302, a variable representing the soil cadmium value is tcd, a variable representing the soil chromium value is tcr, a variable representing the soil lead value is tpb, a variable representing the soil arsenic value is tas, and a variable representing the soil mercury value is thg;
s303, taking an array formed by 10 numerical values of scd, scr, spb, sas, shg, tcd, tcr, tpb, tas and thg in sequence as an array Ctrs;
s304, enabling a variable k to represent the number of characteristic components, wherein k is greater than 1, the characteristic components are components representing a numerical value in a characteristic extraction process, the variable k represents a numerical value to obtain k components in the characteristic extraction process, the characteristic extraction represents that a numerical value is converted into a k-dimensional vector, the serial number of the dimensionality in the k-dimensional vector is v, v belongs to [1, k ], and three functions for calculating characteristic extraction are Ftr1(), Ftr2(), and Ftr3 ();
ftr1() represents that one value of the input function is output as a k-dimensional vector, the value of the input function is recorded as x, and the value of the dimension with the sequence number v in the output k-dimensional vector is the v-1 power of the value of the input function, that is, xv-1The dimension denoted by v in Ftr1(x) is Ftr1(x) [ v [ [ v ]]The formula is as follows:
ftr2() represents that a value of an input function is output as a k-dimensional vector, the value of the input function is recorded as x, k-times of x is recorded as (x/k), and the value of a dimension with a sequence number v in the output k-dimensional vector is (x/k) to the power of-v x, namely (x/k)-v*xThe formula is as follows:
ftr3() represents that a value of an input function is output as a k-dimensional vector, the value of the input function is recorded as x, k-times of x are recorded as (x/k), and the value of a cosine of a dimension with a sequence number v in the output k-dimensional vector is (x/k) v, i.e., cos ((x/k) v), where cos () represents a cosine-solving function, and the formula is:
respectively inputting variables scd representing the numerical value of the cadmium hydrate into three functions of feature extraction to obtain Ftr1(scd), Ftr2(scd) and Ftr3 (scd);
respectively inputting variables scr representing the numerical values of the chromium hydrate into three functions of feature extraction to obtain Ftr1(scr), Ftr2(scr) and Ftr3 (scr);
inputting variables spb representing the numerical values of lead hydrate into three functions of feature extraction respectively to obtain Ftr1(spb), Ftr2(spb) and Ftr3 (spb);
respectively inputting variables sa representing the numerical values of water arsenic into three functions of feature extraction to obtain Ftr1 (sa), Ftr2 (sa) and Ftr3 (sa);
inputting variables shg representing the numerical value of mercury into three functions of feature extraction respectively to obtain Ftr1(shg), Ftr2(shg) and Ftr3 (shg);
inputting a variable tcd representing the value of the soil cadmium into three functions of feature extraction respectively to obtain Ftr1(tcd), Ftr2(tcd) and Ftr3 (tcd);
inputting variables tcr representing the numerical value of the soil chromium into three functions of feature extraction respectively to obtain Ftr1(tcr), Ftr2(tcr) and Ftr3 (tcr);
inputting variables tpb representing the values of the lead of the soil into three functions of feature extraction respectively to obtain Ftr1(tpb), Ftr2(tpb) and Ftr3 (tpb);
respectively inputting variables tas representing the numerical values of the arsenic in the soil into three functions of feature extraction to obtain Ftr1(tas), Ftr2(tas) and Ftr3 (tas);
inputting variables thg representing the soil mercury values into three functions of feature extraction respectively to obtain Ftr1(thg), Ftr2(thg) and Ftr3 (thg);
s305, a matrix of 10 columns and k rows, in which 10 k-dimensional vectors, that is, Ftr1(scd), Ftr1(scr), Ftr1(spb), Ftr1(sas), Ftr1(shg), Ftr1(tcd), Ftr1(tcr), Ftr1(tpb), Ftr1(tas), and Ftr1(thg), are sequentially formed by using each k-dimensional vector as one column of the matrix, is referred to as a first matrix, Mat1 is referred to as the first matrix, and Mat1 has the following formula:
Mat1=[ Ftr1(scd), Ftr1(scr), Ftr1(spb), Ftr1(sas), Ftr1(shg), Ftr1(tcd), Ftr1(tcr), Ftr1(tpb), Ftr1(tas), Ftr1(thg)];
a matrix of 10 columns and k rows, in which 10 k-dimensional vectors of Ftr2(scd), Ftr2(scr), Ftr2(spb), Ftr2(sas), Ftr2(shg), Ftr2(tcd), Ftr2(tcr), Ftr2(tpb), Ftr2(tas), and Ftr2(thg) are sequentially formed by taking each k-dimensional vector as one column of the matrix, is referred to as a second matrix, and the second matrix is Mat2, and the Mat2 has the following formula:
Mat2=[ Ftr2(scd), Ftr2(scr), Ftr2(spb), Ftr2(sas), Ftr2(shg), Ftr2(tcd), Ftr2(tcr), Ftr2(tpb), Ftr2(tas), Ftr2(thg)];
defining a third matrix as a matrix with 10 columns and k rows, wherein the third matrix is named as Mat3, elements in the third matrix are variables, the values of the elements in the third matrix can be subjected to gradient reduction, the third matrix can be initialized, namely initial values of the elements in the matrix are set and then subjected to gradient reduction, and 10 k-dimensional vectors, namely Ftr3(scd), Ftr3(scr), Ftr3(spb), Ftr3(sas), Ftr3(shg), Ftr3(tcd), Ftr3(tcr), Ftr3(tpb), Ftr3(tas) and Ftr3(thg), are sequentially used as initial values of the matrix with 10 columns and k rows which are formed by taking each k-dimensional vector as one column of the matrix;
s306, recording the numerical matrix as Mats; in a matrix with 10 columns and k rows, v belongs to [1, k ], a sequence of rows of the matrix is represented by v, and serial numbers of columns of the matrix are marked as s, and s belongs to [1,10 ]; in Mat1, the elements in the v-th row and s-th column of Mat1 are denoted as Mat1(v, s); in Mat2, the elements in the v-th row and s-th column of Mat2 are denoted as Mat2(v, s); in Mat3, the elements in the v-th row and s-th column of Mat3 are denoted as Mat3(v, s); in Mats, the elements in the v-th row and s-th column of Mats are denoted as Mats (v, s);
elements of the s-th column of Mats are:
the formula for calculating Mats (v, s) is Mats (v, s) = [ Mat1(v, s) × Mat2(v, s) × Mat3(v, s) ]/3;
the steps from S301 to S306 are methods for calculating to obtain a numerical matrix, so as to obtain a numerical matrix Mats, wherein, since the third matrix Mat3 can perform gradient reduction on the initial value, the values of the elements in Mats can also perform gradient reduction accordingly.
Further, in S400, the method for calculating the deviation between the environment data set and the threshold array by combining the numerical matrix and the threshold array includes:
marking a threshold value array as a array Tarr, and respectively representing the numerical values of the limit values of cadmium, chromium, lead, arsenic and mercury in the aquatic vegetables in the Tarr by variables cdl, crl, pbl, asl and hgl, namely the Tarr = [ cdl, crl, pbl, asl and hgl ], marking the number of elements in the Tarr as L and the serial number of the elements as t, (t belongs to [1, L ]), and the serial number of the elements in the Tarr as t element is Tarr (t);
acquiring the matrix size of the numerical matrix and recording as k multiplied by c, wherein k represents the row number of the numerical matrix, and c represents the column number of the numerical matrix;
defining a variable v, v belongs to [1, k ]; defining a variable s, s belongs to [1, c ];
using v to represent the serial number of a row in the numerical matrix, and using s to represent the serial number of a column in the numerical matrix;
recording the numerical matrix as matrix Mats, recording the elements of the v-th row and the s-th column in the numerical matrix as Mats (v, s), wherein the Mats (v, s) belongs to Mats;
defining a fourth vector as a k-dimensional vector, wherein elements in the vector are variables, the fourth vector is denoted as Vec4, and the values of the elements in the fourth vector can be subjected to gradient descent; since the fourth vector is a k-dimensional vector, v is also used to represent the sequence number of the dimension in the fourth vector, and the element with the sequence number v of the dimension in the fourth vector is Vec4(v), and Vec4(v) belongs to Vec 4;
the variable initial value of the element in the fourth vector is a random number with a value range of (0,1) generated by a random function, or the variable initial value of the element in the fourth vector is Vec4(v) = cos (pi × v/2k), cos () represents a cosine function, and pi is a circumference ratio;
and (3) recording the calculation result of the combined numerical value matrixes Mats and Vec4 as Maty, wherein the calculation formula of Maty is as follows:
the calculation formula of Maty is a calculation formula combining Mats and Vec4, wherein because s ∈ [1, c ], Maty is a vector of c dimension, the dimension with the sequence number s in Maty is marked as Maty(s), and Maty(s) is as follows:
keeping the function of calculating the deviation between the environment data set and the threshold value array as Disr (), wherein Disr (Maty, Tarr) represents the deviation between the environment data set and the threshold value array calculated by the function Disr (), and the calculation formula of Disr (Maty, Tarr) is as follows:
wherein, the calculation process of Ur (Maty(s), Tarr (t)) is as follows:
the dist (Maty, Tarr) is a deviation between the environment data set and the threshold value array, and the calculation formula of the dist (Maty, Tarr) is a formula for calculating the deviation between the environment data set and the threshold value array.
Further, in S500, the method for obtaining a value matrix after gradient descent by performing gradient descent on the value matrix by minimizing the deviation using a gradient descent algorithm includes:
the deviation between the environment data set and the threshold value array is subjected to gradient descent through an Adam algorithm by using a random gradient descent algorithm based on a first derivative, the Adam algorithm is used for carrying out gradient descent on an initial value of a third matrix Mat3 in the gradient descent process, correspondingly, the numerical values of elements in the numerical matrix are also subjected to gradient descent, after the numerical matrix is subjected to gradient descent, the numerical matrix subjected to gradient descent is obtained and recorded as Mats', and the size of the numerical matrix subjected to gradient descent is kept consistent with the size of the numerical matrix.
Further, in S600, the method for obtaining the upper limit value of the heavy metal concentration of the various vegetables according to the numerical matrix after the gradient is decreased includes: taking each row in the numerical matrix subjected to gradient reduction, adding elements in each row respectively to obtain the accumulated sum of each row respectively, recording the ordered array formed by the accumulated sums of each row as an upper limit array according to the sequence number of each row in the numerical matrix subjected to gradient reduction, wherein the number of the rows in the numerical matrix is 10, the number of the elements in the upper limit array is 10, the elements in the upper limit array are respectively cadmium, chromium, lead, arsenic, mercury, cadmium, chromium, lead, arsenic and mercury, the upper limit value of 10 numerical values of soil and irrigation water needing to be detected, namely the upper limit value of the heavy metal concentration, judging whether the upper limit value of the heavy metal concentration is exceeded or not, the pollution exceeding the upper limit value of the heavy metal concentration is the pollution of the heavy metal concentration, and marking and outputting the polluted aquatic vegetables in the production area, thus, when only the data of heavy metals of cadmium, chromium, lead, arsenic, mercury, cadmium, chromium, lead, arsenic, and mercury in the aquatic vegetable production area is obtained, but the data of specific heavy metals contained in the sample of the aquatic vegetable produced in the aquatic vegetable production area is not obtained, the upper limit of the heavy metal concentration and the data of heavy metals in the aquatic vegetable production area are used to determine, and the aquatic vegetable produced in the aquatic vegetable production area is marked as contaminated, and the aquatic vegetable produced in the aquatic vegetable production area is stopped from being consumed.
The invention also provides a system for evaluating the quality of aquatic vegetables based on the production place environment data, which comprises: the aquatic vegetable quality evaluation system based on the production place environment data can be operated in computing equipment such as a desktop computer, a notebook computer, a palm computer, a cloud data center and the like, and can be operated by including but not limited to the processor, the memory and a server cluster, and the processor executes the computer program to operate in the following units of the system:
the system comprises an environmental data acquisition unit, a data acquisition unit and a data acquisition unit, wherein the environmental data acquisition unit is used for acquiring the data of the heavy metal concentrations of soil and water of various vegetables in a plurality of different producing areas as an environmental data set through a sensor;
the threshold value array obtaining unit is used for obtaining threshold values of heavy metal concentrations of various vegetables from the database to serve as threshold value arrays;
the numerical matrix initialization unit is used for initializing a numerical matrix of the heavy metal concentration according to the environment data set;
the deviation calculation unit is used for calculating the deviation between the environment data set and the threshold value array by combining the numerical matrix and the threshold value array;
the numerical matrix optimization unit is used for minimizing deviation by using a gradient descent algorithm so as to optimize the numerical matrix to obtain an optimized numerical matrix;
and the upper limit value calculating unit is used for obtaining the upper limit values of the heavy metal concentrations of the various vegetables according to the optimized numerical matrix.
The invention has the beneficial effects that: the invention provides a method and a system for evaluating the quality of aquatic vegetables based on production area environment data, initializing a numerical matrix of heavy metal concentration according to the environment data set, calculating by combining the numerical matrix and the threshold value array to obtain the deviation of the environment data set and the threshold value array, minimizing the deviation by using a gradient descent algorithm so as to optimize the numerical matrix to obtain an optimized numerical matrix, obtaining the upper limit value of the heavy metal concentration of various vegetables according to the optimized numerical matrix, obtaining the soil of the producing area environment and the water body heavy metal threshold value of the large class of vegetables for planting the aquatic vegetables according to the data of the soil of the producing area environment and the water body heavy metal of various aquatic vegetables, under the condition of the threshold value, the heavy metal concentration of the aquatic vegetables does not exceed the upper limit value, and the beneficial effect that the upper limit value of the heavy metal concentration of various vegetables is obtained through automatic calculation according to the heavy metal concentration in the production area environment of various vegetables is realized.
Detailed Description
The conception, the specific structure and the technical effects of the present invention will be clearly and completely described in conjunction with the embodiments and the accompanying drawings to fully understand the objects, the schemes and the effects of the present invention. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
In the description of the present invention, the meaning of a plurality of means is one or more, the meaning of a plurality of means is two or more, and larger, smaller, larger, etc. are understood as excluding the number, and larger, smaller, inner, etc. are understood as including the number. If the first and second are described for the purpose of distinguishing technical features, they are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
Referring to fig. 1, which is a flowchart illustrating a method for evaluating quality of aquatic vegetables based on habitat environmental data according to the present invention, a method and a system for evaluating quality of aquatic vegetables based on habitat environmental data according to an embodiment of the present invention will be described with reference to fig. 1.
The invention provides a method for evaluating the quality of aquatic vegetables based on production area environment data, which specifically comprises the following steps:
s100, acquiring heavy metal concentration data of soil and water of various aquatic vegetables in a plurality of different producing places as an environment data set through a sensor;
s200, obtaining threshold values of heavy metal concentrations of various vegetables from a database as threshold value arrays;
s300, initializing a numerical matrix of heavy metal concentration according to the environment data set;
s400, calculating to obtain the deviation of the environment data set and the threshold value array by combining the numerical matrix and the threshold value array;
s500, minimizing deviation by using a gradient descent algorithm so as to perform gradient descent on the numerical matrix and obtain the numerical matrix after gradient descent;
s600, obtaining the upper limit values of the heavy metal concentrations of various vegetables according to the numerical matrix after gradient reduction;
in S100, the method for acquiring data of heavy metal concentrations in soil and water of a plurality of aquatic vegetables in a plurality of different production places by using a sensor as an environmental data set includes: for different vegetables, acquiring data of heavy metal concentration of soil of each vegetable in each production area and data of heavy metal concentration of irrigation water from a plurality of different production areas of each vegetable through a sensor and heavy metal detection equipment respectively, wherein the data of heavy metal concentration of soil comprises numerical values of cadmium, chromium, lead, arsenic, mercury and pH value in the soil and is recorded as soil cadmium, soil chromium, soil lead, soil arsenic, soil mercury and soil pH value, the data of heavy metal concentration of irrigation water comprises numerical values of cadmium, chromium, lead, arsenic, mercury and pH value in the irrigation water and is recorded as water cadmium, water chromium, water lead, water arsenic, water mercury and water pH value, the data of heavy metal concentration in the vegetables comprises numerical values of cadmium, chromium, lead, arsenic and mercury in the vegetables and is recorded as vegetable cadmium, vegetable chromium, vegetable lead, vegetable arsenic and vegetable mercury, the numerical values and the data are subjected to dimensionless treatment, the vegetables are aquatic vegetables, and data of cadmium, chromium, lead, arsenic, mercury, water cadmium, water chromium, water lead, water arsenic, water mercury, water pH value, soil cadmium, soil chromium, soil lead, soil arsenic, soil mercury and soil pH value of the vegetables obtained from different production places are stored in a form of a table to serve as an environment data set;
in S200, the method of obtaining the threshold values of the heavy metal concentrations of the various vegetables from the database as the threshold value array includes: the method comprises the steps of storing heavy metal limit value requirements of various aquatic vegetable varieties in a database, wherein the heavy metal limit value requirements comprise limit values of cadmium, chromium, lead, arsenic and mercury in each aquatic vegetable, respectively taking the limit values of the cadmium, the chromium, the lead, the arsenic and the mercury in each aquatic vegetable as threshold values of the content of corresponding heavy metals in the aquatic vegetable, and taking an array formed by the limit values of the cadmium, the chromium, the lead, the arsenic and the mercury in each aquatic vegetable as a threshold value array.
Further, in S300, the method for initializing the numerical matrix of the heavy metal concentration according to the environmental data set includes:
each row of the environment data set comprises data of vegetable cadmium, vegetable chromium, vegetable lead, vegetable arsenic, vegetable mercury, water cadmium, water chromium, water lead, water arsenic, water mercury, water pH value, soil cadmium, soil chromium, soil lead, soil arsenic, soil mercury and soil pH value collected by an aquatic vegetable in a producing area, wherein the vegetable cadmium, vegetable chromium, vegetable lead, vegetable arsenic and vegetable mercury are numerical values of the content and the pH value of cadmium, chromium, lead, arsenic and mercury contained in the vegetable, the water cadmium, water chromium, water lead, water arsenic, water mercury and water pH value are numerical values of the content and the pH value of cadmium, chromium, lead, arsenic and mercury contained in irrigation water of the vegetable producing area, and the soil cadmium, soil chromium, soil lead, soil arsenic, soil mercury and soil pH value are numerical values of the content and the pH value of cadmium, chromium, lead, arsenic and mercury contained in soil of the vegetable producing area;
the method comprises the following steps that (1) target heavy metal elements in vegetables to be detected are 5 numerical values of cadmium, chromium, lead, arsenic and mercury, data of cadmium, chromium, lead, arsenic and mercury in soil of a vegetable production place and irrigation water are detected, and 10 numerical values of cadmium, chromium, lead, arsenic, mercury, cadmium, chromium, lead, arsenic and mercury are obtained;
in the process of inputting the numerical values of the soil and irrigation water to be detected into a numerical value matrix after dimensionless treatment, the process of obtaining the numerical value matrix by defining and calculating is as follows:
s301, letting scd be a variable representing the water cadmium value, scr be a variable representing the water chromium value, spb be a variable representing the water lead value, sas be a variable representing the water arsenic value, and shg be a variable representing the water mercury value;
s302, a variable representing the soil cadmium value is tcd, a variable representing the soil chromium value is tcr, a variable representing the soil lead value is tpb, a variable representing the soil arsenic value is tas, and a variable representing the soil mercury value is thg;
s303, taking an array formed by 10 numerical values of scd, scr, spb, sas, shg, tcd, tcr, tpb, tas and thg in sequence as an array Ctrs;
s304, enabling a variable k to represent the number of characteristic components, wherein k is greater than 1, the characteristic components are components representing a numerical value in a characteristic extraction process, the variable k represents a numerical value to obtain k components in the characteristic extraction process, the characteristic extraction represents that a numerical value is converted into a k-dimensional vector, the serial number of the dimensionality in the k-dimensional vector is v, v belongs to [1, k ], and three functions for calculating characteristic extraction are Ftr1(), Ftr2(), and Ftr3 ();
ftr1() represents that one value of the input function is output as a k-dimensional vector, the value of the input function is recorded as x, and the value of the dimension with the sequence number v in the output k-dimensional vector is the v-1 power of the value of the input function, that is, xv-1The dimension denoted by v in Ftr1(x) is Ftr1(x) [ v [ [ v ]]The formula is as follows:
ftr2() represents that a value of an input function is output as a k-dimensional vector, the value of the input function is recorded as x, k-times of x is recorded as (x/k), and the value of a dimension with a sequence number v in the output k-dimensional vector is (x/k) to the power of-v x, namely (x/k)-v*xThe formula is as follows:
ftr3() represents that a value of an input function is output as a k-dimensional vector, the value of the input function is recorded as x, k-times of x are recorded as (x/k), and the value of a cosine of a dimension with a sequence number v in the output k-dimensional vector is (x/k) v, i.e., cos ((x/k) v), where cos () represents a cosine-solving function, and the formula is:
respectively inputting variables scd representing the numerical value of the cadmium hydrate into three functions of feature extraction to obtain Ftr1(scd), Ftr2(scd) and Ftr3 (scd);
respectively inputting variables scr representing the numerical values of the chromium hydrate into three functions of feature extraction to obtain Ftr1(scr), Ftr2(scr) and Ftr3 (scr);
inputting variables spb representing the numerical values of lead hydrate into three functions of feature extraction respectively to obtain Ftr1(spb), Ftr2(spb) and Ftr3 (spb);
respectively inputting variables sa representing the numerical values of water arsenic into three functions of feature extraction to obtain Ftr1 (sa), Ftr2 (sa) and Ftr3 (sa);
inputting variables shg representing the numerical value of mercury into three functions of feature extraction respectively to obtain Ftr1(shg), Ftr2(shg) and Ftr3 (shg);
inputting a variable tcd representing the value of the soil cadmium into three functions of feature extraction respectively to obtain Ftr1(tcd), Ftr2(tcd) and Ftr3 (tcd);
inputting variables tcr representing the numerical value of the soil chromium into three functions of feature extraction respectively to obtain Ftr1(tcr), Ftr2(tcr) and Ftr3 (tcr);
inputting variables tpb representing the values of the lead of the soil into three functions of feature extraction respectively to obtain Ftr1(tpb), Ftr2(tpb) and Ftr3 (tpb);
respectively inputting variables tas representing the numerical values of the arsenic in the soil into three functions of feature extraction to obtain Ftr1(tas), Ftr2(tas) and Ftr3 (tas);
inputting variables thg representing the soil mercury values into three functions of feature extraction respectively to obtain Ftr1(thg), Ftr2(thg) and Ftr3 (thg);
s305, a matrix of 10 columns and k rows, in which 10 k-dimensional vectors, that is, Ftr1(scd), Ftr1(scr), Ftr1(spb), Ftr1(sas), Ftr1(shg), Ftr1(tcd), Ftr1(tcr), Ftr1(tpb), Ftr1(tas), and Ftr1(thg), are sequentially formed by using each k-dimensional vector as one column of the matrix, is referred to as a first matrix, Mat1 is referred to as the first matrix, and Mat1 has the following formula:
Mat1=[ Ftr1(scd), Ftr1(scr), Ftr1(spb), Ftr1(sas), Ftr1(shg), Ftr1(tcd), Ftr1(tcr), Ftr1(tpb), Ftr1(tas), Ftr1(thg)];
a matrix of 10 columns and k rows, in which 10 k-dimensional vectors of Ftr2(scd), Ftr2(scr), Ftr2(spb), Ftr2(sas), Ftr2(shg), Ftr2(tcd), Ftr2(tcr), Ftr2(tpb), Ftr2(tas), and Ftr2(thg) are sequentially formed by taking each k-dimensional vector as one column of the matrix, is referred to as a second matrix, and the second matrix is Mat2, and the Mat2 has the following formula:
Mat2=[ Ftr2(scd), Ftr2(scr), Ftr2(spb), Ftr2(sas), Ftr2(shg), Ftr2(tcd), Ftr2(tcr), Ftr2(tpb), Ftr2(tas), Ftr2(thg)];
defining a third matrix as a matrix with 10 columns and k rows, wherein the third matrix is named as Mat3, elements in the third matrix are variables, the values of the elements in the third matrix can be subjected to gradient reduction, the third matrix can be initialized, namely initial values of the elements in the matrix are set and then subjected to gradient reduction, and 10 k-dimensional vectors, namely Ftr3(scd), Ftr3(scr), Ftr3(spb), Ftr3(sas), Ftr3(shg), Ftr3(tcd), Ftr3(tcr), Ftr3(tpb), Ftr3(tas) and Ftr3(thg), are sequentially used as initial values of the matrix with 10 columns and k rows which are formed by taking each k-dimensional vector as one column of the matrix;
s306, recording the numerical matrix as Mats; in a matrix with 10 columns and k rows, v belongs to [1, k ], a sequence of rows of the matrix is represented by v, and serial numbers of columns of the matrix are marked as s, and s belongs to [1,10 ]; in Mat1, the elements in the v-th row and s-th column of Mat1 are denoted as Mat1(v, s); in Mat2, the elements in the v-th row and s-th column of Mat2 are denoted as Mat2(v, s); in Mat3, the elements in the v-th row and s-th column of Mat3 are denoted as Mat3(v, s); in Mats, the elements in the v-th row and s-th column of Mats are denoted as Mats (v, s);
elements of the s-th column of Mats are:
the formula for calculating Mats (v, s) is Mats (v, s) = [ Mat1(v, s) × Mat2(v, s) × Mat3(v, s) ]/3;
the steps from S301 to S306 are methods for calculating to obtain a numerical matrix, so as to obtain a numerical matrix Mats, wherein, since the third matrix Mat3 can perform gradient reduction on the initial value, the values of the elements in Mats can also perform gradient reduction accordingly.
Further, in S400, the method for calculating the deviation between the environment data set and the threshold array by combining the numerical matrix and the threshold array includes:
marking the threshold value array as a array Tarr, and respectively representing the numerical values of the limit values of cadmium, chromium, lead, arsenic and mercury in the aquatic vegetables in the Tarr by variables cdl, crl, pbl, asl and hgl, namely Tarr = [ cdl, crl, pbl, asl and hgl ], marking the number of elements in the Tarr as L, the serial number of the elements as t, and the serial number of the elements in the Tarr as t, and the element in the Tarr as Tarr (t);
acquiring the matrix size of the numerical matrix and recording as k multiplied by c, wherein k represents the row number of the numerical matrix, and c represents the column number of the numerical matrix;
defining a variable v, v belongs to [1, k ]; defining a variable s, s belongs to [1, c ];
using v to represent the serial number of a row in the numerical matrix, and using s to represent the serial number of a column in the numerical matrix;
recording the numerical matrix as matrix Mats, recording the elements of the v-th row and the s-th column in the numerical matrix as Mats (v, s), wherein the Mats (v, s) belongs to Mats;
defining a fourth vector as a k-dimensional vector, wherein elements in the vector are variables, the fourth vector is denoted as Vec4, and the values of the elements in the fourth vector can be subjected to gradient descent; since the fourth vector is a k-dimensional vector, v is also used to represent the sequence number of the dimension in the fourth vector, and the element with the sequence number v of the dimension in the fourth vector is Vec4(v), and Vec4(v) belongs to Vec 4;
the variable initial value of the element in the fourth vector is a random number with a value range of (0,1) generated by a random function, or the variable initial value of the element in the fourth vector is Vec4(v) = cos (pi × v/2k), cos () represents a cosine function, and pi is a circumference ratio;
and (3) recording the calculation result of the combined numerical value matrixes Mats and Vec4 as Maty, wherein the calculation formula of Maty is as follows:
the calculation formula of Maty is a calculation formula combining Mats and Vec4, wherein because s ∈ [1, c ], Maty is a vector of c dimension, the dimension with the sequence number s in Maty is marked as Maty(s), and Maty(s) is as follows:
keeping the function of calculating the deviation between the environment data set and the threshold value array as Disr (), wherein Disr (Maty, Tarr) represents the deviation between the environment data set and the threshold value array calculated by the function Disr (), and the calculation formula of Disr (Maty, Tarr) is as follows:
wherein, the calculation process of Ur (Maty(s), Tarr (t)) is as follows:
the dist (Maty, Tarr) is a deviation between the environment data set and the threshold value array, and the calculation formula of the dist (Maty, Tarr) is a formula for calculating the deviation between the environment data set and the threshold value array.
Further, in S500, the method for obtaining a value matrix after gradient descent by performing gradient descent on the value matrix by minimizing the deviation using a gradient descent algorithm includes:
the deviation of the environment data set from the threshold value array is subjected to gradient descent (the code can refer to the code of a drill. optimal. Adam module in an open Python machine learning library Pythch) by an Adam algorithm (see a paper: Kingma D, Ba J. Adam: A Method for Stochastic Optimization [ J ]. Computer Science, 2014.) through a random gradient descent algorithm based on a first derivative, the Adam algorithm is subjected to gradient descent by carrying out a gradient descent on an initial value of a third matrix Mat3 in the gradient descent process, correspondingly, the numerical values of elements in the numerical matrix are also subjected to gradient descent, and the numerical matrix subjected to gradient descent is recorded as Mats after the numerical matrix is subjected to gradient descent, wherein the size of the numerical matrix subjected to gradient descent is consistent with the size of the numerical matrix.
Further, in S600, the method for obtaining the upper limit value of the heavy metal concentration of the various vegetables according to the numerical matrix after the gradient is decreased includes: taking each row in the numerical matrix subjected to gradient reduction, adding elements in each row respectively to obtain the accumulated sum of each row respectively, recording the ordered array formed by the accumulated sums of each row as an upper limit array according to the sequence number of each row in the numerical matrix subjected to gradient reduction, wherein the number of the rows in the numerical matrix is 10, the number of the elements in the upper limit array is 10, the elements in the upper limit array are respectively cadmium, chromium, lead, arsenic, mercury, cadmium, chromium, lead, arsenic and mercury, the upper limit value of 10 numerical values of soil and irrigation water needing to be detected, namely the upper limit value of the heavy metal concentration, judging whether the upper limit value of the heavy metal concentration is exceeded or not, the pollution exceeding the upper limit value of the heavy metal concentration is the pollution of the heavy metal concentration, and marking and outputting the polluted aquatic vegetables in the production area, thus, when only the data of heavy metals of cadmium, chromium, lead, arsenic, mercury, cadmium, chromium, lead, arsenic, and mercury in the aquatic vegetable production area is obtained, but the data of specific heavy metals contained in the sample of the aquatic vegetable produced in the aquatic vegetable production area is not obtained, the upper limit of the heavy metal concentration and the data of heavy metals in the aquatic vegetable production area are used to determine, and the aquatic vegetable produced in the aquatic vegetable production area is marked as contaminated, and the aquatic vegetable produced in the aquatic vegetable production area is stopped from being consumed.
The aquatic vegetable quality evaluation system based on the production place environment data comprises: the aquatic vegetable quality evaluation system based on the production place environment data can be operated in computing equipment such as a desktop computer, a notebook computer, a palm computer, a cloud data center and the like, and the operable systems can include, but are not limited to, a processor, a memory and a server cluster.
An embodiment of the present invention provides a system for evaluating quality of aquatic vegetables based on habitat environmental data, as shown in fig. 2, the system for evaluating quality of aquatic vegetables based on habitat environmental data of the embodiment includes: a processor, a memory and a computer program stored in the memory and operable on the processor, the processor executing the computer program to implement the steps in an embodiment of the method for evaluating the quality of aquatic vegetables based on the habitat environmental data as described above, the processor executing the computer program to run in the units of the following system:
the system comprises an environmental data acquisition unit, a data acquisition unit and a data acquisition unit, wherein the environmental data acquisition unit is used for acquiring the data of the heavy metal concentrations of soil and water of various vegetables in a plurality of different producing areas as an environmental data set through a sensor;
the threshold value array obtaining unit is used for obtaining threshold values of heavy metal concentrations of various vegetables from the database to serve as threshold value arrays;
the numerical matrix initialization unit is used for initializing a numerical matrix of the heavy metal concentration according to the environment data set;
the deviation calculation unit is used for calculating the deviation between the environment data set and the threshold value array by combining the numerical matrix and the threshold value array;
the numerical matrix optimization unit is used for minimizing deviation by using a gradient descent algorithm so as to optimize the numerical matrix to obtain an optimized numerical matrix;
and the upper limit value calculating unit is used for obtaining the upper limit values of the heavy metal concentrations of the various vegetables according to the optimized numerical matrix.
The aquatic vegetable quality evaluation system based on the production place environment data can be operated in computing equipment such as a desktop computer, a notebook computer, a palm computer and a cloud data center. The aquatic vegetable quality evaluation system based on the production place environment data comprises a processor and a memory, but is not limited to the processor and the memory. It will be understood by those skilled in the art that the example is merely an example of the method and system for evaluating quality of aquatic vegetables based on the production area environment data, and does not constitute a limitation of the method and system for evaluating quality of aquatic vegetables based on the production area environment data, and may include more or less components than the production area environment data, or combine some components, or different components, for example, the system for evaluating quality of aquatic vegetables based on the production area environment data may further include an input/output device, a network access device, a bus, etc.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete component Gate or transistor logic, discrete hardware components, etc. The general processor may be a microprocessor or the processor may be any conventional processor or the like, the processor is a control center of the aquatic vegetable quality evaluation system based on the production place environment data, and various interfaces and lines are used for connecting various subareas of the whole aquatic vegetable quality evaluation system based on the production place environment data.
The memory can be used for storing the computer program and/or the module, and the processor realizes various functions of the aquatic vegetable quality evaluation method and system based on the production place environment data by operating or executing the computer program and/or the module stored in the memory and calling the data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
The invention provides a method and a system for evaluating the quality of aquatic vegetables based on production place environment data.
Although the present invention has been described in considerable detail and with reference to certain illustrated embodiments, it is not intended to be limited to any such details or embodiments or any particular embodiment, so as to effectively encompass the intended scope of the invention. Furthermore, the foregoing describes the invention in terms of embodiments foreseen by the inventor for which an enabling description was available, notwithstanding that insubstantial modifications of the invention, not presently foreseen, may nonetheless represent equivalent modifications thereto.