Near-infrared Spectral Wavelength Selection Method for Black Vinegar Solution Based on a Four-step Strategy Selection
The screening of near-infrared spectral wavelengths through a four-step strategy selection method solves the problem that model accuracy and the number of wavelength variables in the prior art are difficult to take into account, and the rapid non-destructive detection of the concentration of Urotropine in the Urovita solution is achieved, reducing the cost of convenient near-infrared instruments.
Patent Information
- Application Number
- CN202310249561.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-15
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2043-03-15
AI Technical Summary
The existing near-infrared spectral wavelength selection method is difficult to take into account the model accuracy and the number of wavelength variables, resulting in high cost of convenient near-infrared instruments and hindering the development of online detection.
A four-step strategy selection method is adopted, including spectral preprocessing, information-free variable elimination method, differential algorithm, cuckoo algorithm and continuous projection algorithm, and the optimal characteristic wavelength is gradually screened out, and a near-infrared quantitative analysis model of Urotropine concentration in Urotropine solution is established.
A highly accurate model is achieved at the smallest number of wavelengths possible, reducing the development cost of convenient near-infrared instruments and improving detection efficiency and practicality.
Smart Images

Figure CN116578836B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical fields of analytical chemistry and on-line detection of explosives, and particularly relates to a method for selecting near-infrared spectral wavelengths of urotropine-acetic acid (uroacetic acid) solution based on a four-step strategy selection. Background Art
[0002] As one of the important raw materials for producing HMX by the acetic anhydride method, the concentration change of urotropine-acetic acid (uroacetic acid) solution affects the yield and purity of the product. The traditional method for measuring the concentration of urotropine in uroacetic acid solution belongs to chemical analysis, which is time-consuming and laborious, and the organic reagents used will cause environmental pollution. Near-infrared spectroscopy has been applied to a certain extent in the detection of components of mixed explosives and propellants due to its advantages of non-destructive, fast, and pollution-free, so it can also be applied to the concentration detection of raw materials for producing explosives.
[0003] The non-destructive detection technology using near-infrared spectroscopy requires the construction of a quantitative or qualitative analysis model, and wavelength variable selection is an essential link. Screening characteristic wavelengths through specific algorithms helps to reduce the complexity of the model, reduce the interference of redundant information, and construct an analysis model with strong prediction ability and good robustness.
[0004] In terms of characteristic wavelength selection, the commonly used ones are the successive projections algorithm SPA and the uninformative variable elimination method UVE. The number of wavelength variables selected by the SPA algorithm is small, but the performance of the finally established model is poor and it is difficult to meet the actual application requirements; the accuracy of the model finally established after selecting characteristic wavelengths by the UVE algorithm is relatively high, however, the number of selected wavelength variables is also large; even if the two are combined to form the UVE-SPA algorithm, although the number of wavelength variables is reduced, the prediction performance of the model is not satisfactory, the practicability is weak, which makes the cost of developing a portable near-infrared spectrometer relatively high and hinders the further development of on-line detection. Therefore, a method for selecting wavelength variables is needed to balance the model accuracy and the number of wavelength variables. Summary of the Invention
[0005] In order to solve the problem that the existing wavelength selection methods are difficult to balance the model accuracy and the number of wavelength variables, the main purpose of the present invention is to provide a method for selecting near-infrared spectral wavelengths of uroacetic acid solution based on a four-step strategy selection, select the near-infrared spectral wavelengths of uroacetic acid solution based on the four-step strategy selection, and establish a near-infrared quantitative analysis model for the concentration of urotropine in uroacetic acid solution, which can reduce the complexity of the model, improve the detection efficiency and practicability of the model, so as to realize the rapid non-destructive detection of the concentration of urotropine in uroacetic acid solution and reduce the development cost of portable near-infrared instruments.
[0006] The present invention is achieved by the following technical solutions:
[0007] The method for selecting near-infrared spectral wavelengths of wu vinegar solution based on four-step strategy selection disclosed by the present invention includes the following steps:
[0008] Step 1: Preprocess the collected near-infrared spectrum of the wu vinegar solution to eliminate the burrs and deformations caused by temperature and noise during data collection; and use chemical analysis methods to measure the hexamine concentration corresponding to the near-infrared spectrum curve of the collected wu vinegar solution;
[0009] Step 2: Use the uninformative variable elimination method to select characteristic wavelengths from the preprocessed spectrum to obtain a set of characteristic wavelengths S1;
[0010] The selection of characteristic wavelengths by the uninformative variable elimination method described in Step 2 includes the following steps:
[0011] (1) Form a spectral matrix X(n×m) composed of the preprocessed near-infrared spectrum and a concentration matrix Y(n×1) composed of the hexamine concentration corresponding to the near-infrared spectrum curve of the collected wu vinegar solution measured by the above chemical analysis method, where m represents the total number of spectral bands. Randomly generate a noise matrix R(n×m), and combine the foregoing spectral matrix X and the noise matrix R to form a mixed matrix XR(n×2m), where the first m columns of the mixed matrix are the spectral matrix X and the last m columns are the noise matrix R;
[0012] (2) Perform PLS regression on the mixed matrix XR and the concentration matrix Y, and perform cross-validation by removing one sample each time to obtain a regression coefficient vector b, and finally obtain a regression coefficient matrix B(n×2m);
[0013] (3) Calculate the standard deviation S(b) and the mean value mean(b) of the regression coefficient matrix B column by column, and calculate the variable index coefficient C j =mean(b j ) / S(b j ), where j = 1, 2,..., 2m;
[0014] (4) In the interval [m+1, 2m], take the maximum absolute value C max =max(abs(C)) of the absolute value of the variable index coefficient C, where abs(C) represents the absolute value of the variable index coefficient C;
[0015] (5) In the interval [1, m], remove the variable data of the spectral matrix X corresponding to Cj<C max , and form a set of characteristic wavelengths S1 with the remaining variables.
[0016] Step 3: Further screen the wavelength variables in the set of characteristic wavelengths S1 by using the differential algorithm. After initialization, mutation, crossover, and selection, obtain a set of characteristic wavelengths S2 based on the differential algorithm;
[0017] The preferred feature wavelength by the differential algorithm described in Step 3 includes the following steps:
[0018] (1) Initialization: The initial population X(g) at the g-th generation of evolution usually needs to be calculated in combination with the upper and lower limits of the decision space:
[0019]
[0020]
[0021] where x i,j (g) is the i-th and j-th dimensional individual in the initial population X(g) at the g-th generation of evolution, are the lower and upper limits of the j-th dimension respectively, rand(0,1) represents a random number in the interval [0,1], NP is the population size, and D is the individual dimension;
[0022] (2) Mutation: Randomly select three different individuals from the initial population X(g) at the g-th generation of evolution and denote them as x r1 (g), x r2 (g) and x r3 (g), where r1, r2, and r3 are random numbers in the interval [1,NP], and then generate a mutant individual V i (g + 1) = (v i,1 (g + 1), v i,2 (g + 1), …, v i,D (g + 1)):
[0023] v i,j (g + 1) = x r1,j (g) + F(x r2,j (g) - x r3,j (g)) (3)
[0024] where F is the mutation parameter;
[0025] (3) Crossover: Cross the mutant individual v i,j (g + 1) with the individual x i ,j(g) in the initial population X(g) at the g-th generation of evolution to obtain a trial individual U i (g + 1) = (u i,1 (g + 1), u i,2 (g + 1), …, u i,D (g + 1)):
[0026]
[0027] where CR is the crossover probability.
[0028] (4) Selection: Select the trial individual \(u\) according to the greedy criterion i (g + 1) to compete with the individual \(x\) in the initial population \(X(g)\) at the evolutionary generation \(g\) i (g). If the performance of the trial individual \(u\) i (g + 1) is better than that of \(x\) i (g), then the trial individual \(u\) i (g + 1) replaces \(x\) i (g) and enters the initial population \(X(g + 1)\) at the evolutionary generation \(g+1\). Otherwise, \(x\) i (g) enters the initial population \(X(g + 1)\) at the evolutionary generation \(g + 1\):
[0029]
[0030] where \(f\) is the fitness function.
[0031] (5) Set the iteration number \(g=g + 1\), and judge whether \(g\) is equal to the maximum iteration number \(IterMax\). If it is equal to \(IterMax\), continue to the next step. Otherwise, jump to step (2);
[0032] (6) Output the finally obtained initial population \(X(g + 1)\), which is the characteristic wavelength set \(S2\) of the differential optimization algorithm.
[0033] Step Four: Further screen the wavelength variables in the characteristic wavelength set \(S2\) based on the differential algorithm by using the cuckoo algorithm to obtain the characteristic wavelength set \(S3\) based on the cuckoo algorithm.
[0034] The characteristic wavelength optimization by the cuckoo algorithm described in Step Four includes the following steps:
[0035] (1) Take the spectral data in the spectral matrix \(X\) corresponding to the characteristic wavelength set \(S2\) of the differential optimization algorithm as the initial variables. According to the dimension constraint, randomly generate \(NC\) nests \(Y(t)=(y1(t),y2(t),…,y\) NC (t)) of the \(t\)-th generation in the dimension space \(dim\);
[0036] (2) For the position \(y\) of the \(k\)-th nest k (t)=(y k1 (t),y k2 (t),…,y kdim (t)), \(1\leq k\leq NC\), evaluate the information of the \(t\)-th generation nest \(Y(t)\) according to the fitness function \(f\), retain the information of the optimal nest, and obtain the information of the \((t + 1)\)-th generation nest according to the update formula:
[0037]
[0038] In the formula is the nest position of the k-th cuckoo's nest in the t-th generation. is the point-to-point multiplication, α is the step size control parameter, which is used to control the search range of the step size. Its value follows a normal distribution. At this time, α = 1. L(λ) is the Levy random search path, which belongs to a random walk and adopts the Levy flight mechanism. After simplification:
[0039]
[0040] In the formula is the optimal nest information found by the cuckoo at the t-th iteration. u and v follow the standard normal distribution, and β = 1.5.
[0041] (3) Generate a uniformly distributed random number r (r ∈ (0, 1)) and compare it with the maximum discovery probability P. If r < P, discard this nest and replace the old nest through the random walk strategy. After updating, evaluate the nest information and retain the current optimal nest information; if r ≥ P, remain unchanged:
[0042]
[0043] In the formula represents the positions of two random nests in the t-th generation;
[0044]
[0045] (4) Set the iteration number t = t + 1, and judge whether t is equal to the maximum iteration number N_IterTotal. If it is equal to N_IterMax, continue to the next step; otherwise, jump to step (2);
[0046] (5) Output the optimal nest information Obtain the characteristic wavelength set S3 under the cuckoo algorithm.
[0047] Step Five: Use the successive projections algorithm SPA to further screen the wavelength variables in the characteristic wavelength set S3 under the cuckoo algorithm to obtain the final wavelength variable set S, that is, realize the near-infrared spectral wavelength selection of black vinegar solution based on the four-step strategy selection.
[0048] The SPA algorithm described in Step Five belongs to the forward iterative search algorithm. Its purpose is to select the wavelengths with the least spectral information redundancy to solve the collinearity problem. The selection steps are as follows:
[0049] (1) When the initial iteration l = 1, assign the k-th column of the spectral matrix X corresponding to the characteristic wavelength set S3 under the cuckoo algorithm to x j , denoted as x k(0) , and k(0) is the initial position of the selected variable (j = k(0), 1 ≤ j ≤ m);
[0050] (2) Define the set of remaining column vector positions as s:
[0051]
[0052] (3) Calculate the projections of the remaining column vectors x j (j ∈ s) onto the selected vector x k(l-1) respectively.
[0053]
[0054] In the formula, represents the transpose matrix of x j , and represents 's inverse matrix.
[0055] (4) Extract the wavelength serial number k(l) corresponding to the maximum projection value. The calculation formula is:
[0056]
[0057] (5) Take the maximum projection value as the initial value for the next iteration, that is
[0058] (6) Let l = l + 1. When l < H, return to step (2) for loop calculation. When l is equal to the optimal wavelength H, stop the loop and proceed to step (7);
[0059] (7) When the loop terminates, obtain the finally selected combination of wavelength variables {k(t), t = 0, 1,..., H - 1}.
[0060] (8) Since the first variable x k(0) of the iteration is randomly selected, let each column in the spectrum be used as an initial variable once, and perform the iteration of steps (1) to (6). Select H variables each time, and obtain m combinations of wavelength variables selected by the iteration of m initial variables. Then, establish a multiple linear regression analysis model for each combination respectively, obtain the root mean square error of cross - validation (RMSECV), and take the k(0) corresponding to the minimum RMSECV value as the final set of wavelength variables S.
[0061] Preferably, the fitness function is set as: where y i is the measured value of the sample component or property, is the predicted value of the sample, and n is the number of samples.
[0062] Beneficial effects
[0063] 1) The method for selecting near-infrared spectral wavelengths of vinegar solution based on a four-step strategy disclosed by the present invention selects the near-infrared spectrum of vinegar solution based on the four-step strategy and establishes a near-infrared quantitative analysis model for the concentration of hexamethylenetetramine in the vinegar solution, taking into account both the number of selected wavelength variables and the accuracy of the established model, that is, obtaining a model with as high accuracy as possible with as few wavelength numbers as possible.
[0064] 2) The method for selecting near-infrared spectral wavelengths of vinegar solution based on a four-step strategy disclosed by the present invention uses a differential algorithm to obtain an initial solution, reducing the time for the cuckoo algorithm to perform blind searches due to a large amount of information in the initial stage and improving the efficiency of selecting characteristic wavelengths of the near-infrared spectrum of vinegar solution.
[0065] 3) The method for selecting near-infrared spectral wavelengths of vinegar solution based on a four-step strategy disclosed by the present invention adopts a near-infrared quantitative analysis model for the concentration of hexamethylenetetramine in the vinegar solution, which can achieve rapid and non-destructive detection of the concentration of hexamethylenetetramine in the vinegar solution and reduce the development cost of portable near-infrared instruments. Description of the Drawings
[0066] Figure 1 It is a near-infrared spectral wavelength variable diagram of vinegar solution selected based on a four-step strategy. Detailed Embodiments
[0067] The following further describes the present invention in detail with reference to the drawings:
[0068] Example 1:
[0069] I. Spectrum Pretreatment
[0070] Considering that when collecting near-infrared spectra, there are many noise information such as high-frequency random noise, baseline drift, particle size, and light scattering, which affect the correlation between the near-infrared spectrum and the concentration of hexamethylenetetramine in the hexamethylenetetramine-acetic acid solution, resulting in phenomena such as inaccurate precision and poor stability in the established model. To eliminate the influence of noise, algorithms such as standard normal variate (SNV), Savitzky-Golay (S-G) smoothing, maximum-minimum normalization (MMS), vector normalization (VN), and wavelet transform (WT) are often used to preprocess the near-infrared spectrum. In this embodiment, the standard normal variate (SNV) is used to preprocess the original near-infrared spectra of 102 vinegar solution samples collected, constituting a preprocessed spectral matrix X(n×m), where m represents the total number of spectral bands and n represents the total number of samples; at the same time, based on manual analysis, the concentration values represented by the near-infrared spectral curves of different vinegar solutions are obtained, constituting an original concentration matrix Y(n×1).
[0071] II. Dataset Division
[0072] According to the process of the random division algorithm, the preprocessed spectral set and the original concentration set are divided into a calibration set and a prediction set according to a preset ratio of 71:29.
[0073] III. Feature wavelength optimization by uninformative variable elimination method
[0074] The uninformative variable elimination method is used to select the feature wavelengths from the preprocessed spectra, and a set of feature wavelengths S1 is obtained;
[0075] The uninformative variable elimination method for feature wavelength selection includes the following steps:
[0076] (1) Randomly generate a noise matrix R(n×m), and combine the aforementioned preprocessed spectral matrix X with the noise matrix R to form a mixed matrix XR(n×2m), where the first m columns of the mixed matrix are the preprocessed spectral matrix X, and the last m columns are the noise matrix R;
[0077] (2) Perform PLS regression on the mixed matrix XR and the aforementioned original concentration matrix Y, with leave-one-out cross-validation each time to obtain a regression coefficient vector b, and finally obtain a regression coefficient matrix B(n×2m);
[0078] (3) Calculate the standard deviation S(b) and the mean value mean(b) of the regression coefficient matrix B column by column, and calculate the variable index coefficient C j =mean(b j ) / S(b j ), where j = 1, 2, …, 2m;
[0079] (4) In the interval [m+1, 2m], take the maximum absolute value C max =max(abs(C)) of the absolute value of the variable index coefficient C, where abs(C) represents the absolute value of the variable index coefficient C;
[0080] (5) In the interval [1, m], remove the variable data of the preprocessed spectral matrix X corresponding to Cj < C max , and form a set of feature wavelengths S1 with the remaining variables.
[0081] In this embodiment, after the feature wavelength optimization by the uninformative variable elimination method, a set of feature wavelengths S1 including 354 wavelength variables such as 4817.31, 4828.88, 4809.596, 4821.167, 8566.249, 8570.105, 4859.736, 4906.019, 4855.879, 8350.261, 8373.402, 8408.114, etc. is obtained.
[0082] IV. Differential optimization algorithm and optimized feature wavelengths
[0083] The 354 wavelength variables in the characteristic wavelength set S1 are further screened using the differential algorithm. After initialization, mutation, crossover, and selection, the characteristic wavelength set S2 based on the differential algorithm is obtained.
[0084] The optimization of characteristic wavelengths by the differential algorithm includes the following steps:
[0085] (1) Initialization: Let g = 0, and then perform the initialization of the population X(0) by combining the upper and lower limits of the decision space:
[0086]
[0087]
[0088] where x i,j (0) is the i-th and j-th dimensional individual in the initialization population X(0) when the evolution generation is 0, are the lower and upper limits of the j-th dimension respectively, rand(0,1) represents a random number in the interval [0,1], NP is the population size, and D is the individual dimension;
[0089] (2) Mutation: Randomly select three different individuals from the initialization population X(0) and denote them as x r1 (0), x r2 (0), and x r3 (0), where r1, r2, and r3 are random numbers in the interval [1,NP], and then generate the mutant individual V i (1) = (v i,1 (1), v i,2 (1), …, v i,D (1)):
[0090] v i,j (1) = x r1,j (0) + F(x r2,j (0) - x r3,j (0)) (3)
[0091] where F is the mutation parameter;
[0092] (3) Crossover: Cross the mutant individual v i,j (1) with the individual x i,j (0) in the initialization population X(0) to obtain the trial individual U i (1) = (u i,1 (1), u i,2 (1), …, u i,D (1)):
[0093]
[0094] Among them, CR is the crossover probability.
[0095] (4) Selection: According to the greedy criterion, the trial individual u i (1) Competes with the individual x in the initial population X(0) i (0). If the performance of the trial individual u i (1) is better than that of x i (0), then the trial individual u i (1) replaces x i (0) and enters the initial population X(1). Otherwise, x i (0) enters the initial population X(1):
[0096]
[0097] Among them, f is the fitness function, and the calculation formula is:
[0098]
[0099] Among them, y i is the measured value of the sample component or property in the aforementioned prediction set, is the sample prediction value, and n1 is the number of samples.
[0100] (5) Set the iteration number g = g + 1, and judge whether g is equal to the maximum iteration number IterMax. If it is equal to IterMax, continue to the next step. Otherwise, jump to step (2);
[0101] (6) Output the finally obtained initial population X(g + 1), which is the differential optimization algorithm characteristic wavelength set S2.
[0102] In this embodiment, the mutation parameter F is 0.5, the population size NP is 40, the individual dimension D is 354, the crossover probability CR is 0.7, and the maximum iteration number IterMax is 400. The differential algorithm is used to further screen the wavelength variables in the characteristic wavelength set S1, and a differential optimization algorithm characteristic wavelength set S2 including 203 wavelength variables such as 4828.88, 4809.596, 8566.249, 4859.736, 4906.019, 8350.261, 8373.402, 8408.114, 4832.737, 8377.259, etc. is obtained.
[0103] V. Optimizing Characteristic Wavelengths by Cuckoo Algorithm
[0104] The cuckoo algorithm is used to further screen the 203 wavelength variables in the characteristic wavelength set S2 based on the differential algorithm. By calculating the function values of the existing variables and comparing them with the optimal function of the previous generation, continuous iteration is carried out until the global optimal variables are found, which is the characteristic wavelength set S3 based on the cuckoo algorithm.
[0105] The cuckoo algorithm for optimal selection of characteristic wavelengths includes the following steps:
[0106] (1) Take the near-infrared spectra in the calibration set corresponding to 203 characteristic wavelengths including 4828.88, 4809.596, 8566.249, 4859.736, 4906.019, 8350.261, 8373.402, 8408.114, 4832.737, 8377.259, etc. in the characteristic wavelength set S of the differential optimization algorithm as the initial variables. According to the constraint of the dimension, randomly generate NC nests of the t-th generation (let t = 0) in the 203-dimensional space, Y(0) = (y1(0), y2(0), …, y NC (0));
[0107] (2) The position y k (0) = (y k1 (0), y k2 (0), …, y k203 (0)) of the k-th nest, 1 ≤ k ≤ NC. Evaluate the information of the 0-th generation nest Y(0) according to the fitness function f, retain the optimal nest information, and obtain the information of the (t + 1)-th generation nest according to the update formula:
[0108]
[0109] In the formula is the nest position of the k-th nest in the 0-th generation, is the point-to-point multiplication, α is the step control quantity, which is used to control the search range of the step. Its value follows a normal distribution. At this time, take α = 1, L(λ) is the Levy random search path, which belongs to a random walk. Adopting the Levy flight mechanism, after simplification:
[0110]
[0111] In the formula is the optimal nest information found by the cuckoo at the t-th iteration. u and v follow the standard normal distribution, and β = 1.5.
[0112] (3) Generate a uniformly distributed random number r (r ∈ (0, 1)) and compare it with the maximum discovery probability P. If r < P, discard the nest and replace the old nest through the random walk strategy. After updating, evaluate the nest information and retain the current optimal nest information; if r ≥ P, then Unchanged:
[0113]
[0114] where represent the positions of two random bird nests in the 0th generation;
[0115]
[0116] (4) Set the iteration number t = t + 1, and determine whether t is equal to the maximum iteration number N_IterTotal. If it is equal to N_IterMax, proceed to the next step; otherwise, jump to step (2);
[0117] (5) Output the optimal bird nest information Obtain the characteristic wavelength set S3 based on the cuckoo algorithm.
[0118] In this embodiment, the population size NC is 40, the maximum discovery probability P is 0.25, and the maximum number of iterations N_IterTotal is 500. The characteristic wavelength set S3 based on the cuckoo algorithm includes 95 wavelength variables of 4809.596, 8566.249, 4859.736, 4906.019, 8373.402, 8408.114, 4832.737, 8377.259, 8404.258, 8400.4, 8384.973, 8381.116, 8419.686, 8435.113, 8346.403, 8477.539, 8392.687, 4848.165, 8581.677, 8369.545, 5874.109, 4886.734, 8454.397, 8365.688, 8431.256, 4867.45, 4844.308, 4902.162, 4925.304, 8357.975, 4863.593, 8465.969, 5391.993, 5407.42, 5877.966, 8585.533, 8577.819, 8485.253, 8527.68, 8492.967, 8500.681, 5403.563, 8489.11, 5449.847, 8523.822, 7166.182, 5457.561, 5472.988, 7127.613, 7143.041, 5434.419, 7119.899, 7116.042, 5958.962, 7154.611, 5596.41, 5600.267, 8612.532, 7100.614, 5607.981, 7092.9, 7420.74, 7455.452, 4767.169, 5511.558, 7710.01, 5357.28, 5931.963, 7170.039, 5349.566, 5615.695, 5345.709, 7848.859, 5623.409, 7096.757, 7702.296, 5935.82, 5928.106, 5773.829, 8620.246, 5777.686, 5330.282, 7837.289, 5326.425, 5337.996, 4751.742, 7999.28, 5291.712, 7956.854, 8018.564, 7675.297, 7694.582, 7717.724, 7463.166, 8003.137, which is the characteristic wavelength set S3 based on the cuckoo algorithm.
[0119] VI. Optimizing Characteristic Wavelengths by Successive Projection Algorithm
[0120] The successive projections algorithm (SPA) is used to further screen the 95 wavelength variables in the characteristic wavelength set S3 based on the cuckoo algorithm, and the final wavelength variable set S is obtained.
[0121] The SPA algorithm described in step five belongs to a forward iterative search algorithm, and its purpose is to select wavelengths with the least spectral information redundancy to solve the collinearity problem. The selection steps are as follows:
[0122] (1) When the initial iteration t = 1, any column k of the spectral matrix corresponding to the characteristic wavelength set S3 under the cuckoo algorithm is assigned to x j , denoted as x k(0) , and k(0) is the initial position of the selected variable (j = k(0), 1 ≤ j ≤ m);
[0123] (2) Define the set of remaining column vector positions as s:
[0124]
[0125] (3) Calculate the projections of the remaining column vectors x j (j ∈ s) on the selected vector x k(t-1) respectively.
[0126]
[0127] In the formula represents the transpose matrix of x j , and represents 's inverse matrix.
[0128] (4) Extract the wavelength number k(t) corresponding to the maximum projection value. The calculation formula is:
[0129]
[0130] (5) Take the maximum projection value as the initial value for the next iteration, that is
[0131] (6) Let t = t + 1. When t < H, return to step (2) for loop calculation. When t is equal to the optimal wavelength H, stop the loop and proceed to step (7);
[0132] (7) When the loop terminates, the finally screened wavelength variable combination {k(t), t = 0,..., H - 1} is obtained.
[0133] (8) Since the first variable x k(0)It is randomly selected. Therefore, each column in the spectrum is used as an initial variable, and steps (1) to (6) are iterated. Each time, H variables are selected, and m wavelength variable combinations are obtained from the iteration of the m initial variables. Then, a multiple linear regression analysis model is established for each combination, and the root mean square error of cross-validation (RMSECV) is obtained. The k(0) corresponding to the minimum RMSECV value is the final wavelength variable set S.
[0134] In this embodiment, after the characteristic wavelengths are optimized by the successive projections algorithm, the final wavelength variable set S including 14 wavelength variables of 4925.304, 5958.962, 7956.854, 7127.613, 8454.397, 7702.296, 5935.82, 7420.74, 5357.28, 7116.042, 8373.402, 7154.611, 7463.166, and 7096.757 is obtained.
[0135] V. Result verification
[0136] Figure 1 It shows the positions of the characteristic wavelengths obtained by the above method in the near-infrared spectrum of the original black vinegar solution. It can be found that the number of characteristic wavelengths has decreased significantly compared with that without variable selection, indicating that the method of the present invention can greatly reduce the wavelength variables and screen out the optimal number of wavelength variables.
[0137] Using the near-infrared spectrum data of the calibration set corresponding to the 14 characteristic wavelengths in the final wavelength variable set S, a quantitative analysis model for the concentration of hexamine in the black vinegar solution is constructed, and the correlation coefficient R of the prediction set p 2 and the root mean square error of prediction RMSEP are used as evaluation indicators to compare the performance of the support vector machine regression prediction models under different wavelength selection methods.
[0138] Table 1 Comparison of different variable optimization methods
[0139]
[0140] As can be seen from Table 1, for the hexamine concentration prediction model in the hexamine-acetic acid solution established by the wavelength selection method based on the proposed four-step strategy, its RMSEP is 0.0804, and R p 2 is 0.9987. The performance index is second only to the combination algorithm of the uninformative variable elimination method - differential evolution algorithm - cuckoo search algorithm, and is greatly improved compared with the full band, SPA, and UVE-SPA methods; the number of selected wavelength variables is 14, which is 0.90% of the initial band.
[0141] The specific description above further elaborates on the purpose, technical solution, and beneficial effects of the invention. It should be understood that the above is only a specific embodiment of the present invention and is not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for selecting wavelengths of near-infrared spectra of black vinegar solution based on a four-step strategy comprises the following steps: Step 1, pre-processing the collected near-infrared spectrum of the black vinegar solution to eliminate burrs and deformation caused by temperature and noise during data collection; and using a chemical analysis method to determine the concentration of urotropine corresponding to the collected near-infrared spectrum curve of the black vinegar solution; Step 2: Use the uninformative variable elimination method to select characteristic wavelengths from the preprocessed spectrum to obtain a characteristic wavelength set S1; Step 3: Use the differential algorithm to further screen the wavelength variables in the characteristic wavelength set S1, and obtain the characteristic wavelength set S2 based on the differential algorithm after initialization, mutation, crossover and selection; Step 4: Using the cuckoo algorithm, further screen the wavelength variables in the characteristic wavelength set S2 based on the difference algorithm to obtain the characteristic wavelength set S3 based on the cuckoo algorithm; Step 5: Use the continuous projection algorithm SPA to further screen the wavelength variables in the characteristic wavelength set S3 under the cuckoo algorithm to obtain the final wavelength variable set S, that is, to achieve the near-infrared spectrum wavelength selection of the black vinegar solution based on the four-step strategy selection.
2. The near-infrared spectral wavelength selection method of the black vinegar solution selected based on the four-step strategy according to claim 1, wherein: The method further includes step 6, establishing a near-infrared quantitative analysis model of urotropine concentration in black vinegar solution according to the wavelength variable set S obtained in step 4, reducing the complexity of the model and improving the detection efficiency and accuracy of the model.
3. The method for selecting near-infrared spectral wavelengths of black vinegar solution based on the four-step strategy as claimed in claim 1 or 2, characterized in that: The characteristic wavelength selection by the non-information variable elimination method described in step 2 includes the following steps: (1) The spectrum matrix X (n×m) composed of the pre-processed near-infrared spectrum and the urotropine concentration corresponding to the near-infrared spectrum curve of the black vinegar solution collected by the chemical analysis method are used to form a concentration matrix Y (n×1), where m represents the total number of spectral bands; a noise matrix R (n×m) is randomly generated, and the spectrum matrix X and the noise matrix R are combined to form a mixed matrix XR (n×2m), wherein the first m columns of the mixed matrix are the spectrum matrix X and the last m columns are the noise matrix R; (2) performing PLS regression on the mixing matrix XR and the concentration matrix Y, removing one sample for interactive verification each time, obtaining a regression coefficient vector b, and finally obtaining a regression coefficient matrix B (n×2m); (3) Calculate the standard deviation S(b) and the mean value mean(b) of the regression coefficient matrix B by column, and calculate the coefficient C of each variable index j = mean(b j ) / S(b j ), where j = 1, 2, …, 2m; (4) In the interval [m + 1, 2m], take the maximum absolute value C of the absolute value of the variable index coefficient C max = max(abs(C)), where abs(C) represents the absolute value of the variable index coefficient C; (5) Remove the variable data corresponding to Cj < C in the spectral matrix X in the interval [1, m], and form the characteristic wavelength set S from the remaining variables max 1。 4. The near-infrared spectral wavelength selection method of the black vinegar solution selected based on the four-step strategy according to claim 3, characterized in that: Step 3: The differential algorithm for characteristic wavelength optimization includes the following steps: (1) Initialization: The initial population X(g) when the evolutionary generation number is g needs to be calculated in combination with the upper and lower limits of the decision space: where x i,j (g) is the i-th and j-th dimensional individual in the initial population X(g) when the generation number of evolution is g, are the lower and upper limits of the j-th dimension respectively, rand(0,1) represents a random number in the interval [0,1], NP is the population size, and D is the individual dimension; (2) Mutation: Randomly select three different individuals from the initial population X(g) when the evolutionary generation is g, denoted as x r1 (g), x r2 (g) and x r3 (g), where r1, r2, and r3 are random numbers in the interval [1, NP]. Then generate the mutant individual V i (g + 1) = (v i,1 (g + 1), v i,2 (g + 1), …, v i,D (g + 1)): v i,j (g + 1) = x r1,j (g) + F(x r2,j (g) - x r3,j (g)) (3) Where F is the variation parameter; (3) Crossover: Cross the mutant individual v i,j (g + 1) with the individual x i,j (g) in the initial population X(g) when the evolutionary generation is g to obtain the trial individual U i (g + 1) = (u i,1 (g + 1), u i,2 (g + 1), …, u i,D (g + 1)): Where CR is the crossover probability; (4) Selection: Select the trial individual u according to the greedy criterion i (g + 1) to compete with the individual x in the initial population X(g) when the evolutionary generation is g i (g). If the performance of the trial individual u i (g + 1) is better than that of x i (g), then the trial individual u i (g + 1) replaces x i (g) and enters the initial population X(g + 1) when the evolutionary generation is g + 1. Otherwise, x i (g) enters the initial population X(g + 1) when the evolutionary generation is g + 1: Where f is the fitness function; (5) Set the number of iterations g = g + 1, and determine whether g is equal to the maximum number of iterations IterMax. If it is equal to IterMax, proceed to the next step; otherwise, jump to step (2); (6) Output the finally obtained initial population X(g + 1), which is the characteristic wavelength set S of the differential optimization algorithm 2。 5. The method for selecting near-infrared spectral wavelengths of black vinegar solution based on the four-step strategy as claimed in claim 4, wherein: Step 4: The cuckoo algorithm for optimizing characteristic wavelengths includes the following steps: (1) Using the spectral data in the spectral matrix X corresponding to the characteristic wavelength set S2 of the differential optimization algorithm as the initial variable, according to the dimensional constraint, randomly generate a population of NC t-generation bird nests Y(t) = (y1(t), y2(t), ..., yNC(t)) in the dimensional space dim; (2) For the position y of the k-th bird nest k (t) = (y k1 (t), y k2 (t), …, y kdim (t)), 1 ≤ k ≤ NC, evaluate the information of the t-th generation bird nest Y(t) according to the fitness function f, retain the information of the optimal bird nest, and obtain the information of the (t + 1)-th generation bird nest according to the update formula: In the formula is the nest position of the k-th bird nest in the t-th generation, is the point-to-point multiplication, α is the step size control quantity, which is used to control the search range of the step size. Its value follows a normal distribution. At this time, α = 1, L(λ) is the Levy random search path, which belongs to random walk and adopts the Levy flight mechanism. After simplification: where is the optimal nest information found by the cuckoo at the t-th iteration. u and v follow the standard normal distribution, and β = 1.5; (3) Generate a uniformly distributed random number \(r\) and compare it with the maximum discovery probability \(P\), where \(r\in(0,1)\); if \(r < P\), discard the nest and replace the old nest through a random walk strategy. After the update, evaluate the nest information and retain the current optimal nest information; If r ≥ P, then Unchanged: Wherein represents the positions of two random bird nests in the t-th generation; (4) Set the iteration number \(t=t + 1\), and determine whether \(t\) is equal to the maximum iteration number \(N\_IterTotal\). If it is equal to \(N\_IterMax\), proceed to the next step; otherwise, jump to step (2); (5) Output the optimal bird nest information Obtain the set S3 of characteristic wavelengths under the cuckoo algorithm.
6. The near-infrared spectral wavelength selection method of the black vinegar solution selected based on the four-step strategy according to claim 5, wherein: (2) The SPA algorithm described in step five belongs to a forward iterative search algorithm, and its purpose is to select wavelengths with the least spectral information redundancy to solve the collinearity problem. The selection steps are as follows: (1) When the initial iteration \(l = 1\), assign the \(k\)-th column of the spectral matrix \(X\) corresponding to the set of characteristic wavelengths \(S3\) under the cuckoo algorithm to \(x\). j , denoted as \(x\). k(0) , \(k(0)\) is the initial position of the selected variable, \(j = k(0)\), \(1\leq j\leq m\); (2) Define the set of remaining column vector positions as \(s\): (3) Calculate the remaining column vectors x respectively j (j ∈ s) For the selected vector x k(l-1) Projection of where represents the transpose matrix of x j , and represents the inverse matrix of (4) Extract the wavelength number \(k(l)\) corresponding to the maximum projection value, and the calculation formula is: (5) Use the maximum projection value as the initial value for the next iteration, i.e., j ∈ s; (6) Let \(l=l + 1\). When \(l < H\), return to step (2) for loop calculation. When \(l\) is equal to the optimal wavelength \(H\), stop the loop and proceed to step (7); (7) When the loop terminates, obtain the finally selected wavelength variable combination \(\{k(t),t = 0,1,\cdots,H - 1\}\); (8) Since the first variable \(x\) of the iteration k(0) is randomly selected, each column in the spectrum is taken as an initial variable, and steps (1) to (6) are iterated. Each time \(H\) variables are selected in the iteration, and \(m\) wavelength variable combinations selected by the iteration of \(m\) initial variables are obtained. Then, a multiple linear regression analysis model is established for each combination, and the root mean square error of cross-validation (RMSECV) is obtained. The \(k(0)\) corresponding to the smallest RMSECV value is the final wavelength variable set \(S\).
7. The near-infrared spectral wavelength selection method for black vinegar solution selected based on the four-step strategy according to claim 6, characterized in that: (7) The fitness function is set as where y i is the measured value of the sample component or property, is the predicted value of the sample, and n is the number of samples.
Citation Information
Patent Citations
Method for selecting near infrared spectrum characteristic wavelength of black vinegar solution based on combinatorial algorithm
CN116525018A