A heavy metal element content detection method based on elastic network regression
By using a method based on elastic network regression in soil heavy metal detection for feature selection and model training, the problem of matrix effect interference in X-ray fluorescence spectrum analysis was solved, the detection accuracy and efficiency were improved, and multi-component simultaneous detection was achieved. .
Patent Information
- Application Number
- CN202111361837.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-17
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-11-17
AI Technical Summary
X-ray fluorescence spectrometry analysis in soil heavy metal detection has matrix effect interference, which leads to inaccurate detection results. It is difficult to improve the accuracy and precision of the instrument with existing technology.
A heavy metal element content detection method based on elastic network regression is adopted. Feature selection is performed within the energy range of the characteristic peaks of heavy metal elements, and the elastic network regression model is used for training and verification to prevent overfitting and improve modeling efficiency and accuracy.
It improves the accuracy and efficiency of the detection model, can effectively prevent over-fitting, realize simultaneous detection of multiple components, shorten the spectrum acquisition time, and basically ignore the calculation time after the model is successfully established, making the modeling easy to implement.
Smart Images

Figure CN114088757B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of X-ray fluorescence spectrum analysis application, and relates to a heavy metal element content detection method based on elastic network regression. Background Art
[0002] Heavy metal pollution in soil has the characteristics of long-term accumulation, ecotoxicity, and bioaccumulation, which poses a continuous threat to the regional ecological environment, food safety, and human health. Therefore, the detection of heavy metals in soil has attracted the attention of agricultural workers and scientific researchers. With the development of soil detailed investigation, the rapid detection of heavy metals in soil has become a key research direction.
[0003] Among them, X-ray fluorescence spectroscopy (XRF) has been widely used in the field of soil heavy metal detection due to its advantages such as simple sample pretreatment, easy operation, fast detection speed, high sensitivity, low cost, and on-site detection. The complexity of soil composition leads to matrix effect interference during XRF scanning analysis, thus affecting the detection results. How to improve the accuracy and precision of instrument detection is a key and difficult problem that troubles instrument developers. Summary of the invention
[0004] In view of the problems existing in the prior art, the purpose of the present invention is to provide a heavy metal element content detection method based on elastic network regression, which at least partially solves the above technical problems.
[0005] The embodiment of the present invention provides a method for detecting heavy metal element content based on elastic network regression, comprising:
[0006] S1: Collect XRF spectrum information of the soil sample to be tested;
[0007] S2: preprocessing the XRF spectrum information of the soil sample to be tested;
[0008] S3: inputting the preprocessed spectral information into a preset heavy metal element content detection model based on elastic network regression, and outputting the heavy metal element content information of the soil sample to be detected.
[0009] Furthermore, the modeling process of the heavy metal element content detection model based on elastic network regression includes:
[0010] Collect XRF spectrum information of different soil samples and the corresponding heavy metal element information;
[0011] Preprocessing the XRF spectrum information of the different soil samples;
[0012] The preprocessed spectral information is divided into a training set and a validation set according to a preset ratio; the training set and the corresponding heavy metal element information are input into an elastic network regression model for training;
[0013] The validation set is used to input the trained elastic network regression model for model evaluation.
[0014] Furthermore, XRF spectrum information of different soil samples is collected, including: collecting soil samples at different preset depths on the surface, performing multiple spectrum measurements and obtaining an average value.
[0015] Furthermore, the heavy metal element information is obtained by detecting the different soil samples using an ICP-MS method.
[0016] Furthermore, the preprocessing is to use the SNV standard normal transformation method to smooth and reduce noise on the spectral information.
[0017] Furthermore, the division into a training set and a validation set according to a preset ratio includes:
[0018] The Holdout test method is used to divide the XRF spectrum information of the different soil samples into a training set and a validation set according to a preset ratio.
[0019] Furthermore, the step of inputting the training set and the corresponding heavy metal element information into an elastic network regression model for training includes:
[0020] The training set and the corresponding heavy metal element information are input into the elastic network regression model for testing using a ten-fold cross validation method;
[0021] Calculating the loss function of the heavy metal element content detection model after training and testing;
[0022] The elastic network regression model is optimized according to the loss function to obtain a trained model.
[0023] Further, the validation set is used to input the trained heavy metal element content detection model for model evaluation, including:
[0024] Inputting the validation set into the trained elastic network regression model to obtain a detection result;
[0025] Model evaluation is performed according to the detection result and the heavy metal element information corresponding to the verification set; the specific calculation process includes:
[0026]
[0027]
[0028]
[0029] In the formula, R 2 represents the coefficient of determination; RMSE represents the root mean square error; RPD represents the relative analytical error; n represents the total number of samples in the validation set; i represents the number of samples in the validation set; y represents the number of samples in the validation set; i Indicates the heavy metal element information corresponding to the i-th sample in the validation set; represents the model prediction value of the i-th sample in the validation set; represents the mean of all model prediction values of the validation set; SD() represents the standard deviation of the validation set.
[0030] The present invention discloses an X-ray fluorescence spectrum modeling method based on elastic network regression. The prior art usually processes within the full spectrum range during feature selection. Due to the complexity of spectral components and interference, the selected characteristic band may not be able to achieve data fitting well. Compared with the prior art, the present method improves modeling efficiency and model accuracy by performing feature selection within the energy range of the characteristic peak of heavy metal elements during feature selection. Compared with the traditional partial least squares regression method, the elastic network regression adds constraints on minimizing the empirical error function during calculation, which can prevent the occurrence of overfitting.
[0031] The spectral acquisition time is short, and after the model is successfully established, the model calculation time can be basically ignored, and the modeling is easy to implement.
[0032] The established detection models for multiple heavy metal elements can simultaneously calculate the content of the corresponding heavy metal elements and realize simultaneous detection of multiple components.
[0033] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A flow chart of a heavy metal element content detection method based on elastic network regression provided in an embodiment of the present invention;
[0035] Figure 2 A diagram for selecting optimal adjustment parameters when elastic network regression modeling is provided in an embodiment of the present invention;
[0036] Figure 3 A schematic diagram of the prediction results of the elastic network regression model for the training set of Cu provided by an embodiment of the present invention;
[0037] Figure 4A schematic diagram of the prediction results of the validation set of Cu by the elastic network regression model provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0038] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] In the description of the present invention, it should be noted that the terms "upper", "lower", "inside", "outside", "top / bottom" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0040] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "provided with", "internal connection", "connection", etc. should be understood in a broad sense. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0041] An embodiment of the present invention provides a method for detecting heavy metal content based on elastic network regression, comprising:
[0042] S1: Collect XRF spectrum information of the soil sample to be tested;
[0043] S2: preprocessing the XRF spectrum information of the soil sample to be tested;
[0044] S3: Input the preprocessed spectral information into a preset heavy metal element content detection model based on elastic network regression, and output the heavy metal element content information of the soil sample to be detected.
[0045] Compared with the prior art, the present invention improves modeling efficiency and model accuracy by performing feature selection within the energy range of characteristic peaks of heavy metal elements; compared with the traditional partial least squares regression method, the present invention adds constraints on minimizing the empirical error function, which can prevent the occurrence of overfitting, wherein elastic network regression is a regularization process, and the definition of regularization is to add constraints on minimizing the empirical error function; the spectral acquisition time is short, and after the model is successfully established, the model calculation time can be basically ignored, and modeling is easy to implement; the established multiple heavy metal element detection models can simultaneously calculate the content of the corresponding heavy metal elements, thereby realizing simultaneous detection of multiple components.
[0046] The following will be explained in detail in conjunction with the measurement of heavy metals in farmland.
[0047] 41 farmland soil samples were collected, and about 100 g of samples from the farmland surface layer at a depth of 0-20 cm were taken. The soil was collected and mixed using the quartering method. The samples were air-dried, and after removing foreign matter, they were ground and passed through a 100-mesh nylon sieve for later use.
[0048] The NX-100S (Nano-Ken Co., Ltd.) XRF spectrometer was used to collect the sample spectral information. For cadmium (Cd), the single scan time was 600 s and the light tube voltage was set to 65 kV. For arsenic (As), lead (Pb), chromium (Cr), copper (Cu), nickel (Ni) and zinc (Zn), the single scan time was 120 s and the light tube voltage was 40 kV. Each sample was scanned 3 times and the average spectrum was taken for subsequent analysis.
[0049] The chemical detection values of heavy metal elements Cd, As, Pb, Cr, Cu, Ni and Zn in the soil were determined by ICP-MS method.
[0050] There are 41 soil samples for modeling. The SNV standard normal transformation method, SG method, wavelet transform and other methods can be used for spectral preprocessing, smoothing and noise reduction. The best method is to use the SNV standard normal transformation method for preprocessing. The next step is to divide the data set after preprocessing, including the Holdout method, concentration gradient method, SPXY method and other methods. The best method is to use the Holdout method for division after preprocessing with the SNV standard normal transformation method. The following will take the best method as an example for detailed explanation.
[0051] The standard normal variable (SNV) method was used to preprocess the spectra, and the elastic network regression method was used to establish the correction model between the XRF spectra and the chemical detection values, such as Figure 1 The Holdout test method was used to divide the training set and the prediction set, where 80% of the samples (33) were used as training set data and 20% of the samples (8) were used as prediction set data. The training set samples were used to establish the quantitative model, and the prediction set samples were used to verify the accuracy of the model.
[0052] When using elastic net regression modeling, the ten-fold cross-validation method is selected to test the algorithm accuracy, the model is calibrated, the mean square error of the model is calculated, and the value of the model adjustment parameter Lambda (a fixed parameter of elastic net regression modeling) is determined accordingly. As Figure 2 shown, the Lambda value corresponding to the minimum cross-validation error and the value obtained by adding one standard deviation to the minimum cross-validation error are marked in the figure respectively. The value of Lambda can be selected from either of the two. Preferably, the value corresponding to the minimum cross-validation error is selected. It can be seen from Figure 2 that the function is flat near the optimal value of Lambda, indicating that changes near the optimal value have little impact on the prediction ability of the model.
[0053] After determining the Lambda value, the corresponding sparse coefficient is calculated. During the calculation process, sparsity with low correlation will be compressed to 0, thereby performing sparse variable screening to achieve the purpose of optimizing feature selection. Finally, an XRF-based heavy metal element content detection model based on elastic net regression is established.
[0054] The accuracy of the calibrated model is verified using the prediction set data.
[0055] Taking the coefficient of determination (R 2 2), root mean square error (RMSE), and relative analysis error (RPD) as the model evaluation indicators.
[0056]
[0057]
[0058]
[0059] Among them, y i is the chemical test value of the i-th sample, is the model prediction value of the i-th sample, is the mean of all model prediction values in the test set, and SD is the standard deviation of the test set. The higher the coefficient of determination R2 and the smaller the root mean square error RMSE, the better the modeling effect of the model. Conversely, the worse the modeling effect of the model. When RPD > 3, the established model has good prediction effect and has practical application value; when 2.25 < RPD < 3, the established model has relatively good prediction effect and has certain application value; when 1.75 < RPD < 2.25, the model is considered available; when RPD < 1.75, the established model has poor prediction effect and the model is not available.
[0060] The modeling results are shown in Table 1, where RMSE C , RMSE PRespectively represent the root mean square error of the training set and the prediction set (i.e., the validation set), R 2 C , R 2 P Represent the determination coefficient of the training set and the prediction set, RPD C 、RPD P Represent the relative analysis errors of the training set and the prediction set, respectively. From Table 1, it can be seen that the coefficients of determination of Cd, As, Pb, Cr, Cu, Ni, and Zn in the soil in the training set and the prediction set are all higher than 0.92, and the RPDs are all higher than 1.8. The root mean square error of the training set is numerically close to the root mean square error of the prediction set, indicating that the model effect is good, and the distribution of the prediction set samples in the entire modeling concentration range can better measure the accuracy of the model's prediction results. The above modeling results show that XRF modeling based on elastic network regression can accurately detect the content of Cd, As, Pb, Cr, Cu, Ni, and Zn elements in soil.
[0061] Take the Cu modeling effect as an example. Figure 3 and Figure 4 The spectral prediction value determination coefficient is shown on the vertical axis, and the chemical detection value is on the horizontal axis, representing the Cu in the training set R 2 C and the prediction set R 2 p From the prediction results above, we can see that the model prediction results are numerically close to the chemical detection results, indicating that the model prediction results are accurate.
[0062] Table 1 Spectral modeling prediction results of soil heavy metal elements
[0063] <![CDATA[RMSE C ]]> <![CDATA[R 2 C ]]> <![CDATA[RPD C ]]> <![CDATA[RMSE P ]]> <![CDATA[R 2 P ]]> <![CDATA[RPD P ]]> Cu 10.6405 0.9959 15.7629 9.1878 0.9317 2.1952 Cr 9.4604 0.9831 7.4161 5.9895 0.966 5.3793 As 10.7901 0.9895 8.1496 6.5186 0.9223 1.8483 Cd 0.5283 0.9941 10.1708 0.4737 0.9707 3.3398 Ni 17.0876 0.9656 4.1219 4.7628 0.9271 2.6863 Pb 14.6780 0.9926 11.0943 22.6654 0.9866 1.8250 Zn 47.4702 0.9674 3.7867 14.1088 0.9376 2.5583
[0064] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and improved concepts of the present invention within the technical scope disclosed by the present invention, and they should be covered by the protection scope of the present invention.
Claims
1. A heavy metal element content detection method based on elastic network regression, characterized in that: include: S1: Collect XRF spectrum information of the soil sample to be tested; S2: preprocessing the XRF spectrum information of the soil sample to be tested; S3: inputting the preprocessed spectral information into a preset heavy metal element content detection model based on elastic network regression, and outputting the heavy metal element content information of the soil sample to be detected; The heavy metal element content detection model based on elastic network regression is trained by adding constraints on minimizing the empirical error function. When using elastic network regression modeling, a ten-fold cross-validation method is selected to test the accuracy of the algorithm, the model is calibrated, and the mean square error of the model is calculated. The value of the model adjustment parameter Lambda is determined based on this. The value of Lambda is selected from Lambda with the minimum cross-validation error and the value of the minimum cross-validation error plus a standard deviation. After determining the Lambda value, the sparse coefficient corresponding to Lambda is calculated. During the calculation process, the sparse coefficients with low correlation will be compressed to 0, so as to screen sparse variables and achieve feature selection optimization.
2. The heavy metal element content detection method based on elastic network regression according to claim 1 is characterized in that: The modeling process of the heavy metal element content detection model based on elastic network regression includes: Collect XRF spectrum information of different soil samples and the corresponding heavy metal element information; Preprocessing the XRF spectrum information of the different soil samples; The preprocessed spectral information is divided into a training set and a validation set according to a preset ratio; the training set and the corresponding heavy metal element information are input into an elastic network regression model for training; The validation set is used to input the trained elastic network regression model for model evaluation.
3. The method for detecting heavy metal content based on elastic network regression according to claim 2, characterized in that: Collecting XRF spectrum information of different soil samples includes: collecting soil samples at different preset depths on the surface, performing multiple spectrum measurements and taking an average value.
4. The method for detecting heavy metal content based on elastic network regression according to claim 2, characterized in that: The heavy metal element information is obtained by detecting the different soil samples using the ICP-MS method.
5. The method for detecting heavy metal content based on elastic network regression according to claim 2, characterized in that: The preprocessing is to use the SNV standard normal transformation method to smooth and reduce noise on the spectral information.
6. The method for detecting heavy metal content based on elastic network regression according to claim 2, characterized in that: The division into a training set and a validation set according to a preset ratio includes: The Holdout test method is used to divide the XRF spectrum information of the different soil samples into a training set and a validation set according to a preset ratio.
7. The method for detecting heavy metal content based on elastic network regression according to claim 2, characterized in that: The inputting the training set and the corresponding heavy metal element information into the elastic network regression model for training comprises: The training set and the corresponding heavy metal element information are input into the elastic network regression model for testing using a ten-fold cross validation method; Calculating the loss function of the heavy metal element content detection model after training and testing; The elastic network regression model is optimized according to the loss function to obtain a trained model.
8. The method for detecting heavy metal content based on elastic network regression according to claim 2, characterized in that: The heavy metal element content detection model trained by inputting the validation set is used to perform model evaluation, including: Inputting the validation set into the trained elastic network regression model to obtain a detection result; Model evaluation is performed according to the detection result and the heavy metal element information corresponding to the verification set; the specific calculation process includes: In the formula, R 2 represents the coefficient of determination; RMSE represents the root mean square error; RPD represents the relative analytical error; n represents the total number of samples in the validation set; i represents the number of samples in the validation set; y i represents the heavy metal element information corresponding to the i-th sample in the validation set; represents the model prediction value of the i-th sample in the validation set; represents the mean of all model prediction values of the validation set; represents the standard deviation of the validation set.
Citation Information
Patent Citations
Mid-infrared spectrum-based method for quickly detecting contents of heavy metal elements in soil
CN101738383A
Rock character judging method and system based on laser-induced breakdown spectroscopy
CN105938099A
Method for detecting soil heavy metal pollution by adopting unmanned aerial vehicle and XRF technology
CN113155880A
Lung X-ray image segmentation method based on UNet
CN113223021A
Laser-induced breakdown spectroscopy weak supervision feature extraction method
CN113295673A
