An optimization system for automatic construction of near-infrared PLS quantitative analysis model

By optimizing the near-infrared PLS model through spectral cleaning and characteristic wavelength screening, the problem of improper removal of abnormal samples was solved, the generalization ability and robustness of the model were improved, and the accuracy and stability of tobacco quality detection were achieved.

CN123142809APending Publication Date: 2026-11-20GUIZHOU TOBACCO REDRYING +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611253764.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-18
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

In the process of building a near-infrared quality detection model for the tobacco industry, the lack of a targeted screening mechanism in the spectral data preprocessing stage leads to improper removal of abnormal samples, which affects the model's generalization ability.

Method used

By eliminating non-smoke impurities and abnormal samples through a spectral cleaning unit, correcting optical path drift through vector normalization, selecting characteristic wavelengths using competitive adaptive reweighted sampling and continuous projection algorithms, and optimizing model parameters through regularization constraints and cross-validation, the PLS model can be automatically constructed and iteratively optimized.

Benefits of technology

This improved the model's data quality and prediction reliability, ensuring the accuracy and robustness of tobacco quality testing and adapting to disturbances in complex production environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123142809A_ABST
    Figure CN123142809A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of spectral analysis, and discloses an optimization system for automatic construction of a near-infrared PLS quantitative analysis model, which comprises a spectral data preprocessing module, a spectral feature screening module, a model parameter optimization module, a model performance verification module, a model iteration optimization module and a model deployment management module. The system performs cleaning and normalization processing on original tobacco near-infrared spectra, outputs a standardized spectral data set suitable for tobacco spectral characteristics, screens characteristic wavelengths by using a competitive self-adaptive reweighted sampling and a successive projections algorithm, outputs an optimized feature matrix, locks optimal parameters based on a grid search and a regularization constraint to generate a PLS model draft, outputs model performance indicators relying on cross-validation and stability testing, and finally encapsulates and pushes the optimized PLS model to an online near-infrared quality analyzer of a tobacco redrying line and a cut tobacco line. The present application improves the purity of tobacco quality model input.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of spectral analysis technology, specifically to an optimized system for automatically constructing a near-infrared PLS quantitative analysis model. Background Technology

[0002] The method of identifying substances and determining their chemical composition and relative content based on their spectra is called spectroscopic analysis.

[0003] Currently, in the process of building near-infrared quality detection models in the tobacco industry, due to the lack of a targeted screening mechanism in the spectral data preprocessing stage, it is impossible to determine in real time whether the abnormal samples removed by the spectral cleaning unit contain representative edge information of tobacco when generating standardized spectral datasets. Excessive removal will lead to insufficient representativeness of modeling samples, affecting the generalization ability of tobacco quality models.

[0004] Therefore, an optimized system for automatically constructing a near-infrared PLS quantitative analysis model is proposed to solve the above problems. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides an optimized system for the automatic construction of near-infrared PLS quantitative analysis models. This system solves the problems mentioned in the background art, such as the inability to determine in real time whether abnormal samples removed by the spectral cleaning unit contain representative tobacco edge information, and the problem that excessive removal can lead to insufficient representativeness of modeling samples, affecting the generalization ability of tobacco quality models.

[0006] To achieve the above objectives, the present invention provides the following technical solution: an optimized system for automatically constructing a near-infrared PLS quantitative analysis model, comprising: The spectral data preprocessing module uses the spectral cleaning unit to remove non-tobacco impurities, moldy samples, and extreme samples with abnormal spectral responses from tobacco samples. It uses the vector normalization unit to correct the optical path drift during tobacco powder compression and sheet tobacco transmission detection, and outputs a standardized spectral dataset through the sample partitioning unit. The spectral feature screening module receives the standardized spectral dataset, filters the characteristic wavelengths corresponding to the characteristic absorption of the CH, OH, and NH bonds in tobacco through a competitive adaptive reweighted sampling unit, eliminates the collinear interference between tobacco polysaccharides and reducing sugars, and between total nitrogen and nicotine through a continuous projection algorithm unit, and outputs an optimized feature matrix through a feature vector construction unit. The model parameter optimization module receives the optimized feature matrix, traverses the number of latent variables that adapt to the low concentration and strong correlation characteristics of tobacco quality indicators through the grid search unit, suppresses the risk of overfitting by the regularization constraint unit, and outputs the initial draft of the PLS model through the optimal parameter locking unit. The model performance verification module receives the initial draft of the PLS model, calculates the root mean square error of prediction through the cross-validation unit, uses the stability test unit to simulate the temperature, humidity and vibration disturbances at the tobacco production site to evaluate the robustness of the model, and outputs the model performance index through the verification report generation unit. The model iteration and optimization module receives the model performance index, identifies invalid variables such as tobacco background interference through the variable projection importance analysis unit, locates the systematic bias caused by uneven particle size and aging differences of tobacco samples through the residual analysis unit, and outputs the optimized PLS model through the model coefficient update unit. The model deployment management module integrates the optimized PLS model, generates a general calling interface through the model format encapsulation unit, records iteration logs through the version management unit, and pushes the encapsulated model to the online near-infrared quality analyzer of the tobacco re-drying line and the tobacco processing line through the model distribution unit.

[0007] Preferably, the process in the spectral data preprocessing module, which uses a spectral cleaning unit to remove non-tobacco impurities, moldy samples, and extreme samples with abnormal spectral responses from tobacco samples, corrects optical path drift during tobacco powder compression and sheet transmission detection using a vector normalization unit, and outputs a standardized spectral dataset using a sample partitioning unit, is as follows: The spectral cleaning unit is equipped with a Mahalanobis distance calculation subunit, which calculates the Mahalanobis distance of the samples based on the covariance matrix of the spectral matrix, and identifies tobacco outlier samples whose distance values ​​exceed a preset threshold as outliers and removes them. The vector normalization unit is equipped with an intercept correction subunit, which calculates the average absorbance for each spectral curve and subtracts the average absorbance from the absorbance value at each wavelength point. The sample partitioning unit is equipped with a KS algorithm subunit, which divides the entire sample set into a training set and a test set in a 3:1 ratio based on the distance metric between sample spectra.

[0008] Preferably, the spectral feature screening module receives the standardized spectral dataset, filters the characteristic wavelengths corresponding to the characteristic absorption of tobacco CH, OH, and NH bonds through a competitive adaptive reweighting sampling unit, eliminates collinear interference between tobacco polysaccharides and reducing sugars, and between total nitrogen and nicotine through a continuous projection algorithm unit, and outputs an optimized feature matrix through a feature vector construction unit. The competitive adaptive reweighted sampling unit is equipped with a variable weight calculation subunit, which calculates the selection frequency of each wavelength point through multiple adaptive reweighted samplings, and retains the wavelength points corresponding to the tobacco characteristic absorption peaks with frequencies higher than a set threshold as feature variables. The continuous projection algorithm unit is configured with a projection vector subunit, which calculates the orthogonality of the projection vector from the set of wavelength points selected in the forward iteration. The feature vector construction unit is equipped with a matrix recombination subunit, which recombines the absorbance data corresponding to the selected feature wavelength points according to the sample order to generate an optimized feature matrix with reduced dimensionality.

[0009] Preferably, the process in the model parameter optimization module that receives the optimized feature matrix, traverses the number of latent variable combinations that fit the low concentration and strong correlation characteristics of tobacco quality indicators through a grid search unit, suppresses the risk of overfitting using a regularization constraint unit, and outputs the initial draft of the PLS model through an optimal parameter locking unit is as follows: The grid search unit is configured with a parameter space sub-unit, which presets the search range and step size of the number of latent variables adapted to small sample tobacco modeling, as well as the candidate set of regularization coefficients, to generate a discrete parameter combination grid. The regularization constraint unit is configured with a ridge regression penalty subunit, which introduces an L2 norm penalty term into the objective function of PLS ​​regression. The coefficient of the penalty term is determined by the regularization coefficient. The optimal parameter locking unit is equipped with an index evaluation subunit. It uses the ten-fold cross-validation method to calculate the sum of squared predicted residuals under each parameter combination, selects the parameter combination corresponding to the minimum sum of squared predicted residuals as the optimal parameters, and constructs a draft PLS model based on these parameters.

[0010] Preferably, the process by which the model performance verification module receives the initial draft of the PLS model, calculates the root mean square error of prediction through the cross-validation unit, evaluates the robustness of the model by simulating temperature, humidity, and vibration disturbances at the tobacco production site using the stability testing unit, and generates a verification report to output model performance indicators is as follows: The cross-validation unit is equipped with a leave-one-out sub-unit, which sequentially uses a single sample from the training set as the validation set, and applies the remaining samples to modeling, and iteratively calculates the difference between the predicted value and the true value of all samples. The stability testing unit is equipped with a Monte Carlo sub-unit. It simulates and measures fluctuations by randomly adding Gaussian white noise to simulate temperature, humidity, and vibration disturbances in a tobacco production site multiple times, and statistically analyzes the coefficient of variation of the model's prediction results. The coefficient of variation is used to quantify the model's anti-interference ability. The verification report generation unit is equipped with an index summary subunit, which integrates and calculates the root mean square error of prediction, the coefficient of determination, and the relative analysis error, and encapsulates the above statistics into structured model performance indicators.

[0011] Preferably, the process in the model iterative optimization module that receives the model performance index, identifies invalid variables such as tobacco background interference through the variable projection importance analysis unit, locates the systematic bias caused by uneven particle size and aging differences in tobacco samples through the residual analysis unit, and outputs the optimized PLS model through the model coefficient update unit is as follows: The variable projection importance analysis unit is equipped with a weight value calculation subunit, which analyzes the product of the PLS model loading matrix and the regression coefficient, calculates the variable projection importance score for each characteristic wavelength, and marks interference variables with scores lower than 1 that are not related to tobacco quality as invalid variables. The residual analysis unit is equipped with a trend detection subunit, which plots a scatter plot of the predicted residual as a function of tobacco quality concentration, and detects whether there is a nonlinear trend and heteroscedasticity caused by differences in tobacco sample particle size. If these exist, the model is determined to have systematic bias. The model coefficient update unit is equipped with a coefficient correction subunit, which removes the model coefficients corresponding to invalid variables based on the variable projection importance analysis results, and performs offset term correction on the retained coefficients based on the residual analysis results to generate an optimized PLS model.

[0012] Preferably, the process of integrating the optimized PLS model in the model deployment management module, generating a general calling interface through the model format encapsulation unit, recording iteration logs through the version management unit, and pushing the encapsulated model to the online near-infrared quality analyzer of the tobacco re-drying line and the tobacco processing line through the model distribution unit is as follows: The model format encapsulation unit is configured with an XML encoding subunit, which extracts the regression coefficients, intercepts, wavelength indexes and preprocessing parameters of the optimized PLS model, encodes them into an XML file that conforms to the prediction model markup language standard, and generates a general calling interface. The version management unit is configured with a timestamp recording subunit, which associates the hash value of the model file with the construction timestamp, records the parameter change details of each iteration optimization, and forms a traceable version tree; The model distribution unit is equipped with a communication protocol adaptation subunit, which packages the XML format model file into a binary data stream and pushes the model data to the embedded computing unit of the online near-infrared quality analyzer of the tobacco re-drying line and the tobacco processing line through the OPC UA communication protocol.

[0013] Preferably, the competitive adaptive reweighted sampling unit is configured with a variable weight calculation subunit. The process of calculating the selection frequency of each wavelength point through multiple adaptive reweighted samplings and retaining the wavelength points corresponding to the tobacco characteristic absorption peaks with frequencies higher than a set threshold as feature variables is as follows: Set the maximum number of samplings to N. In the i-th sampling iteration, calculate the weight value of each wavelength point based on the current model coefficients, and retain the wavelength points with larger weight values ​​into the candidate subset. PLS regression modeling is performed on the candidate subset, and the prediction accuracy of the model on the validation set is calculated. When the accuracy meets the preset condition, the set of wavelength points selected in this iteration is recorded as the effective subset. The total number of times each wavelength point appears in all valid subsets during N iterations is counted. The ratio of this number to the total number of valid subsets is calculated as the selection frequency. Wavelength points with a selection frequency greater than 0.7 are determined as the final feature variables.

[0014] Preferably, the regularization constraint unit is configured with a ridge regression penalty subunit, introducing an L2 norm penalty term into the objective function of PLS ​​regression. The coefficient of the penalty term is determined by the regularization coefficient as follows: The objective function is defined as minimizing the sum of the loss function and the regularization term, where the loss function is the sum of the squares of the differences between the predicted and the true values, and the regularization term is the L2 norm penalty term. The L2 norm penalty term is the product of the sum of squares of all regression coefficients and the regularization coefficient, which is taken from the candidate set generated by the grid search unit. In the process of solving the regression coefficients, the objective function containing the L2 norm penalty term is iteratively optimized by the gradient descent method, so that the regression coefficients shrink towards zero while retaining non-zero values.

[0015] Preferably, the stability testing unit is equipped with a Monte Carlo sub-unit. It simulates fluctuations by repeatedly adding Gaussian white noise to simulate temperature, humidity, and vibration disturbances at a tobacco production site, and then statistically measures the coefficient of variation of the model's prediction results. The process of using the coefficient of variation to quantify the model's anti-interference capability is as follows: Set the number of noise additions to M. In the j-th test, add random noise following a Gaussian distribution to the spectral data of the training set samples to generate a perturbed training set. The perturbed training set is predicted using the initial draft of the PLS model to obtain the j-th predicted value sequence, and the mean and standard deviation of the sequence are calculated. Repeat the test M times, and calculate the ratio of the overall mean of the standard deviation of the M predicted value sequences to the overall mean of the mean of the M predicted value sequences. This ratio is defined as the coefficient of variation. The smaller the coefficient of variation, the stronger the model stability.

[0016] Compared with existing technologies, this invention provides an optimized system for automatically constructing a near-infrared PLS quantitative analysis model, which has the following beneficial effects: 1. In this invention, when constructing a quantitative model for near-infrared PLS quality of tobacco, the spectral cleaning unit in the spectral data preprocessing module removes non-tobacco impurities, moldy samples, and extreme samples with abnormal spectral responses from tobacco samples. The vector normalization unit is used to correct optical path drift, which ensures the representativeness and accuracy of tobacco in the output standardized spectral dataset. This solves the problem of modeling distortion caused by sample anomalies and optical path differences, and ensures the data quality of subsequent model construction.

[0017] 2. In this invention, during the model feature selection stage, the competitive adaptive reweighted sampling unit and the continuous projection algorithm unit in the spectral feature selection module work together to accurately select the absorption wavelengths of tobacco nicotine and sugar features and eliminate collinearity interference after receiving the standardized spectral dataset. This results in a simplified dimension and sufficient information content in the output optimized feature matrix, avoids noise interference introduced by redundant variables, and improves the purity of the tobacco quality model input.

[0018] 3. In this invention, during the model construction and verification process, the optimal parameters for modeling small tobacco samples are locked by the grid search unit and regularization constraint unit in the model parameter optimization module. Combined with the cross-validation unit and stability test unit in the model performance verification module, the model performance index is output. The model iteration optimization module updates the coefficients based on the index, realizing the closed-loop refinement of the PLS model from the initial draft to the optimized PLS model. This ensures that the model pushed to the online near-infrared quality analyzer of the tobacco re-drying line and the tobacco processing line by the model deployment management module has excellent robustness and predictive reliability. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the architecture of an optimization system for automatically constructing a near-infrared PLS quantitative analysis model according to the present invention. Figure 2 This is a schematic diagram of the split structure of the spectral data preprocessing module of the present invention; Figure 3 This is a schematic diagram of the split structure of the spectral feature screening module of the present invention. Detailed Implementation

[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] Please see Figures 1-3 The specific implementation of an optimized system for automatically constructing a near-infrared PLS quantitative analysis model is as follows, including: The spectral data preprocessing module uses the spectral cleaning unit to remove non-tobacco impurities, moldy samples, and extreme samples with abnormal spectral responses from tobacco samples. It uses the vector normalization unit to correct the optical path drift during tobacco powder compression and sheet tobacco transmission detection, and outputs a standardized spectral dataset through the sample partitioning unit. The spectral feature screening module receives a standardized spectral dataset, filters the characteristic wavelengths corresponding to the absorption of CH, OH, and NH bonds in tobacco through a competitive adaptive reweighted sampling unit, eliminates collinear interference between tobacco polysaccharides and reducing sugars, and between total nitrogen and nicotine through a continuous projection algorithm unit, and outputs an optimized feature matrix through a feature vector construction unit. The model parameter optimization module receives the optimized feature matrix, traverses the number of latent variables that adapt to the low concentration and strong correlation characteristics of tobacco quality indicators through the grid search unit, suppresses the risk of overfitting by the regularization constraint unit, and outputs the initial draft of the PLS model through the optimal parameter locking unit. The model performance verification module receives the initial draft of the PLS model, calculates the root mean square error of prediction through the cross-validation unit, uses the stability test unit to simulate temperature, humidity and vibration disturbances in the tobacco production site to evaluate the robustness of the model, and generates the model performance index through the verification report. The model iteration and optimization module receives the model performance index, identifies invalid variables such as tobacco background interference through the variable projection importance analysis unit, locates the systematic bias caused by the uneven particle size and aging difference of tobacco samples through the residual analysis unit, and outputs the optimized PLS model through the model coefficient update unit. The model deployment management module integrates and optimizes the PLS model, generates a general calling interface through the model format encapsulation unit, records iteration logs through the version management unit, and pushes the encapsulated model to the online near-infrared quality analyzer of the tobacco re-drying line and the tobacco processing line through the model distribution unit.

[0022] The process of using the spectral cleaning unit to remove non-tobacco impurities, moldy samples, and extreme samples with abnormal spectral responses from tobacco samples in the spectral data preprocessing module, correcting optical path drift during tobacco powder compression and sheet transmission detection using the vector normalization unit, and outputting a standardized spectral dataset through the sample partitioning unit is as follows: The spectral cleaning unit is equipped with a Mahalanobis distance calculation subunit. Based on the covariance matrix of the spectral matrix, it calculates the Mahalanobis distance of the samples and identifies tobacco outliers whose distance values ​​exceed a preset threshold as outliers, removing them from the system. The preset threshold... Set the degrees of freedom to equal the number of wavelength variables. The critical value of the chi-square distribution, i.e. ; The vector normalization unit is equipped with an intercept correction subunit, which calculates the average absorbance for each spectral curve, corrects the baseline shift caused by differences in compaction density and particle size of tobacco samples, and subtracts the average absorbance from the absorbance value at each wavelength point to unify the dimensions. In practical implementation, let the spectral data matrix be... ,in To collect tobacco samples covering multiple origins, grades, and aging cycles, To determine the number of wavelength points, first calculate the mean vector of all samples. and covariance matrix For any sample Its Mahalanobis distance The calculation formula is: ; in, For the sample The deviation vector from the mean vector, It is the inverse of the covariance matrix. For the transpose operation, the Mahalanobis distance calculation subunit will calculate the... With preset threshold In comparison, when When determining the sample Identify outliers and remove them; The vector normalization unit is equipped with an intercept correction subunit. It calculates the average absorbance for each spectral curve, subtracts the average absorbance from the absorbance value at each wavelength point to ensure that the training set covers all tobacco samples from all tested origins, grades, and aging cycles. Then, it divides the difference by the standard deviation of the spectrum to complete the vector normalization process and correct the baseline shift caused by differences in compaction density and particle size of the tobacco samples. The sample partitioning unit is equipped with a KS algorithm subunit, which divides the entire sample set into a training set and a test set in a 3:1 ratio based on the distance metric between sample spectra. The training set is used for model building, and the test set is used for independent validation, ensuring that the training set covers the category features of all tested tobacco samples.

[0023] The spectral feature selection module receives a standardized spectral dataset, selects characteristic wavelengths corresponding to the absorption of CH, OH, and NH bonds in tobacco through a competitive adaptive reweighting sampling unit, eliminates collinear interference between tobacco polysaccharides and reducing sugars, and between total nitrogen and nicotine using a continuous projection algorithm unit, and outputs an optimized feature matrix through a feature vector construction unit. The competitive adaptive reweighted sampling unit is equipped with a variable weight calculation subunit, which calculates the selection frequency of each wavelength point through multiple adaptive reweighted samplings, and retains the wavelength points corresponding to the tobacco characteristic absorption peaks with frequencies higher than the set threshold as feature variables. In the In the next sampling iteration, based on the current model coefficients Calculate the weight value of each wavelength point The calculation formula is as follows: ; in, For the first In the nth iteration The regression coefficients corresponding to each wavelength point For absolute value operations, The sum of the absolute values ​​of the regression coefficients for all wavelength points; the variable weight calculation sub-unit is retained. Wavelengths with larger values ​​are included in the candidate subset; The continuous projection algorithm unit is equipped with a projection vector sub-unit, which calculates the orthogonality of the projection vector from the set of wavelength points selected by forward iteration, removes redundant wavelength points that cause multicollinearity, and eliminates the collinearity interference between total sugar and reducing sugar, and between total nitrogen and nicotine in tobacco. The degree of orthogonality is measured by the norm of the residual vector, that is, in each iteration, the wavelength point that minimizes the norm of the residual vector is selected and added to the feature set until the preset maximum number of wavelength points is reached; The feature vector construction unit is equipped with a matrix recombination subunit, which recombines the absorbance data corresponding to the selected feature wavelength points according to the sample order to generate an optimized feature matrix with reduced dimensionality.

[0024] The process of receiving the optimized feature matrix in the model parameter optimization module, traversing the number of latent variable combinations that adapt to the low concentration and strong correlation characteristics of tobacco quality indicators through grid search units, suppressing overfitting risk using regularization constraint units, and outputting the initial draft of the PLS model through the optimal parameter locking unit is as follows: The grid search unit is configured with parameter space sub-units, preset the search range and step size of the number of latent variables adapted to small sample tobacco modeling, as well as the candidate set of regularization coefficients, to generate a discrete parameter combination grid. The regularization constraint unit is configured with a ridge regression penalty subunit, which introduces an L2 norm penalty term into the objective function of PLS ​​regression. The coefficient of the penalty term is determined by the regularization coefficient to reduce the model complexity. Define the objective function To minimize the sum of the loss function and the regularization term, the formula is as follows: ; in, This is a vector of concentration reference values. To optimize the feature matrix, This is a column vector of regression coefficients. To predict the sum of squares of the residuals, This is the L2 norm penalty term, which is the sum of squares of all regression coefficients. The regularization coefficient is taken from the candidate set generated by the grid search unit. The ridge regression penalty sub-unit is applied using the gradient descent method. Iterative optimization is performed to shrink the regression coefficients towards zero while retaining non-zero values. The learning rate is set to 0.01, and the maximum number of iterations is 1000. The optimization is performed when the difference in the objective function between two iterations is less than 10. -6 Stop iteration when the time is right; The optimal parameter locking unit is equipped with an index evaluation sub-unit. The ten-fold cross-validation method is used to calculate the sum of squared predicted residuals under each parameter combination. The parameter combination corresponding to the minimum sum of squared predicted residuals is selected as the optimal parameter, and a draft PLS model is constructed based on this parameter.

[0025] The model performance verification module receives the initial draft of the PLS model, calculates the root mean square error of prediction using cross-validation units, evaluates the robustness of the model by simulating temperature, humidity, and vibration disturbances at a tobacco production site using stability testing units, and generates unit output model performance indicators through a verification report. The cross-validation unit is equipped with leave-one-out sub-units, which sequentially use a single sample from the training set as the validation set, and apply the remaining samples to modeling, and iteratively calculate the difference between the predicted value and the true value of all samples. The stability testing unit is equipped with a Monte Carlo sub-unit. It simulates and measures fluctuations by adding Gaussian white noise to simulate temperature, humidity, and vibration disturbances in a tobacco production site multiple times. The coefficient of variation of the model prediction results is statistically analyzed. The coefficient of variation is used to quantify the model's anti-interference ability. In the In this test, random noise following a Gaussian distribution was added to the spectral data of the training set samples, and the mean of the prediction results was calculated. with standard deviation Final coefficient of variation The calculation formula is: ; in, Add the total number of times to the noise. For the first The variance of the prediction results for each test. for The overall mean of the variance of each test. for The overall mean of the predicted results of each test, the stability test unit will As an indicator of the model's resistance to interference, The smaller the value, the stronger the stability of the model under the complex environment of tobacco production; The validation report generation unit is equipped with an index summary sub-unit, which integrates and calculates the root mean square error of prediction, the coefficient of determination, and the relative analysis error, and encapsulates the above statistics into structured model performance indicators.

[0026] The model iteration and optimization module receives model performance indicators, identifies invalid variables such as tobacco background interference through the variable projection importance analysis unit, locates systematic biases caused by uneven particle size and aging differences in tobacco samples through the residual analysis unit, and outputs the optimized PLS model through the model coefficient update unit. The variable projection importance analysis unit is equipped with a weight value calculation subunit, which analyzes the product of the PLS model loading matrix and the regression coefficients, calculates the variable projection importance score for each characteristic wavelength, and marks interference variables with scores lower than 1 that are not related to tobacco quality as invalid variables. The residual analysis unit is equipped with a trend detection subunit, which plots a scatter plot of the predicted residual as a function of tobacco quality concentration, and detects whether there is a nonlinear trend and heteroscedasticity caused by differences in tobacco sample particle size. If these exist, the model is determined to have systematic bias. When performing residual trend detection, the autocorrelation coefficient rk of the residual sequence is calculated to quantify the trend of residual changes with time and concentration. The calculation formula is as follows: ; in, For the first The prediction residuals for each sample The average value of the residual sequence. The total number of samples, The lag order is calculated differently by the trend detection subunit. Value When multiple If the value is not 0, it is determined that the residual has autocorrelation, that is, the model has systematic bias; The model coefficient update unit is equipped with a coefficient correction subunit, which removes the model coefficients corresponding to invalid variables based on the variable projection importance analysis results, and performs offset term correction on the retained coefficients based on the residual analysis results to generate an optimized PLS model; Offset term correction specifically updates the intercept term of the model, and the correction formula is as follows: ,in This is the original intercept term. For the first The residuals of each sample To correct for the fixed bias caused by the uneven particle size of tobacco samples, the number of collected tobacco samples covering multiple origins, grades, and aging cycles was increased.

[0027] The process of integrating and optimizing the PLS model in the model deployment management module, generating a general calling interface through the model format encapsulation unit, recording iteration logs through the version management unit, and pushing the encapsulated model to the online near-infrared quality analyzer of the tobacco re-drying line and tobacco processing line through the model distribution unit is as follows: The model format encapsulation unit is equipped with an XML encoding subunit, which extracts the regression coefficients, intercepts, wavelength indices and preprocessing parameters of the optimized PLS model, encodes them into an XML file that conforms to the prediction model markup language standard, and generates a general calling interface. The version management unit is configured with a timestamp recording subunit, which associates the hash value of the model file with the build timestamp, records the parameter change details of each iteration optimization, and forms a traceable version tree; The model distribution unit is equipped with a communication protocol adaptation subunit, which packages the XML format model file into a binary data stream and pushes the model data to the embedded computing unit of the online near-infrared quality analyzer of the tobacco re-drying line and the tobacco processing line through the OPC UA communication protocol, so as to realize the real-time detection of indicators such as nicotine and total sugar.

[0028] The competitive adaptive reweighted sampling unit is equipped with a variable weight calculation subunit. It calculates the selected frequency for each wavelength point through multiple adaptive reweighted samplings, and retains the wavelength points corresponding to tobacco characteristic absorption peaks with frequencies higher than a set threshold as feature variables. Set the maximum number of samplings to N. In the i-th sampling iteration, calculate the weight value of each wavelength point based on the current model coefficients. Retain the wavelength points with larger weight values ​​into the candidate subset. The wavelength points with larger weight values ​​are defined as the wavelength points in the top 10% of the weight ranking. PLS regression modeling is performed on the candidate subset, and the prediction accuracy of the model on the validation set is calculated. When the accuracy meets a preset condition, the set of wavelength points selected in this iteration is recorded as the effective subset. The preset condition is the coefficient of determination R on the validation set. 2 >0.9; Count the total number of times each wavelength point appears in all valid subsets in N iterations, calculate the ratio of this number to the total number of valid subsets as the selection frequency, and determine the wavelength points with a selection frequency greater than 0.7 as the final feature variables.

[0029] The regularization constraint unit is configured with a ridge regression penalty subunit. An L2 norm penalty term is introduced into the objective function of PLS ​​regression. The coefficient of the penalty term is determined by the regularization coefficient. The process of reducing model complexity is as follows: The objective function is defined as minimizing the sum of the loss function and the regularization term. The loss function is the sum of the squares of the differences between the predicted and the true values, and the regularization term is the L2 norm penalty term. The L2 norm penalty term is the product of the sum of squares of all regression coefficients and the regularization coefficient, which is taken from the candidate set generated by the grid search unit. In the process of solving the regression coefficients, the objective function containing the L2 norm penalty term is iteratively optimized by gradient descent, so that the regression coefficients shrink towards zero while retaining non-zero values, thereby suppressing model overfitting.

[0030] The stability testing unit is equipped with Monte Carlo sub-units. Fluctuations are simulated by repeatedly adding Gaussian white noise to simulate temperature, humidity, and vibration disturbances in a tobacco production environment. The coefficient of variation of the model's predictions is then statistically analyzed. The coefficient of variation is used to quantify the model's anti-interference capability. Set the number of noise additions to M. In the j-th test, add random noise following a Gaussian distribution to the spectral data of the training set samples to generate a perturbed training set. The initial draft of the PLS model is used to predict the perturbed training set to obtain the j-th predicted value sequence, and the mean and standard deviation of the sequence are calculated. Repeat the test M times, and calculate the ratio of the overall mean of the standard deviation of the M predicted value series to the overall mean of the mean of the M predicted value series. This ratio is defined as the coefficient of variation. The smaller the coefficient of variation, the stronger the model stability.

[0031] The operation steps of an optimized system for automatically constructing a near-infrared PLS quantitative analysis model are as follows: Step 1: Construction of the standardized spectral dataset: After the system starts, the spectral data preprocessing module first receives the raw near-infrared spectral data. The spectral cleaning unit calls the Mahalanobis distance calculation subunit to calculate the Mahalanobis distance of each sample based on the covariance matrix of the spectral matrix. Outlier tobacco samples with distance values ​​exceeding a preset threshold are removed. This ensures the purity of the data base while avoiding excessive removal of representative tobacco samples from edge grades or special aging cycles. Subsequently, the vector normalization unit performs normalization processing on each spectral curve through the intercept correction subunit. This involves calculating the average absorbance of a single spectrum and subtracting the average absorbance value from the absorbance value at each wavelength point. This corrects for baseline shifts caused by differences in tobacco sample compaction density, particle size, optical path drift, and physical properties. Finally, the sample partitioning unit uses the KS algorithm subunit to divide the preprocessed full sample set into a training set and a test set in a 3:1 ratio based on the distance metric between spectra. This ensures that the training set covers the origin, grade, and aging cycle characteristics of all tested tobaccos, providing a unified input benchmark for subsequent modeling.

[0032] Step 2: Optimize the extraction of the feature matrix: After receiving the standardized spectral dataset, the competitive adaptive reweighted sampling unit of the spectral feature screening module starts working. Its internal variable weight calculation subunit calculates the selection frequency of each wavelength point through multiple adaptive reweighted samplings, and retains the wavelength points corresponding to the tobacco characteristic absorption peaks with frequencies higher than a set threshold as candidate feature variables. Then, the continuous projection algorithm unit performs forward iterative screening of the candidate wavelength point set through its projection vector subunit, and calculates the orthogonality of the projection vectors to eliminate the collinear interference between total sugar and reducing sugar, and total nitrogen and nicotine in tobacco. After the screening is completed, the feature vector construction unit calls the matrix recombination subunit to recombine the absorbance data corresponding to the screened feature wavelength points according to the sample order, generating an optimized feature matrix with reduced dimension but concentrated information, thereby reducing the computational complexity of the model.

[0033] Step 3: Parameter locking of the initial PLS model draft: The model parameter optimization module receives the optimized feature matrix as input. The grid search unit presets the search range, step size, and candidate set of regularization coefficients for the number of latent variables that are suitable for the low concentration and strong correlation characteristics of tobacco quality indicators, and generates a discrete parameter combination grid. For each set of parameters, the regularization constraint unit introduces an L2 norm penalty term into the objective function of PLS ​​regression using the ridge regression penalty sub-unit. This reduces the model complexity by suppressing the absolute value of the regression coefficients, thereby suppressing the risk of overfitting. The optimal parameter locking unit uses the ten-fold cross-validation method to calculate the sum of squared predicted residuals under each parameter combination, selects the optimal parameter combination that minimizes the indicator, and constructs a draft PLS model based on these parameters, thus realizing the automated optimization of tobacco quality model parameters.

[0034] Step 4: Quantitative Validation of Model Performance Indicators: The model performance verification module is used to verify the initial draft of the PLS model. The cross-validation unit uses leave-one-out sub-units to sequentially use a single sample from the training set as the validation set, and the remaining samples are used for modeling. The difference between the predicted value and the true value of all samples is calculated in a loop to obtain the root mean square error of the prediction. At the same time, the stability verification unit uses Monte Carlo sub-units to conduct stress tests. Gaussian white noise simulating temperature, humidity and vibration disturbances in the tobacco production site is added multiple times to simulate the fluctuations of actual measurements. The coefficient of variation of the model prediction results is statistically analyzed to quantify the model's anti-interference ability. Finally, the verification report generation unit integrates the above indicators, calculates the coefficient of determination and relative analysis error, encapsulates the various statistics into structured model performance indicators and outputs them, completing a comprehensive check of the performance of the tobacco quality model.

[0035] Step 5: Closed-loop iterative refinement of the PLS model: The model iteration and optimization module fine-tunes the model based on the model performance index. The variable projection importance analysis unit analyzes the product of the PLS model loading matrix and regression coefficients, calculates the variable projection importance score for each characteristic wavelength, and marks interference variables that are not related to tobacco quality and have scores below the threshold as invalid variables. The residual analysis unit plots the predicted residuals as a function of tobacco quality concentration through the trend detection subunit to detect the existence of nonlinear trends and heteroscedasticity caused by differences in tobacco sample particle size, thereby locating systematic biases. The model coefficient update unit removes the model coefficients corresponding to invalid variables based on the analysis results and performs offset term correction on the retained coefficients based on the residual analysis results to correct the fixed bias caused by uneven tobacco sample particle size. The optimized PLS model is then output, realizing closed-loop optimization from the initial draft to the refined model.

[0036] Step Six: Optimize Model Packaging and Deployment: Finally, the model deployment management module integrates and optimizes the PLS model, the model format encapsulation unit extracts the model's regression coefficients, intercepts, wavelength indices, and preprocessing parameters, encodes them into XML files conforming to the prediction model markup language standard, generates a general calling interface, the version management unit associates the hash value of the model file with the construction timestamp, records the parameter change details of each iteration of optimization, forming a traceable version tree, and finally, the model distribution unit packages the encapsulated model file into a binary data stream through the OPC UA communication protocol and pushes it to the embedded computing unit of the online near-infrared quality analyzer on the tobacco re-drying line and the tobacco processing line, realizing the real-time application of the model at the on-site detection end.

[0037] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0038] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. An optimized system for automatically constructing a near-infrared PLS quantitative analysis model, characterized in that, include: The spectral data preprocessing module uses the spectral cleaning unit to remove non-tobacco impurities, moldy samples, and extreme samples with abnormal spectral responses from tobacco samples. It uses the vector normalization unit to correct the optical path drift during tobacco powder compression and sheet tobacco transmission detection, and outputs a standardized spectral dataset through the sample partitioning unit. The spectral feature screening module receives the standardized spectral dataset, filters the characteristic wavelengths corresponding to the characteristic absorption of the CH, OH, and NH bonds in tobacco through a competitive adaptive reweighted sampling unit, eliminates the collinear interference between tobacco polysaccharides and reducing sugars, and between total nitrogen and nicotine through a continuous projection algorithm unit, and outputs an optimized feature matrix through a feature vector construction unit. The model parameter optimization module receives the optimized feature matrix, traverses the number of latent variables that adapt to the low concentration and strong correlation characteristics of tobacco quality indicators through the grid search unit, suppresses the risk of overfitting by the regularization constraint unit, and outputs the initial draft of the PLS model through the optimal parameter locking unit. The model performance verification module receives the initial draft of the PLS model, calculates the root mean square error of prediction through the cross-validation unit, uses the stability test unit to simulate the temperature, humidity and vibration disturbances at the tobacco production site to evaluate the robustness of the model, and outputs the model performance index through the verification report generation unit. The model iteration and optimization module receives the model performance index, identifies invalid variables such as tobacco background interference through the variable projection importance analysis unit, locates the systematic bias caused by uneven particle size and aging differences of tobacco samples through the residual analysis unit, and outputs the optimized PLS model through the model coefficient update unit. The model deployment management module integrates the optimized PLS model, generates a general calling interface through the model format encapsulation unit, records iteration logs through the version management unit, and pushes the encapsulated model to the online near-infrared quality analyzer of the tobacco re-drying line and the tobacco processing line through the model distribution unit.

2. The optimized system for automatically constructing a near-infrared PLS quantitative analysis model according to claim 1, characterized in that, The process of using a spectral cleaning unit to remove non-tobacco impurities, moldy samples, and extreme samples with abnormal spectral responses from tobacco samples in the spectral data preprocessing module, correcting optical path drift during tobacco powder compression and sheet tobacco transmission detection using a vector normalization unit, and outputting a standardized spectral dataset through a sample partitioning unit is as follows: The spectral cleaning unit is equipped with a Mahalanobis distance calculation subunit, which calculates the Mahalanobis distance of the samples based on the covariance matrix of the spectral matrix, and identifies tobacco outlier samples whose distance values ​​exceed a preset threshold as outliers and removes them. The vector normalization unit is equipped with an intercept correction subunit, which calculates the average absorbance for each spectral curve and subtracts the average absorbance from the absorbance value at each wavelength point. The sample partitioning unit is equipped with a KS algorithm subunit, which divides the entire sample set into a training set and a test set in a 3:1 ratio based on the distance metric between sample spectra.

3. The optimized system for automatically constructing a near-infrared PLS quantitative analysis model according to claim 1, characterized in that, The spectral feature screening module receives the standardized spectral dataset, filters the characteristic wavelengths corresponding to the absorption of CH, OH, and NH bonds in tobacco through a competitive adaptive reweighting sampling unit, eliminates collinear interference between tobacco polysaccharides and reducing sugars, and between total nitrogen and nicotine through a continuous projection algorithm unit, and outputs an optimized feature matrix through a feature vector construction unit. The competitive adaptive reweighted sampling unit is equipped with a variable weight calculation subunit, which calculates the selection frequency of each wavelength point through multiple adaptive reweighted samplings, and retains the wavelength points corresponding to the tobacco characteristic absorption peaks with frequencies higher than a set threshold as feature variables. The continuous projection algorithm unit is configured with a projection vector subunit, which calculates the orthogonality of the projection vector from the set of wavelength points selected in the forward iteration. The feature vector construction unit is equipped with a matrix recombination subunit, which recombines the absorbance data corresponding to the selected feature wavelength points according to the sample order to generate an optimized feature matrix with reduced dimensionality.

4. The optimized system for automatically constructing a near-infrared PLS quantitative analysis model according to claim 1, characterized in that, The process by which the model parameter optimization module receives the optimized feature matrix, traverses the combinations of latent variables that fit the low concentration and strong correlation characteristics of tobacco quality indicators through a grid search unit, suppresses overfitting risk using a regularization constraint unit, and outputs the initial draft of the PLS model through an optimal parameter locking unit is as follows: The grid search unit is configured with a parameter space sub-unit, which presets the search range and step size of the number of latent variables adapted to small sample tobacco modeling, as well as the candidate set of regularization coefficients, to generate a discrete parameter combination grid. The regularization constraint unit is configured with a ridge regression penalty subunit, which introduces an L2 norm penalty term into the objective function of PLS ​​regression. The coefficient of the penalty term is determined by the regularization coefficient. The optimal parameter locking unit is equipped with an index evaluation subunit. It uses the ten-fold cross-validation method to calculate the sum of squared predicted residuals under each parameter combination, selects the parameter combination corresponding to the minimum sum of squared predicted residuals as the optimal parameters, and constructs a draft PLS model based on these parameters.

5. The optimized system for automatically constructing a near-infrared PLS quantitative analysis model according to claim 1, characterized in that, The model performance verification module receives the initial draft of the PLS model, calculates the root mean square error of prediction through the cross-validation unit, evaluates the robustness of the model by simulating temperature, humidity, and vibration disturbances at a tobacco production site using the stability testing unit, and generates the unit output model performance index through the verification report. The cross-validation unit is equipped with a leave-one-out sub-unit, which sequentially uses a single sample from the training set as the validation set, and applies the remaining samples to modeling, and iteratively calculates the difference between the predicted value and the true value of all samples. The stability testing unit is equipped with a Monte Carlo sub-unit. It simulates and measures fluctuations by randomly adding Gaussian white noise to simulate temperature, humidity, and vibration disturbances in a tobacco production site multiple times, and statistically analyzes the coefficient of variation of the model's prediction results. The coefficient of variation is used to quantify the model's anti-interference ability. The verification report generation unit is equipped with an index summary subunit, which integrates and calculates the root mean square error of prediction, the coefficient of determination, and the relative analysis error, and encapsulates the above statistics into structured model performance indicators.

6. The optimized system for automatically constructing a near-infrared PLS quantitative analysis model according to claim 1, characterized in that, The process by which the model iterative optimization module receives the model performance index, identifies invalid variables such as tobacco background interference through the variable projection importance analysis unit, locates systematic biases caused by uneven particle size and aging differences in tobacco samples through the residual analysis unit, and outputs the optimized PLS model through the model coefficient update unit is as follows: The variable projection importance analysis unit is equipped with a weight value calculation subunit, which analyzes the product of the PLS model loading matrix and the regression coefficient, calculates the variable projection importance score for each characteristic wavelength, and marks interference variables with scores lower than 1 that are not related to tobacco quality as invalid variables. The residual analysis unit is equipped with a trend detection subunit, which plots a scatter plot of the predicted residual as a function of tobacco quality concentration, and detects whether there is a nonlinear trend and heteroscedasticity caused by differences in tobacco sample particle size. If these exist, the model is determined to have systematic bias. The model coefficient update unit is equipped with a coefficient correction subunit, which removes the model coefficients corresponding to invalid variables based on the variable projection importance analysis results, and performs offset term correction on the retained coefficients based on the residual analysis results to generate an optimized PLS model.

7. The optimized system for automatically constructing a near-infrared PLS quantitative analysis model according to claim 1, characterized in that, The process by which the optimized PLS model is integrated in the model deployment management module, a general calling interface is generated through the model format encapsulation unit, an iteration log is recorded through the version management unit, and the encapsulated model is pushed to the online near-infrared quality analyzer of the tobacco re-drying line and the tobacco processing line through the model distribution unit is as follows: The model format encapsulation unit is configured with an XML encoding subunit, which extracts the regression coefficients, intercepts, wavelength indexes and preprocessing parameters of the optimized PLS model, encodes them into an XML file that conforms to the prediction model markup language standard, and generates a general calling interface. The version management unit is configured with a timestamp recording subunit, which associates the hash value of the model file with the construction timestamp, records the parameter change details of each iteration optimization, and forms a traceable version tree; The model distribution unit is equipped with a communication protocol adaptation subunit, which packages the XML format model file into a binary data stream and pushes the model data to the embedded computing unit of the online near-infrared quality analyzer of the tobacco re-drying line and the tobacco processing line through the OPC UA communication protocol.

8. The optimized system for automatic construction of a near-infrared PLS quantitative analysis model according to claim 3, characterized in that, The competitive adaptive reweighted sampling unit is equipped with a variable weight calculation subunit. The process of calculating the selection frequency of each wavelength point through multiple adaptive reweighted samplings and retaining the wavelength points corresponding to tobacco characteristic absorption peaks with frequencies higher than a set threshold as feature variables is as follows: Set the maximum number of samplings to N. In the i-th sampling iteration, calculate the weight value of each wavelength point based on the current model coefficients, and retain the wavelength points with larger weight values ​​into the candidate subset. PLS regression modeling is performed on the candidate subset, and the prediction accuracy of the model on the validation set is calculated. When the accuracy meets the preset condition, the set of wavelength points selected in this iteration is recorded as the effective subset. The total number of times each wavelength point appears in all valid subsets during N iterations is counted. The ratio of this number to the total number of valid subsets is calculated as the selection frequency. Wavelength points with a selection frequency greater than 0.7 are determined as the final feature variables.

9. The optimized system for automatically constructing a near-infrared PLS quantitative analysis model according to claim 4, characterized in that, The regularization constraint unit is configured with a ridge regression penalty subunit. An L2 norm penalty term is introduced into the objective function of PLS ​​regression. The coefficient of the penalty term is determined by the regularization coefficient as follows: The objective function is defined as minimizing the sum of the loss function and the regularization term, where the loss function is the sum of the squares of the differences between the predicted and the true values, and the regularization term is the L2 norm penalty term. The L2 norm penalty term is the product of the sum of squares of all regression coefficients and the regularization coefficient, which is taken from the candidate set generated by the grid search unit. In the process of solving the regression coefficients, the objective function containing the L2 norm penalty term is iteratively optimized by the gradient descent method, so that the regression coefficients shrink towards zero while retaining non-zero values.

10. The optimized system for automatically constructing a near-infrared PLS quantitative analysis model according to claim 5, characterized in that, The stability testing unit is equipped with a Monte Carlo sub-unit. It simulates fluctuations by repeatedly adding Gaussian white noise to simulate temperature, humidity, and vibration disturbances at a tobacco production site. The coefficient of variation of the model's prediction results is then statistically analyzed. This coefficient of variation is used to quantify the model's anti-interference capability. Set the number of noise additions to M. In the j-th test, add random noise following a Gaussian distribution to the spectral data of the training set samples to generate a perturbed training set. The perturbed training set is predicted using the initial draft of the PLS model to obtain the j-th predicted value sequence, and the mean and standard deviation of the sequence are calculated. Repeat the test M times, and calculate the ratio of the overall mean of the standard deviation of the M predicted value sequences to the overall mean of the mean of the M predicted value sequences. This ratio is defined as the coefficient of variation. The smaller the coefficient of variation, the stronger the model stability.