Spectral feature wavelength selection method based on improved simulated annealing algorithm
By introducing the local optimal band combination search of the Boruta algorithm into the simulated annealing algorithm, combined with global and local optimization, the problem of low accuracy of the traditional simulated annealing algorithm in near-infrared spectrum analysis is solved, and more efficient characteristic band combinations and models are achieved. modeling effect.
Patent Information
- Application Number
- CN202211434654.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-16
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-11-16
AI Technical Summary
The traditional simulated annealing algorithm relies on global search in near-infrared spectrum analysis, resulting in low accuracy and difficulty in finding accurate characteristic band combinations in high-dimensional data, resulting in low model modeling accuracy.
The Boruta algorithm is combined with the local optimal band combination search, combined with global and local search optimization, and the band combination is optimized through the Metropolis criterion and the temperature attenuation function to ensure that the accuracy of the characteristic bands is improved with a smaller number of bands.
It improves the accuracy and efficiency of band combination, can meet modeling requirements with a smaller number of bands, and overcomes the low accuracy problem of traditional simulated annealing algorithms.
Smart Images

Figure CN115728267B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of spectrum analysis, and in particular to a spectrum characteristic wavelength selection method based on an improved simulated annealing algorithm. Background Art
[0002] Near-infrared spectroscopy is a rapid, non-destructive, low-cost, pollution-free analytical monitoring method that can perform qualitative and quantitative analysis on the quality, type, and composition of substances.
[0003] Generally speaking, the spectra in the near-infrared region are complex, overlapping, and large in data volume, making it difficult to build a prediction model using all the data collected by the spectrometer. It is particularly important to accurately extract the characteristic information we want from the "high-dimensional" spectral information for modeling.
[0004] The simulated annealing algorithm is widely used in feature extraction of near-infrared spectra due to its "global search optimization" feature. The simulated annealing algorithm (SA) is a random combination optimization method developed in the 1980s. The algorithm is derived from the principle of solid annealing. The solid is heated to a sufficiently high temperature, and then slowly cooled to reach equilibrium at each temperature. Finally, it reaches the ground state at room temperature, and the internal energy is reduced to a minimum. According to the Metropolis criterion, the probability that a particle tends to equilibrium at temperature T is exp[-ΔE / (kT)], where E is the internal energy at temperature T, ΔE is its change, and k is the Boltzmann constant.
[0005] Use solid annealing to simulate combinatorial optimization problems. First, determine the initial temperature, randomly select an initial state and examine the objective function value of the state; then, in the neighborhood of the current solution, select a non-local optimal solution with a certain probability, and repeat this solution without falling into the local optimal solution. The algorithm is determined by a control parameter T. After a large number of solution transformations, the relative optimal solution of the optimization problem when the control parameter T is given can be obtained. Then slowly reduce the value of the control parameter T and repeat the above iterative process. When T gradually decreases and approaches 0, the global optimal solution with the problem is finally obtained.
[0006] Theoretically, using the simulated annealing algorithm, as long as the initial temperature is high enough and the cooling process is slow enough, the best characteristic band combination can be found. However, the near-infrared spectrum has a high dimension and a huge number of combinations. We cannot increase the initial temperature indefinitely and slow down the cooling process, which will cause the algorithm to run slowly. In some data sets, there are too many preferred bands, which brings inconvenience to model building and is not suitable for practical applications. In many cases, the band combination screened by the conventional simulated annealing algorithm is difficult to meet our requirements.
[0007] An important reason for the low accuracy of the traditional simulated annealing algorithm is that in order to improve the efficiency of searching for the global optimal band combination, the original band combination is often randomly modified to generate a new combination and then the performance of the objective function is judged. The advantage of this method of generating a new band combination is that it can quickly jump out of the local optimum and efficiently search for the global optimal band combination. The disadvantage is that during the iterative search process, the local optimal band combination in the area may not have reached the "real local optimum", making its accuracy low, and resulting in low modeling accuracy of the "global optimal band combination" screened and retained on this basis. Summary of the invention
[0008] In view of the above problems, the purpose of the present invention is to propose a spectral feature wavelength selection method based on an improved simulated annealing algorithm. In the process of finding the global optimal band combination by the traditional simulated annealing algorithm, a local optimal band combination search process based on the Boruta algorithm is introduced, and the global and local optimization operations are combined, thereby retaining the advantage of the traditional simulated annealing algorithm in efficiently searching for the global optimal band combination, overcoming the disadvantage of low precision caused by relying solely on global optimization, improving the optimization accuracy and effect, and being able to ensure that the target requirements are met while using a smaller number of bands.
[0009] To achieve the above object, the present invention adopts the following specific technical solutions:
[0010] The present invention provides a spectrum characteristic wavelength selection method based on an improved simulated annealing algorithm, comprising the following steps:
[0011] S1, initialization temperature T = T max ; Initialize the number of iterations L = 0;
[0012] Randomly select n bands from all bands as the initial band combination x, and calculate the objective function value f(x) of the initial band combination x;
[0013] The optimal band combination x″ is obtained by searching the local optimal band combination based on the Boruta algorithm for the initial band combination x, and the optimal objective function value f(x″) is calculated;
[0014] Let x a =x, update the global optimal band combination x a , and calculate the global optimal objective function value f(x a );
[0015] S2, remove the initial band combination x from all bands and randomly select m bands from the remaining bands, replace them with the randomly selected bands in the initial band combination x, obtain a secondary band combination x', and calculate the secondary objective function value f(x');
[0016] S3. Determine whether to accept the update of \(x = x'\) according to the comparison result of \(f(x)\) and \(f(x')\) using the Metropolis acceptance criterion for new solutions;
[0017] When \(f(x)\lt f(x')\), definitely accept the update of \(x = x'\); when \(f(x)\gt f(x')\), randomly generate a value \(A\), \(A\in[0 - 1]\). If then accept the update of \(x = x'\), otherwise do not accept;
[0018] The Metropoils criterion is: The probability calculation formula for particles to tend to equilibrium at temperature \(T\) is
[0019] \(P=\exp(-\Delta E / (kT))\)
[0020] where
[0021] \(E\) is the internal energy of the particle when the temperature is \(T\), \(\Delta E\) is the change in the internal energy of the particle, and \(K\) is the Boltzmann constant;
[0022] S4. When the secondary objective function value \(f(x')\gt\) the global optimal objective function value \(f(x\) a ) :
[0023] Let \(x\) a \(= x'\), and perform a local optimal band combination search based on the Boruta algorithm on the secondary band combination \(x'\) to obtain the local optimal band combination \(x\) b and the local optimal objective function value \(f(x\) b ) ;
[0024] S5. If the local optimal objective function value \(f(x\) b ) \gt the optimal objective function value \(f(x'')\) :
[0025] Then let \(x'' = x\) b , and the iteration number \(L = L + 1\);
[0026] S6. Repeat steps S2 - S5 until the iteration number \(L\) is equal to the maximum Markov chain length \(L\) m at which time, reduce the cooling temperature \(T\) according to the temperature decay function;
[0027] S7. Repeat steps S2 - S6 until when the temperature \(T\) is less than or equal to the end temperature \(T\) min to obtain the optimal band combination \(x''\) and the optimal objective function value \(f(x'')\);
[0028] S8. Let the number of band combinations \(n = n + 1\), repeat steps S1 - S7, compare the obtained optimal objective function values \(f(x'')\), and screen out the optimal band combinations \(x''\) that meet the requirements.
[0029] Preferably, in step S4, the local optimal band combination \(x\)b The selection process is as follows:
[0030] S41. Obtain the importance scores of the relevant target dependent variables in the secondary band combination x' through the Boruta algorithm, and delete s weaker or unimportant bands according to the importance scores, and retain the important feature bands;
[0031] S42. Remove the secondary band combination x' from the full band and randomly select s bands from the remaining bands, and combine them with the important feature bands retained in step S41 to form the locally optimal band combination x b , and calculate the locally optimal objective function value f(x b );
[0032] S43. Repeat step S42 for L b times, and finally retain the locally optimal objective function value f(x b ) and the locally optimal band combination x b .
[0033] Preferably, in the actual operation process of step S43:
[0034] When the value of s is 0;
[0035] Or when the secondary objective function value f(x') is better than the objective function values of all band combinations generated through L b iterations;
[0036] If any of the above two cases holds, the secondary band combination x' remains unchanged.
[0037] Preferably, it further includes a preprocessing step S0: preprocess the near-infrared spectral data;
[0038] The preprocessing process mainly includes: multiplicative scatter correction, filtering and denoising, absorbance or reflectance calculation, and division of the training set and the validation set.
[0039] Preferably, the temperature decay function is: T k+1 = kT k ;
[0040] where k is the temperature decay coefficient.
[0041] Preferably, the value of m is < the value of n.
[0042] Compared with the existing technology, the present invention combines the global optimal band combination search with the local optimal band combination search, overcoming the shortcoming of the traditional annealing algorithm that relies solely on global search and results in low precision. The addition of the Boruta algorithm enables the local search to ensure maximum efficiency and optimization purpose. The algorithm can use a smaller number of bands to find a more accurate optimal band combination to meet the modeling requirements under the premise of conventional initial temperature and cooling rate settings. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flow chart of a method for selecting a spectral characteristic wavelength based on an improved simulated annealing algorithm provided according to an embodiment of the present invention.
[0044] Figure 2 It is a flowchart of a method for selecting a spectral characteristic wavelength based on an improved simulated annealing algorithm provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0045] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the following description, the same modules are represented by the same reference numerals. In the case of the same reference numerals, their names and functions are also the same. Therefore, the detailed description thereof will not be repeated.
[0046] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and do not constitute a limitation of the present invention.
[0047] Figure 1 A schematic flow chart of a method for selecting a spectral characteristic wavelength based on an improved simulated annealing algorithm provided according to an embodiment of the present invention is shown.
[0048] Figure 2 A flowchart of a method for selecting a spectral characteristic wavelength based on an improved simulated annealing algorithm provided according to an embodiment of the present invention is shown.
[0049] like Figure 1-2 As shown, the spectral characteristic wavelength selection method based on the improved simulated annealing algorithm provided in the embodiment of the present invention comprises the following steps:
[0050] Preprocessing step S0: preprocessing near infrared spectroscopy data;
[0051] The preprocessing process mainly includes: multivariate scattering correction (MSC), filtering and denoising, absorbance or reflectance calculation, and division of training set and validation set.
[0052] The main improvement of the present invention to the traditional annealing algorithm is to add a local optimal band combination search process based on the Boruta algorithm. The basic idea of the Boruta algorithm is to evaluate the importance of each feature variable through a loop method. By copying the original feature set, random shadows (shadow features) are constructed for each eigenvalue by randomly mixing. The final sample data set of the model is a new feature set formed by merging the original features and the shadow features. In each iteration of the RF algorithm, the importance scores of the original features and the shadow features are compared to screen out important feature components.
[0053] S1. Initialize the temperature T = T max ; Initialize the iteration number L = 0;
[0054] Randomly select n bands from the full band as the initial band combination x, and calculate the objective function value f(x) of the initial band combination x;
[0055] Use the local optimal band combination search based on the Boruta algorithm for the initial band combination x to obtain the optimal band combination x″, and calculate the optimal objective function value f(x″);
[0056] Let x a = x, update the global optimal band combination x for the first time a , and the corresponding objective function value f(x a ) is the global optimal objective function value.
[0057] S2. Remove the initial band combination x from the full band and randomly select m (m < n) bands from the remaining bands, replace them with randomly selected bands in the initial band combination x to obtain the secondary band combination x', and calculate the secondary objective function value f(x');
[0058] S3. According to the comparison result of f(x) and f(x'), use the Metropolis acceptance new solution criterion to judge whether to accept the update of x = x';
[0059] When f(x) < f(x'), the update of x = x' must be accepted; when f(x) > f(x'), a random value A is generated, A ∈ [0 - 1], if then accept the update of x = x', otherwise do not accept;
[0060] The Metropoils criterion is: The probability calculation formula for the particles to tend to equilibrium at temperature T is
[0061] P = exp(-ΔE / (kT))
[0062] Where
[0063] E is the internal energy of the particle when the temperature is T, ΔE is the change in the internal energy of the particle, and K is the Boltzmann constant.
[0064] Use solid annealing to simulate the combinatorial optimization problem, first determine the initial temperature T max , randomly select an initial state and examine the objective function under this state, then in the neighborhood of the current solution, if the objective function of the new solution is better, accept it, otherwise select a non-local optimal solution with a certain probability according to the Metropoils criterion, and repeat this solution so as not to fall into the local optimum.
[0065] S4, when the secondary objective function value f(x')>global optimal objective function value f(x a )hour:
[0066] Then let x a = x', and perform the local optimal band combination search based on the Boruta algorithm on the secondary band combination x' to obtain the local optimal band combination x b and the local optimal objective function value f(x b ).
[0067] Local optimal band combination x b The selection process is:
[0068] S41. Select a secondary band combination x' in the full-band spectral data, obtain the importance score of the target dependent variable in the secondary band combination x' through the Boruta algorithm, and delete s weaker or unimportant bands according to the importance score, and retain the important feature bands.
[0069] S42, remove the secondary band combination x' from the above all bands and randomly select s bands from the remaining bands, and combine them with the important characteristic bands retained in step S41 to form a new band combination x b , and calculate its objective function value f(x b ).
[0070] S43, repeat step S42 b times, and finally retain the local optimal objective function value f(x b ) and the local optimal band combination x b .
[0071] At this time x b That is, the local optimal band combination of the secondary band combination x', f(x b ) is its corresponding objective function value.
[0072] The objective function is used to judge the quality of the current band combination x during the iteration process. The calculation formula of the objective function value f(x) is:
[0073]
[0074] Where t(x) is the mean square error between the predicted value and the true value of the sample obtained by using the optimal band combination and performing multilayer perceptron regression cross-validation on the training set data that we have divided in advance. The larger the value of the objective function f(x), the better.
[0075] L b The maximum number of iterations for searching the local optimal band combination based on the Boruta algorithm.
[0076] In the actual operation process:
[0077] When the s value is 0;
[0078] Or when the objective function value of the secondary band combination x' may be better than that of L b The objective function values of all band combinations generated by the iteration process are:
[0079] If either of these two situations holds true, the local optimal solution of the secondary band combination x' is still itself.
[0080] S5. If the local optimal objective function value f(x b )>Optimal objective function value f(x″):
[0081] Then let x″=x b , the number of iterations L = L + 1;
[0082] S6. Repeat steps S2-S5 until the number of iterations L is equal to the maximum Markov chain length L m When , the cooling temperature T is reduced according to the temperature decay function.
[0083] The temperature decay function is: T k+1 =kT k ;
[0084] Among them, k is the temperature attenuation coefficient, which controls the cooling rate of the solid annealing process, that is, the decay rate of temperature T.
[0085] S7, repeat steps S2-S6 until the temperature T is less than or equal to the end temperature T min When , the optimal band combination x″ and the optimal objective function value f(x″) are obtained.
[0086] S8. Let the number of band combinations n=n+1, repeat steps S1-S7, compare the extracted multiple optimal objective function values f(x″), and screen out the optimal band combination x″ that meets the requirements.
[0087] Using the characteristic band combination x″ with the best objective function, neural network regression modeling is performed on the full-spectrum near-infrared spectral data set to achieve high-precision detection using spectral technology.
[0088] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
[0089] The above specific implementations of the present invention do not constitute a limitation on the protection scope of the present invention. Any other corresponding changes and modifications made based on the technical concept of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A spectrum characteristic wavelength selection method based on an improved simulated annealing algorithm, characterized in that: The following steps are involved: S1, initialization temperature T = T max ; Initialize the number of iterations L = 0; Randomly select n bands from all bands as the initial band combination x, and calculate the objective function value f(x) of the initial band combination x; The optimal band combination x' is obtained by searching the local optimal band combination based on the Boruta algorithm for the initial band combination x, and the optimal objective function value f(x') is calculated; Let x a =x, update the global optimal band combination x a , and calculate the global optimal objective function value f(x a ); S2, removing the initial band combination x from the full bands and randomly selecting m bands from the remaining bands, replacing them with the randomly selected bands from the initial band combination x, to obtain a secondary band combination x', and calculating a secondary objective function value f(x'); S3, based on the comparison result of f(x) and f(x'), use the Metropolis acceptance criterion to determine whether to accept the update of x = x'; When f(x) < f(x'), the update of x = x' must be accepted; when f(x) > f(x'), a random value A is generated, where A ∈ [0, 1]. If then the update of x = x' is accepted, otherwise it is not accepted. The Metropoils criterion is: The probability formula for the particle to reach equilibrium at temperature T is: P = exp(-ΔE / (kT)) in, E is the internal energy of the particle when the temperature is T, ΔE is the change in the internal energy of the particle, and K is the Boltzmann constant; S4, when the secondary objective function value f(x')> the global optimal objective function value f(x a )hour: Let x a = x', and perform a local optimal band combination search based on the Boruta algorithm on the secondary band combination x' to obtain the local optimal band combination x b and the local optimal objective function value f(x b ); S5. If the local optimal objective function value f(x b )>The optimal objective function value f(x"): Then let x'=x b , the number of iterations L = L + 1; S6. Repeat steps S2-S5 until the number of iterations L is equal to the maximum Markov chain length L. m When , the cooling temperature T is reduced according to the temperature decay function; S7, repeat the steps S2-S6 until the temperature T is less than or equal to the end temperature T min , the optimal band combination x'' and the optimal objective function value f(x'') are obtained; S8. Let the number of band combinations n=n+1, repeat steps S1-S7, compare the extracted optimal objective function values f(x"), and screen out the optimal band combination x" that meets the requirements.
2. The spectral characteristic wavelength selection method based on the improved simulated annealing algorithm according to claim 1 is characterized in that: In step S4, the local optimal band combination x b The selection process is: S41, obtaining the importance score of the target dependent variable in the secondary band combination x' by using the Boruta algorithm, and deleting s weaker or unimportant bands according to the importance score, and retaining important feature bands; S42, removing the secondary band combination x' from the full band and randomly selecting s bands from the remaining bands, and combining them with the important characteristic bands retained in step S41 to form the local optimal band combination x b , and calculate the local optimal objective function value f(x b ); S43, repeat step S42 b times, and finally retain the local optimal objective function value f(x b ) and the local optimal band combination x b .
3. The spectral characteristic wavelength selection method based on the improved simulated annealing algorithm according to claim 2 is characterized in that: In the actual operation process of step S43: When the s value is 0; Or when the secondary objective function value f(x') is better than the value obtained by L b The objective function values of all band combinations generated by the iteration process are: If any of the above two situations is true, the secondary band combination x' remains unchanged.
4. The spectral characteristic wavelength selection method based on the improved simulated annealing algorithm according to claim 3 is characterized in that: It also includes a preprocessing step S0: preprocessing the near infrared spectrum data; The preprocessing process mainly includes: multivariate scattering correction, filtering and denoising, absorbance or reflectance calculation, and division of training set and validation set.
5. The spectral characteristic wavelength selection method based on improved simulated annealing algorithm according to claim 4 is characterized in that: The temperature decay function is: T k+1 =kT k ; Where k is the temperature attenuation coefficient.
6. The spectrum characteristic wavelength selection method based on improved simulated annealing algorithm according to claim 5 is characterized in that: The m value<the n value.
