Prediction method of hexamethylenetetramine concentration in black vinegar solution with renewal mechanism
The concentration of hexamethylenetetramine in black vinegar solution was predicted by using the incremental random forest regression model, which solved the low efficiency problem of the PLS model in the case of new data and achieved efficient and accurate prediction of the concentration of black vinegar solution.
Patent Information
- Application Number
- CN202211540811.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-02
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2042-12-02
AI Technical Summary
When the existing PLS model faces the continuous increase of black vinegar solution training data during the HMX generation process, it needs to abandon the existing model and retrain it, resulting in low modeling efficiency, high space consumption, and long training time, making it difficult to apply to real-time prediction scenarios.
An incremental random forest regression model was used to predict the concentration of hexamethylenetetramine in black vinegar solution using near-infrared spectral data. The model was updated with new samples, including second-order derivatives, wavelet transform, and minimum angle regression algorithm for dimensionality reduction. The random forest regression model was combined to divide the training set and test set and construct a decision tree.
The model's training efficiency and prediction accuracy are improved, and it can gradually adapt to new data based on the original learning structure, thereby improving the model's adaptability and prediction performance.
Smart Images

Figure CN116011572B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the fields of explosive technology and near-infrared spectroscopy quantitative analysis, and in particular relates to a method for predicting the concentration of hexamethylenetetramine in a black vinegar solution with an updating mechanism. Background Art
[0002] Hexamethylenetetramine-acetic acid (black vinegar) solution is an important raw material for the production of octogen (HMX). The concentration of hexamethylenetetramine has a significant impact on product quality and production process. Rapid detection of hexamethylenetetramine concentration during the production process is beneficial to enhancing the stability of the raw material feed ratio and producing qualified products with high yield and excellent quality.
[0003] Currently, process analysis primarily uses the Partial Least Squares (PLS) method from chemometrics to establish analytical models. However, PLS models rely on batch learning. Given that the training data for the black vinegar solution in the HMX production process is not fully available all at once but is continually updated, new models must be established through repeated learning of historical data. This results in low modeling efficiency, high space consumption, and long training times, making it difficult to apply to real-time prediction scenarios that require rapid response to new data additions. Summary of the Invention
[0004] The present invention aims to provide a method for predicting the hexamethylenetetramine concentration in a black vinegar solution with an updating mechanism. The method can update the model based on the originally trained model by utilizing near-infrared spectral data of a new sample of the black vinegar solution and its corresponding concentration data, thereby improving the training efficiency and prediction accuracy of the model. This solves the problem that, when an existing PLS model is used for learning newly added data, it is necessary to abandon the existing model, retrain all the data, and establish a new model.
[0005] To achieve the above object, the present invention adopts the following technical solution: A method for predicting the concentration of methenamine in black vinegar solution with an updating mechanism, comprising the following steps:
[0006] Step 1, collecting near-infrared spectral data of the black vinegar solution with the measured urotropine concentration;
[0007] Step 2: Obtain the hexamethylenetetramine concentration in the solution corresponding to the near-infrared spectral data through an incremental random forest regression model. Preferably, the incremental random forest regression model described in step 2 is established by the following method:
[0008] Step 2-1, collecting n near-infrared spectral data of urotropine-acetic acid solutions with different urotropine concentrations and their corresponding urotropine concentration data to form an original near-infrared spectral data set and an original concentration data set;
[0009] Step 2-2, performing second-order derivative and wavelet transform processing on the data in the original near-infrared spectral data set to obtain pre-processed near-infrared spectral data;
[0010] Step 2-3, performing least angle regression (LAR) dimensionality reduction on the pre-processed near-infrared spectral data to obtain reduced-dimensional near-infrared spectral data;
[0011] Step 2-4, dividing the reduced dimensionality near-infrared spectral data and the data in the original concentration data set into training set spectral data, training set concentration data, test set spectral data and test set concentration data according to the principle of the spxy algorithm;
[0012] Step 2-5: Input the training set spectral data and the training set concentration data into the random forest regression model for training, find the optimal number of regression decision trees, and obtain the random forest regression initial model. Then, fit and predict the test set spectral data to obtain the test set concentration prediction data; compare the test set concentration prediction data with the test set concentration data, and use the correlation coefficient R 2 , mean square error MSE for evaluation;
[0013] Step 2-6: When the kth black vinegar solution near-infrared spectrum data is obtained, the second-order derivative, wavelet transform and minimum angle regression algorithm are performed on the data to reduce the dimension, and the corresponding prediction value is obtained by the random forest regression initial model, wherein k=n+1, n+2, ...;
[0014] Step 2-7, calculate the relative error between the predicted value and the true value; if the absolute value of the relative error is less than or equal to the threshold δ, set k = k + 1 and go to step 2-6; otherwise, input the k-th black vinegar solution near-infrared spectrum data and its corresponding concentration true value into the random forest regression initial model, and according to the constructed random forest, store it in the subspace of the corresponding regression decision tree and mark it, and then determine whether to split, so as to complete the update of the regression decision tree model, and then set k = k + 1 and go to step 2-6 until the final regression decision tree model is obtained, that is, the incremental random forest regression model is obtained.
[0015] In steps 2-3 of the present invention, the core of the minimum angle regression algorithm is to decompose the regression target vector into a linear combination of several groups of feature vectors in sequence, and finally minimize the residual vector that is linearly independent of all features. LAR dimensionality reduction includes the following steps:
[0016] (1) performing standardization processing on the pre-processed near infrared spectroscopy data;
[0017] (2) The initial regression residual vector r is set to the central value of the data in the original concentration dataset, that is, Where y is the data in the original concentration data set, is the mean vector of y, and the parameters β1, β2, ..., β in the regression model are set m is 0, where m represents the near-infrared spectral data after normalization in step (1);
[0018] (3) Find the variable a that has the greatest correlation with r i ;
[0019] (4) Set variable a i The corresponding coefficient β i From 0 to the least squares coefficient i , r>, where <,> represents the inner product, until the new variable a l The residual correlation of is greater than that of variable a i The residual of
[0020] (5) Set variable a i and a l The corresponding coefficient β i and β l , proceed and update along the direction of the least squares estimate of the new variable until a new variable is selected according to the above rules;
[0021] (6) Repeat steps (3) to (5) until all variables are selected and the final estimate is exactly the solution of the least squares method; the variables are selected in order of importance to the regression through an iterative algorithm, and the optimal solution usually discards some irrelevant or unimportant variables. According to actual use requirements, the top k variables are selected to obtain the near-infrared spectral data after dimensionality reduction.
[0022] In steps 2-4 of the above method, the spxy algorithm includes the following steps:
[0023] 1) Take two samples (named p and q) from the reduced-dimensional near-infrared spectral data and the data in the original concentration dataset, and calculate the distance between the (p, q) samples to the reduced-dimensional near-infrared spectral data x and the data y in the original concentration dataset, respectively. The calculation formula is:
[0024]
[0025]
[0026] Where d is the distance between samples, and m is the number of wavelength points in the near-infrared spectrum.
[0027] 2) Give equal importance to the distance between the reduced dimension near-infrared spectral data x and the data y in the original concentration data set, that is, perform normalization processing, and the normalized distance d xy for:
[0028]
[0029] 3) When selecting, first select the sample pair (p, q) with the largest normalized distance to enter the training set. In each iteration, select the samples with the largest and smallest normalized distances relative to any selected samples to enter the training set. Repeat the process until the number of training sets is met, and the rest will enter the test set.
[0030] In the aforementioned method for predicting the concentration of hexamethylenetetramine in black vinegar solution with an updating mechanism, the construction of the incremental random forest regression model described in steps 2-7 includes the following steps:
[0031] a. Combine the training set spectral data and the training set concentration data into a sample set, and use the bootstrap method to randomly sample the sample set with replacement to generate h training sets, denoted as θ1, θ2, ..., θ h ;
[0032] b. Assume that the subspace corresponding to the training set θ1 is R, and the subspace R is divided into two groups according to the threshold value. Split into R l and R r The two parts are divided into two parts until they cannot be further divided, and the regression decision tree model corresponding to the training set θ1 is constructed;
[0033] The subspace R segmentation rule is:
[0034]
[0035]
[0036] Where x is the spectral data in the training set θ1.
[0037] For the segmentation problem, there exists an optimal solution such that the minimum function Minimum:
[0038]
[0039]
[0040]
[0041] Where y is the training set concentration data in the training set θ1, It is in R l and R r The mean of the space, |R| is the number of sample points in subspace R, n r and n l Corresponding to R l and R r The number of sample points in the space.
[0042] According to the above method, R l and R r As the parent node, continue to split until the number of samples in the parent node is less than the set threshold S, and set the current parent node as a leaf node. Each leaf node stores the mean of the training samples that reach this position. After the above splitting, u parent nodes R1, R2, ..., R u , and has a fixed output value in each parent node space (the average value of the output variable y of all samples in the current parent node space), then the regression decision tree model corresponding to the training set θ1 can be expressed as:
[0043]
[0044] Where I is a logical value, expressed as:
[0045]
[0046] c. For the training set θ2, θ3, ..., θ h Repeat step b until h regression decision trees are generated and each tree is grown to the maximum extent;
[0047] d. Combine h regression decision trees into a random forest and establish a function for the random forest regression initial model
[0048]
[0049] e. After the near-infrared spectral data of the new sample undergoes dimensionality reduction processing using the second-order derivative, wavelet transform, and minimum angle regression algorithm, the corresponding predicted value is obtained through the random forest regression initial model. When the relative error between the predicted value and the true value is greater than the threshold δ, it is defined as a training sample s;
[0050] f. The training samples s are respectively selected from the training set θ1, θ2, ..., θ h Arrive at the subspace according to the splitting rule and store it in the corresponding subspace, then execute step b to obtain h incremental regression decision trees;
[0051] g. Combine h incremental regression decision trees into a random forest to obtain the incremental random forest regression model.
[0052] Beneficial effects
[0053] 1. The method of the present invention can predict the concentration value of hexamethylenetetramine from the near-infrared spectral data of the black vinegar solution through an incremental random forest regression model, and has the advantages of simple algorithm, efficient operation and accurate calculation.
[0054] 2. The method for predicting the concentration of hexamethylenetetramine in black vinegar solution with an updating mechanism in the present invention can screen the data to be learned and continue learning on the basis of the original learning structure when new data arrives, acquire new knowledge from the new data obtained in batches, and gradually improve the adaptability and prediction performance of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a flow chart of the method for predicting the concentration of urotropine in black vinegar solution with an updating mechanism.
[0056] Figure 2 This is a comparison of the predicted and measured values of the near-infrared spectra of the test set using the incremental random forest regression model. DETAILED DESCRIPTION
[0057] The present invention has a method for predicting the concentration of urotropine in black vinegar solution with an updating mechanism. Figure 1 shown.
[0058] The present invention will be described in further detail below with reference to the accompanying drawings:
[0059] Example 1:
[0060] 1. Collection and processing of black vinegar solution samples
[0061] Weigh a certain amount of urotropine and acetic acid solution directly to prepare urotropine vinegar solution samples with different urotropine concentrations. Measure the near infrared spectrum of each sample (scanning wavelength range 10000~4000cm -1 ) and measured the hexamethylenetetramine concentration in each solution sample using conventional methods. A total of 92 data sets were collected, 28 of which were used as incremental data for subsequent model updates. The near-infrared spectral data and corresponding concentration data of 64 hexamethylenetetramine-acetic acid solution samples were combined to form the original spectral matrix X0 (n×m) and the original concentration matrix Y (n×1), where m represents the number of wavelength variables (1557) and n represents the number of samples (64).
[0062] 2. Building an Incremental Random Forest Regression Model
[0063] (1) The data in the original spectral matrix X0 are processed by second-order derivative and wavelet transform to eliminate the interference of noise, stray light and other interferences in the near-infrared spectrum and the influence of baseline drift and gentle background interference in the information acquisition process, and the processed spectral matrix X is obtained;
[0064] The second-order derivative of the data x in the original spectrum matrix X0 is calculated as follows:
[0065]
[0066] Wherein λ is the wavelength interval of the near infrared spectrum (λ is 3.857 in the embodiment).
[0067] The wavelet transform is performed on the data processed by the second-order derivative, and the specific method includes the following steps:
[0068] ① By scaling and translating the wavelet basis Ψ(t), many derived wavelets can be obtained:
[0069]
[0070] Where a is the expansion coefficient and b is the translation coefficient. Wavelet transform is the spectral signal f(t)(f(t)∈function space L 2 (R)) is projected onto the wavelet basis Ψ(t):
[0071]
[0072] Where W ψ f(a,b) is the wavelet transform coefficient, is ψ a,b The complex conjugate of (t).
[0073] Let a = a0 u (a0>1,u∈Z),b=vb0a0 u (b0∈R,v∈Z), the derived wavelet transformation is:
[0074]
[0075] The discretized wavelet coefficients can be expressed as:
[0076]
[0077] ② According to multi-resolution analysis, the spectral signal f(t) can be decomposed into:
[0078]
[0079] Where W is the highest decomposition level, c w,o and d w,o are the approximate and detailed parts of the spectral signal f(t), is the function space L 2 (R) scaling function.
[0080] ③ According to the Mallat algorithm, the filter bank is used to complete the wavelet fast decomposition and reconstruction. The decomposition formula is:
[0081] c w,o =∑ l c w-1,l ·h l-2o (7)
[0082] d w,o =∑ l c w-1,l ·g l-2o (8)
[0083] Where h and g are the low-pass filter coefficients and high-pass filter coefficients, respectively, which are related to the selected wavelet function, o is the signal length, and l is the filter length. During the sampling process, the algorithm undergoes a decomposition and the approximate part c w Decomposed into lower-level approximate parts c w-1 and details d w-1 , both are always half the length of the input signal.
[0084] After the wavelet transform decomposes the signal, different wavelet coefficients will occur. The appropriate wavelet coefficients are reconstructed to obtain the data after wavelet processing:
[0085] c w-1,o =∑ l (c w,l ·h l-2o +d w,o ·g l-2o ) (9)
[0086] In the embodiment, the wavelet basis is selected as the db8 wavelet function, the filter length l is 16, the maximum decomposition layer number W is 4, the signal length o is 1557, and the filter coefficients are shown in Table 1.
[0087] Table 1 Filter coefficients
[0088] Serial number High-pass filter coefficients Low-pass filter coefficients 1 -0.05441584224310401 -0.00011747678412476953 2 0.31287159091429995 0.0006754494064505693 3 -0.6756307362972898 -0.00039174037337694705 4 0.5853546836542067 0.004870352993451574 5 0.015829105256349306 0.008746094047405777 6 -0.2840155429615469 0.013981027917398282 7 -0.0004724845739132828 -0.044088253930794755 8 0.12874742662047847 -0.017369301001807547 9 0.017369301001807547 0.12874742662047847 10 -0.044088253930794755 0.0004724845739132828 11 -0.013981027917398282 -0.2840155429615469 12 0.008746094047405777 0.015829105256349306 13 0.004870352993451574 0.5853546836542067 14 -0.00039174037337694705 0.6756307362972898 15 -0.0006754494064505693 0.31287159091429995 16 -0.00011747678412476953 0.05441584224310401
[0089] (2) The processed spectral matrix X and the original concentration matrix Y are reduced in dimension by the least angle regression algorithm (LAR) to obtain the reduced spectral matrix X LAR ;
[0090] The LAR algorithm implements dimensionality reduction processing and includes the following steps:
[0091] a. Normalize the data in the spectral matrix X. The calculation formula is:
[0092]
[0093]
[0094] Where mean is the mean of each column, σ is the standard deviation, and x * is the standardized data, and x is the data in the spectral matrix X.
[0095] b. The initial regression residual vector r is set to the central value of the variable in the concentration matrix, that is Where y is the variable in the concentration matrix, is the mean vector of y, and the parameters β1, β2, ..., β m ;
[0096] c. Find the variable a that has the greatest correlation with r i ;
[0097] d. Set variable a i The corresponding coefficient β i From 0 to the least squares coefficient i , r>, where <,> represents the inner product, until the new variable a j The residual correlation of is greater than that of variable a i The residual of
[0098] e. Change variable a i and a j The corresponding coefficient β i and β j , proceed and update along the direction of the least squares estimate of the new variable until a new variable is selected according to the above rules;
[0099] f. Repeat steps c to e until all variables are selected and the final estimate is exactly the solution of the least squares method;
[0100] An iterative algorithm selects variables based on their importance to the regression. The optimal solution often discards irrelevant or unimportant variables. Based on actual usage requirements, the top k ranked variables are selected to form the reduced spectral matrix. In the optimal model, the original number of bands (1557) is reduced to four characteristic wavelengths.
[0101] (3) The spectrum matrix X after dimension reduction LAR And the original concentration matrix Y, according to the principle of spxy algorithm, the training set spectrum matrix X is divided train , training set concentration matrix Y train , test set spectral matrix X test and the test set concentration matrix Y test , the division ratio is 7:3;
[0102] The spxy algorithm includes the following steps:
[0103] a) Take two samples (named p and q) from the data in the reduced-dimensional near-infrared spectral data and the original concentration data set, and calculate the reduced-dimensional spectral matrix X of the (p, q) samples respectively LAR The distance between the data x in and the data y in the original concentration matrix Y is calculated as:
[0104]
[0105]
[0106] Where d is the distance between samples.
[0107] b) After dimension reduction, the spectral matrix X LAR The distance between the data x in the original concentration matrix Y and the data y in the space is given equal importance, that is, normalization is performed, and the normalized distance d xy for:
[0108]
[0109] c) When selecting, first select the sample pair (p, q) with the largest normalized distance to enter the training set. In each iteration, select the samples with the largest and smallest normalized distances relative to any selected samples to enter the training set. Repeat the process until the number of training sets is met, stop the iteration, and the rest enter the test set.
[0110] (4) The training set spectral matrix X train , training set concentration matrix Y train Input into the random forest regression model for training, find the optimal number of regression decision trees, and get the initial model of random forest regression. Then, the test set spectral matrix X test Perform fitting prediction to obtain the test set concentration prediction data matrix Y′ test ; The test set concentration prediction data matrix Y′ test and the test set concentration matrix Y test The data in the comparison were compared and the correlation coefficient R was used. 2 , mean square error MSE for evaluation;
[0111] The construction of the random forest regression initial model includes the following steps:
[0112] a. Combine the training set spectral data and the training set concentration data into a sample set, and use the bootstrap method to randomly sample the sample set with replacement to generate h training sets, denoted as θ1, θ2, ..., θ h ;
[0113] b. Assume that the subspace corresponding to the training set θ1 is R. Subspace R is divided into two groups according to the threshold value. Split into R l and R r The two parts are divided into two parts until they cannot be further divided, and the regression decision tree model corresponding to the training set θ1 is constructed;
[0114] The subspace R segmentation rule is:
[0115]
[0116]
[0117] Where x is the spectral data in the training set θ1.
[0118] For the segmentation problem, there exists an optimal solution such that the minimum function Minimum:
[0119]
[0120]
[0121]
[0122] Where y is the training set concentration data in the training set θ1, It is in R l and R r The mean of the space, |R| is the number of sample points in subspace R, n r and n l Corresponding to R l and R r The number of sample points in the space.
[0123] According to the above method, R l and R r As the parent node, continue to split until the number of samples in the parent node is less than the set threshold S, and set the current parent node as a leaf node. Each leaf node stores the mean of the training samples that reach this position. After the above splitting, u parent nodes R1, R2, ..., R u , and has a fixed output value in each parent node space (the average value of the output variable y of all samples in the current parent node space), then the regression decision tree model corresponding to the training set θ1 can be expressed as:
[0124]
[0125] Where I is a logical value, expressed as:
[0126]
[0127] c. For the training set θ2, θ3, ..., θ h Repeat step b until h regression decision trees are generated and each tree is grown to the maximum extent;
[0128] d. Combine h regression decision trees into a random forest and establish a function for the random forest regression initial model
[0129]
[0130] The evaluation index correlation coefficient R 2 , Mean Square Error MSE (Mean Square Error):
[0131] ①Correlation coefficient R 2 :R 2 The closer it is to 1, the better the prediction effect of the model is. The calculation formula is:
[0132]
[0133] In the formula is the average of the actual values, is the prediction result corresponding to the input value x.
[0134] ② Mean square error (MSE): The smaller the MSE value, the stronger the prediction ability of the model. The calculation formula is:
[0135]
[0136] The results show that the optimal model, using second-order derivatives and wavelet transforms for spectral data preprocessing and minimum angle regression for dimensionality reduction, yielded a test set mean square error of 0.0011 and a correlation coefficient of 0.99955. The optimal model parameters and prediction performance are shown in Table 2.
[0137] Table 2 Final modeling parameters
[0138] Preprocessing methods Number of bands extracted Random forest regression initial model parameters <![CDATA[R 2 ]]> MSE Second-order derivatives and wavelet transforms k=4 S=2, h=151, K=21 0.99955 0.0011
[0139] (5) Constructing an incremental random forest regression model
[0140] After the near-infrared spectral data of the remaining 28 black vinegar solution samples are processed by second-order derivative, wavelet transform, and minimum angle regression algorithm for dimensionality reduction, the corresponding predicted values are obtained by the random forest regression initial model. The relative error between the predicted value and the true value is calculated one by one. If the absolute value of the relative error is less than or equal to the threshold value of 0.1%, the next sample data is predicted; otherwise, the sample data is respectively taken from the training set θ1, θ2, ..., θ h According to the splitting rule, the subspace is reached and stored in the corresponding subspace, and then the step b of constructing the random forest regression initial model is executed to obtain h incremental regression decision trees, and then the h incremental regression decision trees are combined into a random forest to obtain an incremental random forest regression model. The constructed incremental random forest regression model is used to analyze the test set spectral matrix X test The data in the fitting prediction is used to use the correlation coefficient R 2, mean square error MSE for evaluation.
[0141] The results show that when the aforementioned random forest regression initial model is used to analyze the near infrared spectral data and concentration data of 28 black vinegar solution samples, 23 black vinegar solution samples have relative errors greater than the threshold. The 23 black vinegar solution sample data are composed of training samples s, and the training sets θ1, θ2, ..., θ h According to the splitting rule, the subspace is reached and stored in the corresponding subspace. Then, according to the splitting rule (step b of constructing the initial random forest regression model), the incremental regression decision tree is updated to obtain h incremental regression decision trees to form a random forest, that is, the incremental random forest regression model. The obtained incremental random forest regression model is used to evaluate the test set spectral matrix X test Perform fitting prediction and compare it with the test set concentration matrix Y test The correlation coefficient R 2 It reached 0.99956, and the mean square error was reduced from 0.0011 to 0.0010. Compared with the random forest regression initial model, the accuracy was improved.
[0142] Table 3 shows the prediction results for the test set near-infrared spectral data using the initial random forest regression model and the incremental random forest regression model. As can be seen from Table 3, the maximum absolute value of the relative error is reduced from 0.96% to 0.87% when the incremental random forest regression model is used. This demonstrates that the incremental random forest regression model of the present invention can be used to relearn new data, further reducing the model's prediction error and improving its prediction accuracy. Figure 2 Shown are the prediction results of the test set near-infrared spectral data using the incremental random forest regression model.
[0143] Table 3 Comparison of predictions of different models for near-infrared spectral data of the test set
[0144]
[0145] 3. Prediction of the concentration of black vinegar solution with unknown hexamethylenetetramine concentration
[0146] Once the model is established, it can quickly predict the hexamine concentration in black vinegar solutions with unknown hexamine concentrations. Near-infrared spectral data from 10 new samples of black vinegar solutions collected online were processed using second-order derivatives, wavelet transforms, and minimum angle regression methods for dimensionality reduction. The data were then input into the initial random forest regression model and the incremental random forest regression model. The hexamine concentration values in the new samples were directly obtained. The results are shown in Table 4. As can be seen from Table 4, the predictions from the incremental random forest regression model are more accurate than those from the initial random forest regression model, demonstrating the feasibility of this method.
[0147] Table 4 Comparison of predicted and measured values of methenamine concentration in unknown black vinegar solution samples
[0148]
[0149]
[0150] The above specific description further illustrates the purpose, technical solutions and beneficial effects of the invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for predicting the concentration of methenamine in black vinegar solution with an updating mechanism, characterized in that: The following steps are involved: Step 1, collecting near-infrared spectral data of the black vinegar solution with the measured urotropine concentration; Step 2: Obtain the hexamethylenetetramine concentration in the solution corresponding to the near-infrared spectral data through an incremental random forest regression model; the incremental random forest regression model described in step 2 is established by the following method: Step 2-1, collecting n near-infrared spectral data of urotropine-acetic acid solutions with different urotropine concentrations and their corresponding urotropine concentration data to form an original near-infrared spectral data set and an original concentration data set; Step 2-2, performing second-order derivative and wavelet transform processing on the data in the original near-infrared spectral data set to obtain pre-processed near-infrared spectral data; Step 2-3, performing least angle regression (LAR) dimensionality reduction on the pre-processed near-infrared spectral data to obtain reduced-dimensional near-infrared spectral data; Step 2-4, dividing the reduced dimensionality near-infrared spectral data and the data in the original concentration data set into training set spectral data, training set concentration data, test set spectral data and test set concentration data according to the principle of the spxy algorithm; Step 2-5: Input the training set spectral data and the training set concentration data into the random forest regression model for training, find the optimal number of regression decision trees, and obtain the random forest regression initial model. Then, fit and predict the test set spectral data to obtain the test set concentration prediction data; compare the test set concentration prediction data with the test set concentration data, and use the correlation coefficient R 2 , mean square error MSE for evaluation; Step 2-6: When the kth black vinegar solution near-infrared spectrum data is obtained, the second-order derivative, wavelet transform and minimum angle regression algorithm are performed on the data to reduce the dimension, and the corresponding prediction value is obtained by the random forest regression initial model, wherein k=n+1, n+2, ...; Step 2-7, calculate the relative error between the predicted value and the true value; if the absolute value of the relative error is less than or equal to the threshold δ, set k = k + 1 and go to step 2-6; otherwise, input the k-th black vinegar solution near-infrared spectrum data and its corresponding concentration true value into the random forest regression initial model, and according to the constructed random forest, store it in the subspace of the corresponding regression decision tree and mark it, and then determine whether to split, so as to complete the update of the regression decision tree model, and then set k = k + 1 and go to step 2-6 until the final regression decision tree model is obtained, that is, the incremental random forest regression model is obtained.
2. The method for predicting the concentration of methenamine in black vinegar solution with an updating mechanism as claimed in claim 1, wherein: In steps 2-3, the core of the minimum angle regression algorithm is to decompose the regression target vector into a linear combination of several groups of feature vectors in sequence, and finally minimize the residual vector that is linearly independent of all features. LAR dimensionality reduction includes the following steps: (1) performing standardization processing on the pre-processed near infrared spectroscopy data; (2) The initial regression residual vector r is set to the central value of the data in the original concentration dataset, that is, Where y is the data in the original concentration data set, is the mean vector of y, and the parameters β1, β2, ..., β in the regression model are set m is 0, where m represents the near-infrared spectral data after normalization in step (1); (3) Find the variable a that has the greatest correlation with r i ; (4) Set variable a i The corresponding coefficient β i From 0 to the least squares coefficient i , r>, where <,> represents the inner product, until the new variable a l The residual correlation of is greater than that of variable a i The residual of (5) Set variable a i and a l The corresponding coefficient β i and β l , proceed and update along the direction of the least squares estimate of the new variable until a new variable is selected according to the above rules; (6) Repeat steps (3) to (5) until all variables are selected and the final estimate is exactly the solution of the least squares method; the variables are selected in order of importance to the regression through an iterative algorithm, and the optimal solution obtained usually discards some irrelevant or unimportant variables; according to actual usage requirements, the top k variables are taken to obtain the near-infrared spectral data after dimensionality reduction.
3. The method for predicting the concentration of methenamine in black vinegar solution with an updating mechanism as claimed in claim 1, wherein: In steps 2-4, the spxy algorithm includes the following steps: 1) Take two samples named p and q from the data in the reduced-dimensional near-infrared spectral data and the original concentration dataset, and calculate the distance between the (p, q) samples to the reduced-dimensional near-infrared spectral data x and the data y in the original concentration dataset, respectively. The calculation formula is: Where d is the distance between samples, and m is the number of wavelength points in the near-infrared spectrum; 2) Give equal importance to the distance between the reduced dimension near-infrared spectral data x and the data y in the original concentration data set, that is, perform normalization processing, and the normalized distance d xy for: 3) When selecting, first select the sample pair (p, q) with the largest normalized distance to enter the training set. In each iteration, select the samples with the largest and smallest normalized distances relative to any selected samples to enter the training set. Repeat the process until the number of training sets is met, and the rest will enter the test set.
4. The method for predicting the concentration of methenamine in black vinegar solution with an updating mechanism as claimed in claim 1, wherein: The incremental random forest regression model construction described in steps 2-7 includes the following steps: a. Combine the training set spectral data and the training set concentration data into a sample set, and use the bootstrap method to randomly sample the sample set with replacement to generate h training sets, denoted as θ1, θ2, ..., θ h ; b. Assume that the subspace corresponding to the training set θ1 is R, and the subspace R is divided into two groups according to the threshold value. Split into R l and R r The two parts are divided into two parts until they cannot be further divided, and the regression decision tree model corresponding to the training set θ1 is constructed; The subspace R segmentation rule is: Where x is the spectral data in the training set θ1; For the segmentation problem, there exists an optimal solution such that the minimum function Minimum: Where y is the training set concentration data in the training set θ1, It is in R l and R r The mean of the space, |R| is the number of sample points in subspace R, n r and n l Corresponding to R l and R r The number of sample points in the space; According to the above method, R l and R r As the parent node, continue to split until the number of samples in the parent node is less than the set threshold S, and set the current parent node as a leaf node. Each leaf node stores the mean of the training samples that reach this position. After the above splitting, u parent nodes R1, R2, ..., R u , and has a fixed output value in each parent node space That is, the average value of the output variable y of all samples in the current parent node space, then the regression decision tree model corresponding to the training set θ1 can be expressed as: Where I is a logical value, expressed as: c. For the training set θ2, θ3, ..., θ h Repeat step b until h regression decision trees are generated and each tree is grown to the maximum extent; d. Combine h regression decision trees into a random forest and establish a function for the random forest regression initial model e. After the near-infrared spectral data of the new sample undergoes dimensionality reduction processing using the second-order derivative, wavelet transform, and minimum angle regression algorithm, the corresponding predicted value is obtained through the random forest regression initial model. When the relative error between the predicted value and the true value is greater than the threshold δ, it is defined as a training sample s; f. The training samples s are respectively selected from the training set θ1, θ2, ..., θ h Arrive at the subspace according to the splitting rule and store it in the corresponding subspace, then execute step b to obtain h incremental regression decision trees; g. Combine h incremental regression decision trees into a random forest to obtain the incremental random forest regression model.
Citation Information
Patent Citations
Method of processing vector signals for pattern recognition based on wavelet analysis
RU2690001C1
General form of the tree alternating optimization (TAO) for learning decision trees
WO2020247949A1