A Quantitative Analysis Method for Element Content Combining Support Vector Regression and Gravitational Search
Through the method of supporting vector regression combined with gravitational search, the GSA-SVR model was constructed and parameters C and g were optimized, which solved the problem of large errors in soil element content analysis in the XRF spectrum, and achieved higher prediction accuracy and accuracy.
Patent Information
- Application Number
- CN202211396783.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-04
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-11-04
AI Technical Summary
The existing soil element content analysis methods have problems such as large analysis errors and inaccurate results. Especially when the XRF spectrum is disturbed by nonlinear factors, the accuracy of conventional linear analysis methods is not ideal.
Using the method of supporting vector regression combined with gravitational search, the GSA-SVR model is constructed, spectral data is used for training and prediction, the parameter C and kernel function g of the support vector machine are optimized, and the nonlinear data in the XRF spectrum is processed to reduce the influence of redundant features.
The prediction accuracy of soil element content analysis is improved, error is reduced, and quantitative analysis accuracy is achieved.
Smart Images

Figure CN115879039B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of elemental quantitative analysis of X-ray fluorescence spectrometers, and particularly relates to a method for quantitative analysis of elemental content combining support vector regression and gravitational search. Background Art
[0002] Currently, in the elemental quantitative analysis based on XRF, for the calculation of the content of soil elements, the conventional analysis method is to establish a calibration model by measuring the intensity of the characteristic peaks corresponding to the elements in the spectrum, and perform fitting analysis such as elemental content, for example: Partial Least Squares Regression (PLSR), etc. In the actual prediction of XRF elemental content, due to the interference of many non-linear factors on the spectral data in the XRF spectrum, such as the interference of spectral lines with similar wavelengths emitted by the X-ray tube, the sample, and the optical path, it may also come from the target itself, including the emission lines of the target element and related impurities (such as copper in the tungsten target), as well as the interference lines emitted by other elements in the sample. In this case, there are certain drawbacks in using the conventional linear analysis method, and the accuracy is not ideal. In this situation, some non-linear algorithms, such as: Convolutional Neural Network (CNN), Support Vector Machine Regression (SVR), Radial Basis Function (RBF) Neural Network, Back Propagation (BP) Neural Network, etc. have been widely used in the field of XRF elemental quantitative analysis due to their strong adaptive ability and ability to handle multi-source non-linear data. Among them, the Support Vector Machine Regression (SVR) algorithm has excellent generalization ability and prediction ability compared with other algorithms, and can also provide an accurate prediction model for small sample sets.
[0003] The Support Vector Machine (SVM) itself was proposed for binary classification problems, and SVR (Support Vector Regression) is an important application branch of SVM (Support Vector Machine). The difference between SVR regression and SVM classification is that the sample points of SVR ultimately only have one category, and the optimal hyperplane it seeks is not to separate two or more categories of sample points as "widely" as SVM, but to minimize the total deviation of all sample points from the hyperplane. The reference vector regression is a supervised learning algorithm for predicting discrete values, and the basic idea of SVR is to find the best fitting line. In SVR, the best fitting straight line is the hyperplane with the highest estimated value. The advantages of support vector regression include robustness to outliers, easy update of the decision model, good generalization ability, high prediction accuracy, and easy implementation.
[0004] Through the above analysis, the problems and defects existing in the prior art are: the existing analysis methods for the content of soil elements have large analysis errors, and the analysis results are inaccurate and unreliable. Summary of the Invention
[0005] Aiming at the problems existing in the prior art, the present invention provides a method for quantitative analysis of element content combining support vector regression and gravitational search. The advantages of support vector regression include robustness to outliers, easy update of the decision model, good generalization ability, high prediction accuracy, and easy implementation. The gravitational search algorithm is used to optimize the C and g of support vector regression to solve the problem of the influence of redundant features on the model accuracy in the existing SVR modeling process.
[0006] The present invention is implemented as follows. A method for quantitative analysis of element content combining support vector regression and gravitational search, the method for quantitative analysis of element content combining support vector regression and gravitational search includes:
[0007] Step 1: Select the element a to be measured and collect n selected samples;
[0008] Step 2: Determine the element to be measured, obtain the XRF spectral data of the sample to be measured by a spectrometer, and normalize the data; determine the peak information of the element to be measured based on the spectral data;
[0009] Step 3: Based on the XRF spectral data obtained in Step 2, select the peak information and content information of the element a to be measured and the peak information and content information of m interfering elements of the element a to be measured to obtain a target sample set of the XRF spectrum with p features;
[0010] Step 4: Construct a GSA-SVR model and use the data set to train the constructed GSA-SVR model, and use the trained GSA-SVR model to predict the content of the element to be measured based on the peak information of the element to be measured;
[0011] Based on the data in Step 3, divide the training sample set and the test sample set; the first k target sample data are the training sample set, where the peak data of the element a to be measured is used as the input data of the SVM model, and the content of the element a to be measured is the output data of the model; the subsequent n - k target sample data are the test sample set, where the peak data of the element a to be measured is used as the input data of the SVM model, and the content of the element a to be measured is the output data of the model;
[0012] Step 5: Train and construct a GSA-SVR model based on the k training sample sets in Step 5;
[0013] Step 6: Substitute the input data in the n - k test sample sets in Step 5 into the GSA-SVR model trained in Step 5 for prediction to obtain the content prediction results of the element a to be measured in the n - k test sample sets;
[0014] Step 7: Denormalize the content prediction results of the element a to be measured obtained in Step 6;
[0015] Further, each of the XRF spectral data obtained in step two is measured by an ED-XRF fluorescence spectrometer.
[0016] Further, before constructing the GSA-SVR model and training the constructed GSA-SVR model using the data set, the following steps are also required:
[0017] Collect a plurality of selected samples containing the element to be measured; for the selected samples, obtain the XRF spectral data of the target samples using a spectrometer, and normalize the spectral data;
[0018] Based on the spectral data, screen the peak information and content information of the element to be measured and the peak information and content information of a plurality of interfering elements of the element to be measured, to obtain a target sample set of the XRF spectrum containing a plurality of features;
[0019] Divide the obtained target sample set of the XRF spectrum containing a plurality of features into a training sample set and a test sample set;
[0020] The dividing the obtained target sample set of the XRF spectrum containing a plurality of features into a training sample set and a test sample set includes:
[0021] Divide the first k target sample data of the target sample set of the XRF spectrum containing p features into the training sample set;
[0022] Use the subsequent n-k target sample data of the target sample set of the XRF spectrum containing p features as the test sample set; where n represents the number of selected samples.
[0023] Further, the training the constructed GSA-SVR model using the data set includes:
[0024] First, determine that the kernel function of the support vector machine is a Gaussian kernel function:
[0025] K(x i , x j ) = exp(-g||x i - y j || 2 );
[0026] Wherein, K(x i , x j ) represents the kernel function; g represents the kernel function parameter; y i represents the content value of the element a to be measured in the i-th test sample set;
[0027] Secondly, use the GSA algorithm to optimize the parameters of the support vector machine to obtain the optimal penalty parameter C and kernel function parameter g;
[0028] The parameter optimization of the support vector machine using the GSA algorithm includes:
[0029] Initialize the parameters of the support vector machine SVM, and set C and g in the support vector machine SVM as the GSA optimization values;
[0030] Initialize the position and velocity according to C and g, and use the training samples to train the SVM model to obtain the GSA-SVR model with the optimal C and g.
[0031] Furthermore, the parameter optimization of the support vector machine using the GSA algorithm includes the following steps:
[0032] Initialize the position and velocity in the solution space and velocity space respectively, set the number of iterations, where the position represents the solution to the problem; by evaluating the objective function values of each individual, determine the quality of each individual and the gravitational force received, calculate the acceleration, and update the velocity and position to obtain the GSA-SVR model with the optimal C and g;
[0033] The determination of the mass and gravitational force received by each individual, the calculation of the acceleration, and the update of the velocity and position to obtain the GSA-SVR model with the optimal C and g include:
[0034] 1) Calculate the mass of individual i:
[0035]
[0036]
[0037] where fit i (t) and M i (t) represent the fitness function value and mass of the i-th individual at the t-th iteration respectively; best(t) and worst(t) represent the optimal fitness function value and the worst fitness function value among all individuals at the t-th iteration:
[0038] 2) Calculate the gravitational force:
[0039]
[0040]
[0041] where G(t) represents the value of the gravitational constant at the t-th iteration, M aj (t) is the active gravitational mass related to individual j, M pi (t) is the passive gravitational mass related to individual i, R ij (t) represents the Euclidean distance between individuals i and j, R ij (t) = ||X i(t), X j (t) || 2, where ε is a constant used to prevent the denominator from being zero; rand j represents a random variable uniformly distributed in [0, 1], kbest represents the top k individuals ranked in descending order according to individual quality, and the value of k decreases linearly with the number of iterations, with an initial value of N and a final value of 1;
[0042] 3) Calculate the acceleration:
[0043]
[0044] where M ii (t) represents the inertial gravity of individual i at the t-th iteration;
[0045] 4) Update the velocity and position:
[0046]
[0047]
[0048] where r represents a random variable uniformly distributed in [0, 1];
[0049] 5) Determine whether the maximum number of iterations is reached or the accuracy requirement is met. If so, output the GSA - SVR model with the optimal C and g; otherwise, return for another iteration until the maximum number of iterations is reached or the accuracy requirement is met, and then output the GSA - SVR model with the optimal C and g.
[0050] Furthermore, the element content quantitative analysis method combining support vector regression with gravitational search also includes:
[0051] Use the test sample set to test the trained GSA - SVR model to obtain the test results; perform anti - normalization processing on the obtained test results;
[0052] Evaluate the GSA - SVR model by calculating the mean square error and goodness of fit of the GSA - SVR model.
[0053] Furthermore, the calculation of the mean square error and goodness of fit of the GSA - SVR model includes:
[0054]
[0055]
[0056] where y i represents the content value of the element a to be measured in the i - th test sample set, represents the predicted value of the content of the element a to be measured in the i - th test sample set after anti - normalization processing; represents the average of the true values of the content of the element a to be measured in all test sample sets; R = 1, 2,..., n.
[0057] Another object of the present invention is to provide a quantitative analysis system for element content combining support vector regression and gravitational search for implementing the quantitative analysis method for element content combining support vector regression and gravitational search. The quantitative analysis system for element content combining support vector regression and gravitational search includes:
[0058] A spectral data acquisition module for the element to be measured, which is used to determine the element to be measured and acquire the XRF spectral data of the sample to be measured by using a spectrometer;
[0059] A peak information extraction module, which is used to determine the peak information of the element to be measured based on the spectral data;
[0060] A model construction module, which is used to construct a GSA-SVR model;
[0061] A data set construction module, which is used to acquire the sample data containing the element to be measured and the spectral data of the sample; based on the spectral data, screen the peak information and content information of the target element and the peak information and content information of multiple interfering elements of the element to be measured to obtain a target sample set with multiple characteristics of the XRF spectrum;
[0062] A model training module, which is used to train the constructed GSA-SVR model by using GSA combined with a training sample set;
[0063] A content prediction module, which is used to predict the content of the element to be measured based on the peak information of the element to be measured by using the trained GSA-SVR model.
[0064] Another object of the present invention is to provide a computer device, which includes a memory and a processor. When a computer program stored in the memory is executed by the processor, the processor executes the steps of the quantitative analysis method for element content combining support vector regression and gravitational search.
[0065] Another object of the present invention is to provide a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor executes the steps of the quantitative analysis method for element content combining support vector regression and gravitational search.
[0066] Another object of the present invention is to provide an information data processing terminal, which is used to implement the quantitative analysis system for element content combining support vector regression and gravitational search.
[0067] Combined with the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solution to be protected by the present invention are as follows:
[0068] Based on the fact that there is a clear corresponding relationship between sample characteristics and element content in the elemental quantitative analysis of XRF spectra, the present invention completes the training and prediction processes of the model by dividing the training set and the test set respectively. However, due to problems such as the high dimensionality of sample characteristics, excessive redundant feature information, and long training time using the original feature information, the present invention introduces the GSA algorithm on the basis of SVR to find the optimal parameters C and g. After normalizing the data set, the data is divided into a training set and a test set. A SVR prediction model is constructed using the training set data, and then the performance of the test set prediction model is used. The GSA-SVR model constructed based on the training sample data optimized by GSA is used to achieve the quantitative analysis of elements. Compared with the prior art, the present invention has higher prediction accuracy in the quantitative analysis of element content based on GSA-SVR, and is a reliable method to improve the prediction accuracy in XRF elemental quantitative analysis. It can be widely applied to the field of XRF quantitative analysis of elements.
[0069] The method for quantitative analysis of element content combining support vector regression and gravitational search provided by the present invention belongs to supervised machine learning. On the premise that there is XRF spectral data and the non-linear relationship between its characteristics and element content can be obtained through the data, the modeling work is carried out. First, the information of the element to be measured and the interfering element information are extracted from the obtained XRF spectral data as features, and the data is divided into a training sample set and a test sample set. A GSA-SVR model is obtained based on the training sample set, and the quantitative analysis of elements is realized through this model. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 is the schematic diagram of the method for quantitative analysis of element content combining support vector regression and gravitational search provided by the embodiment of the present invention;
[0071] Figure 2 is the flowchart of the method for quantitative analysis of element content combining support vector regression and gravitational search provided by the embodiment of the present invention;
[0072] Figure 3 is the schematic diagram of the optimized training of the GSA-SVR model provided by the embodiment of the present invention;
[0073] Figure 4 is the element analysis effect diagram of the GSA-SVR model provided by the embodiment of the present invention;
[0074] Figure 5 is the element analysis effect diagram of the SVM model provided by the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0075] In order to make the objectives, technical solutions and advantages of the present invention more clear and understandable, the present invention will be further described in detail below in conjunction with embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0076] This part is an explanatory embodiment that expands and explains the technical solution of the claim in order to enable those skilled in the art to fully understand how the present invention is specifically implemented.
[0077] As Figures 1 to 3 shown, the present invention provides a method for quantitative analysis of element content by combining support vector regression and gravitational search, and uses this analysis method to complete the quantitative analysis of the content of heavy metal elements in soil, including:
[0078] S101, determine the element to be measured, and use a spectrometer to obtain the XRF spectral data of the sample to be measured; determine the peak information of the element to be measured based on the spectral data;
[0079] S102, construct a GSA-SVR model and use a data set to train the constructed GSA-SVR model, and use the trained GSA-SVR model to predict the content of the element to be measured based on the peak information of the element to be measured.
[0080] The method for quantitative analysis of element content by combining support vector regression and gravitational search provided by the embodiments of the present invention specifically includes:
[0081] Step 1: Select the element a to be measured and collect n selected samples;
[0082] Step 2: For the selected samples obtained in Step 1, measure the XRF spectral data of the target samples through a spectrometer and normalize the data; each XRF spectral data is obtained by testing with an ED-XRF fluorescence spectrometer.
[0083] Step 3: Based on the XRF spectral data obtained in Step 2, select the peak information and content information of the element a to be measured and the peak information and content information of m interfering elements of the element a to be measured to obtain a target sample set of the XRF spectrum containing p features;
[0084] Step 4: Based on the data in Step 3, divide the training sample set and the test sample set; the first k target sample data are the training sample set, where the peak data of the element a to be measured is used as the input data of the SVM model, and the content of the element a to be measured is the output data of the model; the subsequent n-k target sample data are the test sample set, where the peak data of the element a to be measured is used as the input data of the SVM model, and the content of the element a to be measured is the output data of the model;
[0085] Step 5: Train and construct a GSA-SVR model based on the k training sample sets in Step 5:
[0086] Step 5.1:
[0087] SVM projects samples into a high-dimensional space through a kernel function and finds the optimal classification hyperplane in this high-dimensional space to separate different samples as much as possible with the maximum margin. When the samples are not completely separable, a soft margin needs to be introduced to alleviate this problem. The soft margin allows SVM to make mistakes in the classification of some controversial samples, and the optimization objective is as shown in Equation (3)
[0088]
[0089] s.t.y·(ω·x + b)≥1 - ξ i , i = 1, …, N
[0090] In the formula, ω is the normal vector of the maximum margin hyperplane;; i is the slack variable;; is the deviation, C is the penalty parameter, which determines the penalty degree of SVM for misclassified samples and is used to achieve a compromise between maximizing the classification margin and minimizing the number of misclassified samples, and it is a parameter that significantly affects the classification performance of SVM.
[0091] Step 5.2:
[0092] To solve this convex quadratic programming problem, after introducing the Lagrange function and the kernel function, using the duality principle, Equation (()) is transformed into Equation (()
[0093] K(x i , x j ) = exp(-g||x i - y j || 2 )
[0094]
[0095] In the formula, α i is the Lagrange multiplier, and K(x i , x j ) is the kernel function.
[0096] Step 5.3:
[0097] The present invention selects the Gaussian radial basis kernel function with universality as the kernel function of SVM, and its function expression is as shown in Equation (()
[0098] K(x i , x j ) = exp(-g||x i - y j || 2 ) (5)
[0099] Where \(g\) is the kernel function parameter that controls the range of the Gaussian kernel and is another important parameter that significantly affects the classification ability of the SVM. For different classification objects, the parameter combinations of \(C\) and \(g\) that optimize the SVM classification performance are different, and the SVM itself cannot optimize \(C\) and \(g\), so other algorithms need to be introduced.
[0100] Step 5.4: The gravitational search algorithm first initializes the positions and velocities in the solution space and velocity space respectively, and sets the number of iterations, where the position represents the solution to the problem. For example, the position and velocity of the \(i\)-th search individual in the \(d\)-dimensional space are expressed as follows:
[0101]
[0102]
[0103] Where, and represent the position component and velocity component of individual \(i\) in the \(d\)-th dimension respectively. By evaluating the objective function values of each individual, the mass and the gravitational force received by each individual are determined, the acceleration is calculated, and the velocity and position are updated.
[0104] Step 5.5: Calculate the mass
[0105] The mass of individual \(i\) is defined as follows:
[0106]
[0107]
[0108] Where, \(fit\) i (t)\) and \(M\) i (t)\) represent the fitness function value and mass of the \(i\)-th individual at the \(t\)-th iteration respectively; \(best(t)\) and \(worst(t)\) represent the optimal fitness function value and the worst fitness function value among all individuals at the \(t\)-th iteration. For a minimization problem, they are defined as follows:
[0109]
[0110]
[0111] Step 5.6: Calculate the gravitational force
[0112] The algorithm is inspired by the simulation of the law of universal gravitation, but is not limited to the exact expression of the universal gravitation formula in physics. In the \(d\)-th dimension, the gravitational force of individual \(j\) on individual \(i\) is defined as follows:
[0113]
[0114] Among them, G(t) represents the value of the gravitational constant at the t-th iteration, and M aj (t) is the active gravitational mass related to individual j, and M pi (t) is the passive gravitational mass related to individual i, and R ij (t) represents the Euclidean distance between individuals i and j, and R ij (t) = ||X i (t), X j (t)||2, and ε is a constant to prevent the denominator from being zero.
[0115] In the d-th dimension, the resultant force on individual i is:
[0116]
[0117] Among them, rand j represents a random variable uniformly distributed between [0, 1], kbest represents the top k individuals with their masses sorted in descending order, and the value of k decreases linearly with the number of iterations, with the initial value being N and the final value being 1.
[0118] Step 5.7: Calculate the acceleration
[0119] According to Newton's second law, the acceleration equation of individual i in the d-th dimension is:
[0120]
[0121] M ii (t) is the inertial gravity of individual i at the t-th iteration.
[0122] Step 5.8: Update the velocity and position
[0123]
[0124]
[0125] Among them, r represents a random variable uniformly distributed between [0, 1].
[0126] Step 5.9: End when the maximum number of iterations is reached or the accuracy requirement is met, and output the optimal solution; otherwise, return to Step 5.2 to enter the next round of iteration.
[0127] In Step 5, the process of training and constructing the GSA - SVR model provided by the embodiment of the present invention is as follows:
[0128] The selective Gaussian kernel function is adopted as the kernel function of the support vector machine. At this time, the SVM is affected by the penalty factor C and the Gaussian kernel parameter g. The GSA algorithm is used to optimize the parameters of the SVM. Through continuous iterative optimization, the optimal parameters C and g are found to improve the accuracy of the model and reduce the error recognition rate. The process of the GSA-SVR algorithm is as follows:
[0129] Step 5.10: Initialize the parameters of the SVM, and set C and g in the SVM as the GSA optimization values.
[0130] Step 5.11: Initialize the position and velocity according to C and g, and use the training samples to train the SVM model.
[0131] Step 5.12: Predict the test samples through the GSA-SVR model and evaluate the performance of the model.
[0132] Step 6: Substitute the input data in the n-k test sample sets in Step 5 into the GSA-SVR model trained in Step 5 for prediction, and obtain the prediction results of the content of the element a to be measured in the n-k test sample sets;
[0133] Step 7: Denormalize the prediction results of the content of the element a to be measured obtained in Step 6;
[0134] Step 8: Calculate the mean square error (Mean-Square Error, MSE) and goodness of fit (Goodness of Fit, R 2) Two performance indicators:
[0135]
[0136]
[0137] where y i is the content value of the element a to be measured in the i-th test sample set, is the predicted value of the content of the element a to be measured in the i-th test sample set after denormalization processing, is the average value of the true content values of the element a to be measured in all test sample sets;.
[0138] To prove the creativity and technical value of the technical solution of the present invention, this part is an application embodiment of the technical solution of the claims on specific products or related technologies.
[0139] Apply the element content quantitative analysis method combining support vector regression and gravitational search provided by the embodiment of the present invention to the analysis of soil heavy metal elements. The specific steps are as follows:
[0140] Step 1: Designate the Cu element as the element to be measured, element a. Use n = 57 national standard samples as the selected samples. The instrument used in this example is a handheld ED-XRF spectrometer manufactured by Tekxund Co., Ltd., with the model number TS-XH4000-SOIL. The X-ray tube parameters of this device under normal operation are 45 KV and 25 uA. Obtain the 2048 full-channel spectrograms of all samples measured by the ED-XRF spectrometer. Step 2: Normalize the peak and content information selected in Step 1 to the interval [0, 1]; the obtained XRF spectral data are measured by the ED-XRF fluorescence spectrometer.
[0141] Step 3: Extract the peak and content information of the element to be measured, Cu, and the peak information of the corresponding 5 interfering elements, Fe, Ni, P, Co, and Mn, that interfere with the element to be measured, Cu, from the data normalized in Step 2 to obtain the original dataset A.
[0142] Step 4: Based on the data in Step 3, divide the training sample set and the test sample set; the first 45 target sample data are the training sample set, where the peak data of the element to be measured, Cu, are used as the input data of the SVM model, and the content of the element to be measured, Cu, is the output data of the model; the subsequent 12 target sample data are the test sample set, where the peak data of the element to be measured, Cu, are used as the input data of the SVM model, and the content of the element to be measured, Cu, is the output data of the model.
[0143] Step 5: Train and construct a GSA-SVR model based on the 45 training sample sets in Step 5.
[0144] The process of constructing the GSA-SVR model is as follows:
[0145] Step 5.1:
[0146] SVM projects the samples into a high-dimensional space through a kernel function and searches for the optimal classification hyperplane in this high-dimensional space to separate different samples as far as possible with the maximum margin. When the samples are not completely separable, a soft margin needs to be introduced to alleviate this problem. The soft margin allows SVM to make mistakes in the classification of some controversial samples. The optimization objective is as shown in Equation (1(
[0147]
[0148] s.t. y·(ω·x + b) ≥ 1 - ξ i , i = 1,..., N
[0149] In the formula, ω is the normal vector of the maximum margin hyperplane; ξ is the slack variable; b is the deviation, C is the penalty parameter, which determines the penalty degree of SVM for misclassified samples and is used to achieve a compromise between maximizing the classification margin and minimizing the number of misclassified samples. It is a parameter that has a significant impact on the classification performance of SVM.
[0150] Step 5.2:
[0151] To solve this convex quadratic programming problem, after introducing the Lagrange function and the kernel function, and using the duality principle, Equation (1) is transformed into Equation (2).
[0152] K(x i , x j ) = exp(-g||x i - y j || 2 )
[0153]
[0154] where α i is the Lagrange multiplier, and K(x i , x j ) is the kernel function.
[0155] Step 5.3:
[0156] The present invention selects the Gaussian radial basis kernel function with universality as the kernel function of SVM, and its function expression is as shown in Equation (3).
[0157] K(x i , x j ) = exp(-g||x i - y j || 2 ) (3)
[0158] In the formula, g is the kernel function parameter, which controls the action range of the Gaussian kernel and is another important parameter that significantly affects the classification ability of SVM. For different classification objects, the parameter combinations of C and g that make the SVM classification performance optimal are different, and the SVM itself cannot achieve the optimization of C and g, so other algorithms need to be introduced.
[0159] Step 5.4: The gravitational search algorithm first initializes the position and velocity in the solution space and the velocity space respectively, and sets the number of iterations, where the position represents the solution to the problem. For example, the position and velocity of the i-th search individual in the d-dimensional space are respectively expressed as:
[0160]
[0161]
[0162] where and respectively represent the position component and the velocity component of individual i in the d dimension. By evaluating the objective function values of each individual, the mass and the gravitational force received by each individual are determined, the acceleration is calculated, and the velocity and position are updated.
[0163] Step 5.5: Calculate the mass
[0164] The mass of individual i is defined as follows:
[0165]
[0166]
[0167] where fit i (t) and M i (t) represent the fitness function value and the mass of the i-th individual at the t-th iteration, respectively; best(t) and worst(t) represent the optimal fitness function value and the worst fitness function value among all individuals at the t-th iteration. For a minimization problem, they are defined as follows:
[0168]
[0169]
[0170] Step 5.6: Calculate the gravitational force
[0171] The algorithm is derived from the simulation of the law of universal gravitation, but is not limited to the exact expression of the universal gravitation formula in physics. In the d-th dimension, the gravitational force of individual j on individual i is defined as follows:
[0172]
[0173] where G(t) represents the value of the universal gravitational constant at the t-th iteration, M aj (t) is the active gravitational mass related to individual j, M pi (t) is the passive gravitational mass related to individual i, R ij (t) represents the Euclidean distance between individuals i and j, R ij (t) = ||X i (t), X j (t)||2, and ε is a constant to prevent the denominator from being zero.
[0174] In the d-th dimension, the resultant force on individual i is:
[0175]
[0176] where rand j represents a random variable uniformly distributed between [0, 1], kbest represents the k individuals with the top k masses in descending order, and the value of k decreases linearly with the number of iterations, with an initial value of N and a final value of 1.
[0177] Step 5.7: Calculate the acceleration
[0178] According to Newton's second law, the acceleration equation of individual i in the d-th dimension is:
[0179]
[0180] M ii (t) is the inertial gravity of individual i at the t-th iteration.
[0181] Step 5.8: Update the velocity and position
[0182]
[0183]
[0184] where r represents a random variable uniformly distributed between [0, 1].
[0185] Step 5.9: End when the maximum number of iterations is reached or the accuracy requirement is met, output the optimal solution, otherwise return to Step 5.2 to enter the next round of iteration.
[0186] The process of training and constructing the GSA-SVR model is as follows:
[0187] The Gaussian kernel function is adopted as the kernel function of the support vector machine. At this time, SVM is affected by the penalty factor C and the Gaussian kernel parameter g. The GSA algorithm is used to optimize the parameters of SVM. By continuous iterative optimization, the optimal parameters C and g are found to improve the accuracy of the model and reduce the error recognition rate. The process of the GSA-SVR algorithm is as follows:
[0188] Step 5.10: Initialize the parameters of SVM, and set C and g in SVM as the GSA optimization values.
[0189] Step 5.11: Initialize the position and velocity according to C and g, and use the training samples to train the SVM model.
[0190] Step 5.12: Predict the test samples through the GSA-SVR model and evaluate the performance of the model.
[0191] Step 6: Substitute the input data in the 12 test sample sets in Step 5 into the GSA-SVR model trained in Step 5 for prediction, and obtain the prediction results of the content of the element a to be measured in the 12 test sample sets;
[0192] Step 7: Denormalize the prediction results of the content of the element Cu to be measured obtained in Step 6;
[0193] Step 8: Calculate the Mean-Square Error (MSE) and Goodness of Fit (R 2) of two performance indicators:
[0194]
[0195]
[0196] where y i is the content value of the element Cu to be measured in the i-th test sample set, is the predicted value of the content of the element Cu to be measured in the i-th test sample set after anti-normalization processing, is the average value of the true values of the content of the element Cu to be measured in all test sample sets; R = 1, 2,..., n.
[0197] Some positive effects have been achieved during the research and development or use of the embodiments of the present invention, and there are indeed great advantages compared with the prior art. The following content will be described in combination with the data, charts, etc. of the experimental process.
[0198] The prediction results of the element Cu to be measured in the soil obtained in the embodiments of the present invention and Comparative Example 1 are as Figure 4 - Figure 5 shown.
[0199] The following uses a table to compare the evaluation index data of the training set and prediction set of the embodiment and Comparative Example 1:
[0200] Table 1 Performance indicators of the training set and prediction set of the Cu element content of the GSA-SVR and SVM models
[0201]
[0202] Table 1 gives the R 2 and MSE of the training set and test set of the GSA-SVR and SVM models for predicting the Cu element content. As can be seen from the table, the R 2 and MSE of the GSA-SVR training set are 0.992 and 0.005 respectively, and the R 2 and RMSE of the test set are 0.988 and 0.008 respectively, while the R 2 and RMSE of the SVM model without GSA are 0.918 and 0.039 respectively, and the R 2The RMSE and [value] are 0.886 and 0.042 respectively, indicating that the established GSA-SVR model has a significant improvement in the prediction performance of Cu elements compared with the SVM model and can better fit the modeling data; moreover, the MSE values of both the GSA-SVR and SVM models are very small, and the errors are within an acceptable range.
[0203] In addition, compared with the training set, the model evaluation indicators of the test set do not differ much, indicating that the model does not overfit and has good generalization performance. By comparing the model evaluation indicators of GSA-SVR and SVM, it can be seen that using GSA-SVR for modeling in the test set 2 increases by at least 11%, the MSE is less than that of the RFR model, and Figure 4 - Figure 5 it can be seen that the pass rate of the predicted values of GSA-SVR is higher. In summary, the quantitative analysis of element content based on GSA-SVR has higher prediction accuracy and is a reliable method to improve the prediction accuracy in XRF element quantitative analysis.
[0204] It should be noted that the embodiments of the present invention can be implemented through hardware, software, or a combination of software and hardware. The hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. Those of ordinary skill in the art can understand that the above devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code is provided on a carrier medium such as a disk, CD, or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The devices and modules of the present invention can be implemented by hardware circuits of programmable hardware devices such as very large scale integrated circuits or gate arrays, semiconductors such as logic chips and transistors, or field programmable gate arrays and programmable logic devices, can also be implemented by software executed by various types of processors, or can be implemented by a combination of the above hardware circuits and software, such as firmware.
[0205] The above is only the specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention by those skilled in the art within the technical scope disclosed by the present invention shall be covered by the protection scope of the present invention.
Claims
1. A quantitative analysis method for element content combining support vector regression and gravitational search, characterized in that, The quantitative analysis method of element content combining support vector regression and gravitational search specifically includes: Step 1: Select the element a to be measured and collect n selected samples; Step 2: Determine the element to be measured, obtain the XRF spectral data of the sample to be measured by a spectrometer, and normalize the data; determine the peak information of the element to be measured based on the spectral data; Step 3: Based on the XRF spectral data obtained in Step 2, select the peak information and content information of the element a to be measured and the peak information and content information of m interfering elements of the element a to be measured, to obtain a target sample set of the XRF spectrum with p features; Step 4: Construct a GSA-SVR model and use the data set to train the constructed GSA-SVR model, and use the trained GSA-SVR model to predict the content of the element to be measured based on the peak information of the element to be measured; based on the data in Step 3, divide the training sample set and the test sample set; the first k target sample data are the training sample set, where the peak data of the element a to be measured is used as the input data of the SVM model, and the content of the element a to be measured is the output data of the model; the subsequent n-k target sample data are the test sample set, where the peak data of the element a to be measured is used as the input data of the SVM model, and the content of the element a to be measured is the output data of the model; Step 5: Train and construct a GSA-SVR model based on the k training sample sets in Step 5; Step 6: Substitute the input data in the n-k test sample sets in Step 5 into the GSA-SVR model trained in Step 5 for prediction, to obtain the content prediction results of the element a to be measured in the n-k test sample sets; Step 7: Denormalize the content prediction results of the element a to be measured obtained in Step 6.
2. The quantitative analysis method for element content by combining support vector regression and gravitational search as claimed in claim 1, wherein, Before constructing the GSA-SVR model and using the data set to train the constructed GSA-SVR model, it is also necessary to: Collect multiple selected samples containing the element to be measured; For the selected samples, obtain the XRF spectral data of the target samples by a spectrometer, and normalize the spectral data; Based on the spectral data, screen the peak information and content information of the element to be measured and the peak information and content information of multiple interfering elements of the element to be measured, to obtain a target sample set of the XRF spectrum with multiple features; Divide the obtained target sample set of the XRF spectrum with multiple features into a training sample set and a test sample set; The dividing the obtained target sample set of the XRF spectrum with multiple features into a training sample set and a test sample set includes: Divide the first k target sample data of the target sample set of the XRF spectrum with p features into the training sample set; The subsequent n-k target sample data of the target sample set of the XRF spectrum with p features are the test sample set; where n represents the number of selected samples.
3. The quantitative analysis method for element content by combining support vector regression and gravitational search according to claim 1, characterized in that The using the data set to train the constructed GSA-SVR model includes: First, determine that the kernel function of the support vector machine is the Gaussian kernel function: K(x i ,x j ) = exp(-g||x i -y j || 2 ); Among them, K(x i , x j ) represents the kernel function; g represents the kernel function parameter; y i represents the content value of the element a to be measured in the i-th test sample set; Second, use the GSA algorithm to optimize the parameters of the support vector machine to obtain the optimal penalty parameter C and kernel function parameter g; The parameter optimization of the support vector machine using the GSA algorithm includes: Initializing the parameters of the support vector machine SVM, and setting C and g in the support vector machine SVM as the GSA optimization values; Initializing the position and velocity according to C and g, training the SVM model using the training samples, and obtaining the GSA-SVR model with the optimal C and g.
4. The quantitative analysis method for element content by combining support vector regression with gravitational search according to claim 3, characterized in that, The parameter optimization of the support vector machine using the GSA algorithm includes the following steps: Initializing the position and velocity in the solution space and the velocity space respectively, setting the number of iterations, where the position represents the solution to the problem; determining the quality and the gravitational force received by each individual by evaluating the objective function values of each individual, calculating the acceleration, and updating the velocity and position to obtain the GSA-SVR model with the optimal C and g; The determination of the quality and the gravitational force received by each individual, the calculation of the acceleration, and the update of the velocity and position to obtain the GSA-SVR model with the optimal C and g include: 1) Calculating the mass of individual i: Among them, fit i (t) and M i (t) represent the fitness function value and quality of the i-th individual at the t-th iteration, respectively; best(t) and worst(t) represent the optimal fitness function value and the worst fitness function value among all individuals at the t-th iteration: 2) Calculating the gravitational force: Among them, G(t) represents the value of the gravitational constant at the t-th iteration, M aj (t) is the active gravitational mass related to individual j, M pi (t) is the passive gravitational mass related to individual i, R ij (t) represents the Euclidean distance between individuals i and j, R ij (t) = ||X i (t), X j (t)||2, ε is a constant used to prevent the denominator from being zero; rand j represents a random variable uniformly distributed between [0, 1], kbest represents the top k individuals with their masses ranked in descending order, and the value of k decreases linearly with the number of iterations, with an initial value of N and a final value of 1; 3) Calculating the acceleration: Among them, M ii (t) represents the inertial gravity of individual i at the t-th iteration; 4) Updating the velocity and position: where r represents a random variable uniformly distributed between [0, 1]; 5) Judging whether the maximum number of iterations is reached or the accuracy requirement is met. If so, output the GSA-SVR model with the optimal C and g; otherwise, return for re-iteration until the maximum number of iterations is reached or the accuracy requirement is met, and output the GSA-SVR model with the optimal C and g.
5. The quantitative analysis method for element content by combining support vector regression and gravitational search according to claim 1, characterized in that, The quantitative analysis method for element content combining support vector regression with gravitational search further includes: Testing the trained GSA-SVR model using the test sample set to obtain the test results; performing anti-normalization processing on the obtained test results; Evaluating the GSA-SVR model by calculating the mean square error and the goodness of fit of the GSA-SVR model; The calculation of the mean square error and the goodness of fit of the GSA-SVR model includes: Among them, y i represents the content value of the element a to be measured in the i-th test sample set, represents the predicted content value of the element a to be measured in the i-th test sample set after inverse normalization processing; represents the average value of the true content values of the element a to be measured in all test sample sets; R = 1, 2,..., n.
6. A quantitative analysis system for element content based on support vector regression combined with gravitational search, which implements the quantitative analysis method for element content based on support vector regression combined with gravitational search according to any one of claims 1-5, characterized in that The quantitative analysis system for element content combining support vector regression with gravitational search includes: A module for obtaining spectral data of the element to be measured, which is used to determine the element to be measured and obtain the XRF spectral data of the sample to be measured using a spectrometer; A peak information extraction module, which is used to determine the peak information of the element to be measured based on the spectral data; A model construction module, which is used to construct a GSA-SVR model; A data set construction module, which is used to obtain the sample data containing the element to be measured and the spectral data of the sample; screening the peak information and content information of the target element and the peak information and content information of multiple interfering elements of the element to be measured based on the spectral data to obtain a target sample set of the XRF spectrum containing multiple features; A model training module, which is used to train the constructed GSA-SVR model using GSA combined with the training sample set; A content prediction module, which is used to predict the content of the element to be measured based on the peak information of the element to be measured using the trained GSA-SVR model.
7. A computer device, characterized in that, The computer device includes a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor is caused to execute the steps of the element content quantitative analysis method combining support vector regression and gravitational search as described in any one of claims 1-5.
8. A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the processor is caused to execute the steps of the element content quantitative analysis method combining support vector regression and gravitational search as described in any one of claims 1-5.
9. An information data processing terminal, characterized in that, The information data processing terminal is used to implement the element content quantitative analysis system combining support vector regression and gravitational search as described in claim 6.
Citation Information
Patent Citations
Method for monitoring state of gearbox of wind power generation set
CN104614179A
Prediction method and system of high slope deformation
US20210049515A1