Near infrared quantitative analysis model migration method based on instrument state perception
Patent Information
- Application Number
- CN202611528771.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-30
- Publication Date
- 2026-11-03
AI Technical Summary
Existing technologies for model transfer between near-infrared analysis instruments suffer from problems such as wavelength nonlinearity deviation, instrument state drift, large sample requirements, inability to determine the reliability of results, and inability to adaptively acquire parameters, resulting in poor model transfer performance.
A state-sensing-based approach is adopted, which synchronously acquires instrument state data from multiple sources. The process involves spectral preprocessing, wavelength mapping, and band-specific feature extraction to construct a state-modulated low-rank migration model. This model is then jointly optimized using unlabeled spectra and a small number of labeled samples to output quantifiable uncertainty and state over-domain criteria, thus forming a measurement closed loop.
Stable model transfer was achieved under conditions of a small number of samples, wavelength residuals were reduced, model transfer accuracy was improved, wet chemical calibration workload was reduced, reliable prediction results and instrument state out-of-domain criteria were provided, spectral acquisition parameters were optimized, and a closed loop for instrument measurement was formed.
Smart Images

Figure CN123028986A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for transferring near-infrared quantitative analysis models across devices based on instrument status perception. Specifically, it relates to a method for transferring a model of grain moisture, protein, fat, starch or other physicochemical indicators established on a reference near-infrared analyzer to another near-infrared analyzer, belonging to the field of biomass energy detection service technology. Background Technology
[0002] Near-infrared quantitative analysis models are suitable for grain biomass energy detection services and are generally constructed using a large number of sample spectra with reference chemical truth values. Even if two near-infrared instruments are equipped with the same light source, spectrometer, and detector, the spectra acquired by different devices will experience domain shifts due to factors such as wavelength axis offset, inconsistent band response, slit width differences, light source aging, detector temperature fluctuations, sample cup placement deviations, and differences in analog front-end gain.
[0003] If a model built on a reference instrument is directly transferred to the target instrument, the spectrum acquired by the target instrument will exhibit absorption peak wavelength shifts, baseline and slope distortions, and heteroscedasticity in various bands, ultimately leading to significant systematic biases in the sample component prediction results. Although re-acquiring a complete set of calibration samples can eliminate these biases, obtaining wet chemical reference values is costly and time-consuming, placing a significant burden on model maintenance in multi-device scenarios.
[0004] Currently used migration techniques such as direct standardization, segmented direct standardization, and slope-intercept correction only perform static transformations on paired spectra and do not incorporate instrument operating conditions such as instrument temperature, cumulative light source operating time, and detector noise into the migration constraints. Furthermore, existing technologies lack methods for assessing the uncertainty of the migration output results and cannot adjust spectral acquisition parameters based on the correction effect feedback.
[0005] Furthermore, existing calibration schemes have several technical shortcomings: they only perform linear calibration at the intensity level, which cannot simultaneously address issues such as wavelength nonlinearity deviation, differences in local response across bands, and instrument state drift over time; the design of transfer model parameters is difficult to balance, with too many parameters relying on a large number of paired calibration samples, while too few parameters are insufficient to characterize the non-uniform spectral distortion of each band; when the actual operating state of the target instrument exceeds the calibration training coverage, the algorithm still outputs predicted values, making it impossible for operators to determine whether the measurement results are reliable; the calibration algorithm is disconnected from acquisition parameters such as integration time and number of scans, and cannot achieve automated compensation in the face of low signal-to-noise ratios and light source aging. Summary of the Invention
[0006] The technical problem this invention aims to solve is to address the above-mentioned shortcomings by providing a method for cross-device migration of near-infrared quantitative analysis models based on instrument state perception. This method resolves issues such as wavelength nonlinearity deviation, instrument state drift, large sample requirements, inability to determine the reliability of results, and inability to adaptively acquire parameters during cross-device migration of near-infrared models. It achieves stable model migration using a small number of samples. Simultaneously, it outputs quantifiable uncertainty and state over-domain criteria, and links them to control spectral acquisition parameters, forming a closed loop for instrument measurement and improving the engineering practicality of the migrated model.
[0007] To solve the above technical problems, the present invention adopts the following technical solution: A method for cross-device transfer of near-infrared quantitative analysis models based on instrument status awareness includes the following steps: Step S1: Synchronously acquire multi-source data and instrument status; Simultaneously acquire dark spectrum, reference white plate spectrum, standard characteristic peak material spectrum, and original sample spectrum of transferred sample, and simultaneously record the instrument status data corresponding to each spectrum. The instrument status data includes detector temperature, ambient temperature, light source current, cumulative working time of light source, detector gain, and integration time. Step S2: Raw spectrum preprocessing, bad pixel repair, and abnormal spectrum screening; Hardware correction, bad pixel identification and repair, and robust anomaly reduction processing are performed on the original sample intensity spectrum acquired by the target instrument to output the corrected absorbance spectrum. Step S3: Multi-peak wavelength mapping with monotonicity constraints, and spectrum resampling to the reference instrument wavelength grid; The wavelength mapping function with monotonic constraints is solved by using multiple standard characteristic peaks to correct the overall wavelength shift and local nonlinear wavelength error of the target instrument, and the spectrum of the target instrument is resampled and aligned to the wavelength grid of the reference instrument. Step S4: Extract spectral features by waveband and construct a standardized instrument state vector; The response ratio, noise variance, baseline intercept, baseline slope and saturation point percentage of the wavelength-aligned spectrum are calculated for each band. Combined with the instrument hardware operating parameters and the optimal wavelength mapping parameters, the instrument state vector is obtained by splicing and standardizing. Step S5: Construct a state-modulated low-rank migration model and solve it jointly using unlabeled spectra and a small number of labeled samples; By utilizing the standardized instrument state vector and the target instrument calibration spectrum aligned with wavelength, and through an architecture of superimposing low-rank state residuals with a globally shared migration matrix, and combining unlabeled paired spectra with a small number of labeled transfer samples for joint optimization, the spectral migration transformation parameters that adaptively adjust with the instrument operating state are solved. Step S6: Calculation of uncertainty and state domain distance for component prediction and multi-component prediction; The migrated spectrum is input into the component prediction model at the reference instrument, which outputs the predicted values of physicochemical indicators. At the same time, multi-component uncertainty decomposition and synthesis are performed, and the Mahalanobis distance between the current state of the instrument and the training state domain of the model is calculated. Step S7, closed-loop control based on uncertainty and state distance; Using integration time and number of repeated scans as adjustable variables, a constrained discrete optimization model is constructed based on uncertainty, detection time and saturation risk. The optimal acquisition parameters are adaptively solved, and the output, re-acquisition correction or maintenance alarm is output according to the execution result of the decision branch.
[0008] Furthermore, step 2 includes the following steps: Step S21: Spectral hardware correction and absorbance conversion; Read the original intensity spectrum of the sample under the same acquisition conditions Dark spectrum Reference whiteboard spectrum , where i represents the i-th repeated data collection. For the j-th wavelength sampling point, a minimal constant ε is introduced, and the dark current subtraction, reference normalization, and absorbance conversion are performed according to the following formula: The absorbance obtained after correction ; Step S22: Identification of invalid wavelength point markers; Determine the calculation conditions for each wavelength sampling point: when the numerator is less than or equal to zero, the denominator is below the instrument's minimum effective count, or the original intensity spectrum... When the wavelength exceeds the saturation threshold of the ADC full scale, mark the wavelength point as invalid. Step S23: Damage interpolation repair and rejection of the entire spectrum; The number of consecutive invalid points on a single spectrum is counted. If the number of consecutive invalid points is less than a preset threshold, cubic spline interpolation or local polynomial interpolation is used to repair the invalid points using data from adjacent valid wavelength points. If the number of consecutive invalid points exceeds the preset threshold, the entire spectrum acquired in this acquisition is rejected directly, and this spectrum will not be included in the subsequent algorithm process. Step S24, robust anomaly reduction processing based on multiple repeated spectra; Robust anomaly reduction processing is performed using multiple repeated acquisitions of the same sample at the same wavelength position. Take multiple repeated absorbance measurements Median, calculating the absolute deviation of the median Outlier sampling points are identified using the Median Absolute Deviation (MAD) robust criterion. The discrimination formula is as follows: ; in, Let be the absorbance value corresponding to the wavelength position of the i-th spectrum; The threshold coefficient for MAD anomaly detection; the constant 1.4826 is the normal distribution conversion constant, which converts MAD into the equivalent normal standard deviation; If the conditions of the discrimination formula are met, the wavelength point of this acquisition is determined to be an outlier noise point. The calculation weight of the corresponding wavelength point is reduced, and the sampling point is not directly removed, so as to reduce the impact of single-frame random noise on subsequent calculations. Step S25: Handling band anomalies and retaining tertiary spectral data; If the difference between the reference spectrum and the dark spectrum is lower than the instrument's effective counting threshold, it is determined that the reference intensity is insufficient. The corresponding band is marked as an invalid band, and logarithmic transformation will no longer be performed on this band, and extrapolation will be prohibited. Invalid marks and abnormal codes generated during the spectral processing are synchronously bound to the spectral data.
[0009] Furthermore, step 3 includes the following steps: Step S31: Standard material spectral processing and characteristic peak extraction; Obtain the spectrum of the standard material, calculate the first and second derivatives of the spectrum, and extract P stable characteristic peaks. The selected characteristic peaks should meet the conditions of peak significance, minimum peak spacing, and stability in repeated acquisitions. Obtain the peak positions of each standard peak measured by the target instrument. and the corresponding nominal peak position on the reference instrument side. ; Step S32, wavelength mapping function initialization; Initialize wavelength mapping function The initial model uses a global translation model, and then higher-order parameters such as slope and curvature are gradually added, along with the mapping function. You can choose a quadratic polynomial, a cubic polynomial, or a piecewise monotonic spline function; Step S33: Construct an objective function with robust loss and monotonicity penalty; Construct an objective function with Huber robust loss and monotonicity penalty term, and solve for the optimal parameters of the wavelength mapping. : ; in, The parameters to be solved for the wavelength mapping function; The weight is the p-th standard characteristic peak, and the weight is related to the reciprocal of the characteristic peak signal-to-noise ratio and peak width. The Huber robust loss function is used to reduce the interference of individual outlier peaks on the fitting results; The mapped wavelength is obtained by inputting the measured peak position of the target instrument into the mapping function; This is the monotonicity penalty coefficient; Wavelength mapping function for wavelength The first derivative; the integration interval covers the entire effective wavelength range of the spectrum; Step S34: Iterative solution and monotonicity constraint verification; During the iterative solution process, the parameters are updated each time. Afterwards, all constraints were verified. Greater than 0, meaning the first derivative of the mapping function is greater than zero throughout. If the check finds a violation of monotonicity, reduce the iteration step size, or project the parameters back into the feasible region to eliminate non-physical solutions such as wavelength inversion and folding. After the iteration converges, the optimal parameters are obtained. Determine the final wavelength mapping function .
[0010] Furthermore, step 3 also includes the following steps: Step S35: Spectral wavelength transformation and area-preserving resampling; Perform wavelength transformation using the obtained wavelength mapping function: The original wavelength of the target instrument is mapped and converted to the wavelength in the coordinate system of the reference instrument; all sample spectra of the target instrument are resampled, and the resampling process uses area-preserving interpolation to protect the peak area of the spectral absorption peak from being changed by the interpolation operation. For bands that exceed the upper and lower limits of the reference instrument wavelength grid after mapping, no extrapolation is performed, and these bands are directly marked as invalid bands. After all wavelength mapping and resampling operations are completed, the wavelength-aligned target instrument spectrum is output and sent to the subsequent step S4 for band-specific spectral feature extraction. Step S36: Exception handling and result output; If the number of valid standard peaks extracted is less than 3, or the matching order of the standard peaks does not satisfy the monotonic relationship, the wavelength peak matching is determined to be unsuccessful. The most recent valid wavelength calibration parameters are used and marked as abnormal, and online updates to the wavelength mapping model are prohibited. After all wavelength mapping and resampling operations are completed, the wavelength-aligned target instrument spectrum is output and sent to the subsequent step S4 for band-specific spectral feature extraction.
[0011] Furthermore, step 4 includes the following steps: Step S41, spectral band division; The resampled full spectrum was divided into bands, dividing the complete wavelength range into K non-overlapping analysis bands. , The bands can be divided using an equal-width method or based on the characteristic absorption range of the sample components. Each band... Includes a set of wavelength sampling points ; Step S42: Calculate the spectral characteristics band by band; For each analysis band Calculate the band response ratio respectively Band noise variance Baseline intercept Baseline slope and the proportion of band saturation points ; Calculate the band response ratio: Band Response Ratio The difference in overall gain between the target instrument and the reference instrument in the corresponding band is characterized by using the median of the response ratios at each wavelength point within the band, reducing interference from single-point noise. The calculation formula is as follows: ; in, For the target instrument wavelength The reference whiteboard spectral intensity at that location; For the target instrument wavelength Dark spectral intensity at that location; For reference instrument wavelength The reference whiteboard spectral intensity at that location; For reference instrument wavelength The dark spectral intensity at that location; ε is a very small positive number used to avoid numerical overflow when the denominator approaches zero; Calculate the band noise variance: Band noise variance To characterize the noise fluctuation level of repeated measurements of the same wavelength, absorbance is first repeatedly collected multiple times. Calculate the measurement variance, and then take the median of the variances of all wavelengths within the band as the noise variance for that band: ; in, For band The median of the calculation results for all wavelength points inside is taken. This represents the variance of a sequence of repeated measurements at the same wavelength position. To standardize the numerical dynamic range, the logarithm of the noise variance is used. Participate in subsequent state vector construction; Calculate the saturation point percentage: Perform a linear fit on the absorbance-wavelength data within the band to obtain the baseline intercept. and baseline slope These parameters respectively characterize the overall baseline shift of the band and the degree of baseline tilt with wavelength, and count the number of wavelength points within the band where the original ADC count reaches the saturation threshold. Combined with the total number of wavelength points in the band Calculate the percentage of saturation points: .
[0012] Furthermore, step 4 also includes the following steps: Step S43, concatenate the original state vectors; The instrument hardware operating parameters, which are collected and recorded synchronously with the spectrum, include detector temperature, ambient temperature, cumulative operating time of the light source, light source current, detector gain, and integration time. Simultaneously, the optimal wavelength mapping parameters obtained in the previous step are input. ; Optimal parameters for wavelength mapping Response ratio across all bands Logarithm of noise across all bands Baseline intercept Baseline slope saturation point percentage Detector temperature Ambient temperature The cumulative operating time L of the light source, the detector gain, and the integration time are sequentially concatenated to obtain the original state vector. : ; Step S44: Standardize the state vector dimension by dimension; The mean vector of each dimension of the state vector is obtained by statistically analyzing all training samples during the training phase of the transfer model. and standard deviation vector Perform dimension-by-dimensional standardization on the original state vector: ; in, The output is a standardized instrument state vector. The standardization operation eliminates the differences in dimensions and numerical magnitudes between different features and balances the influence of each state dimension on the subsequent modulation coefficients. Step S45, Dimension Validation and Downstream Output; After standardization, dimension verification is performed to confirm that the dimensions of the output state vector match the preset dimensions of the transfer model. To maintain consistency, if a dimension mismatch occurs, the state vector is rejected and not passed to the downstream model to avoid abnormal matrix operations in subsequent steps. The resulting standardized instrument state vector is then used. Input the state-modulated low-rank transfer model in step S5.
[0013] Furthermore, step 5 includes the following steps: Step S51: Solve the wavelength mapping function of the training set; Solving the wavelength mapping function using the standard characteristic peaks of the training set The wavelength mapping function is initialized using a global translation model, and then higher-order parameters such as slope and curvature are gradually introduced; the mapping parameters are verified after each update. Monotonicity constraints; when the monotonicity condition is violated, reduce the iteration step size or project the parameters back to the feasible solution region to eliminate non-physical solutions such as wavelength reversal and folding; If the wavelength mapping monotonicity constraint is still not met after the parameter update, the parameters will be rolled back to the feasible parameters of the previous round, and the parameter update will be performed again until the monotonicity constraint is met or the wavelength peak matching is determined to be unsatisfactory. Step S52: Solve for the global migration matrix and initial bias values; Perform quality screening on the original spectra of the training set: identify spectral defects with abnormal jumps in spectral intensity at single points or in local bands; if the band of consecutive defective points is too long, mark the spectrum as a suspicious sample; After completing the training set spectral resampling, the global shared migration matrix is solved using the reference whiteboard spectrum and reference-target instrument paired samples. With global fixed bias vector When the spectral matrix has a high dimension, PCA dimensionality reduction or local mapping by band should be performed on the spectrum first. Step S53, initialize the state modulation coefficients; For state modulation coefficients Perform initialization and set the standard instrument state vector. Equal to the mean of the training set states hour, This causes the state-modulated low-rank transition model to regress to one relying solely on the average instrument state of the training set. , The shared transfer model prevents significant overcorrection from occurring when the instrument is in an untrained state; When the standard instrument state vector When the state exceeds the coverage of the training set, it is determined to be an extrapolation boundary condition. The low-rank state modulation components are frozen, and correction is carried out using only the reference shared transition matrix. A boundary alarm is then output. Step S54: Construct the sample reliability weights and the joint objective function of multiple tasks; First, we construct the joint space of spectral features and instrument status, and define... It is a joint feature vector formed by splicing the spectral principal component features and the instrument state variables; To obtain the joint spatial covariance matrix, a diagonal contraction is added to the covariance matrix to ensure that the matrix is invertible; Spectral characteristics - Instrument status combined spatial Mahalanobis distance to the reference center: ,in, Joint feature vector of all samples in the training set The mean vector, i.e., the center point of the joint space samples; The overall sample weights are obtained by multiplying the reliability components, and the weight value range is limited by a pruning function. : ; in, The sample reliability weight for the i-th sample is used to weight the sample loss in the joint objective function; This is a clipping function that constrains the calculated weight values within the parentheses. Interval; less than Forced value Values greater than 1 are forced to be set to 1; It is an exponential function; Let be the Mahalanobis distance from the reference center to the i-th sample in the joint spectral-instrument state feature space; For distance attenuation scale parameters, The larger the value, the smoother the weight decay of distant samples; The spectral repeatability quality factor of the i-th sample, with a value range of 0 to 1; Let be the label reliability quality factor for the i-th sample, with a value range of 0 to 1; the factor value decreases when the label measurement error is large. This is the lower limit threshold for the weight; If a sample's distance from the reference center in the combined spatial distance of spectral features and instrument status exceeds a set threshold, it is identified as an outlier spectrum. The sample's label loss weight is reduced, but it is still retained in the spectral alignment loss calculation. Samples with excessively low weights are fully retained in the audit log, but they no longer participate in the supervised label loss calculation. The unlabeled spectrum corresponding to the sample can still participate in the training of the state modulation low-rank transfer model for the estimation of wavelength axis and spectral response differences. The spectral shift transformation is as follows: ,in, The predicted spectrum is migrated to the spectral domain of the reference instrument; The transfer matrix adopts an architecture of superimposed low-rank state residuals on a globally shared matrix, thereby controlling the number of parameters in the state-modulated low-rank transfer model and adapting it to transfer scenarios with few samples. ; ; in, This is the state-related transition matrix; The migration matrix is shared globally. This represents the total number of low-rank bases; Low-rank component summation index, value ; For the first The first-order state modulation coefficients are the normalized instrument state vectors. The function; For the first Group of left low-rank basis matrices; For the first The transpose of a group of right-low-rank basis matrices; To constitute the first Low-rank residual matrix; This is the state-dependent bias vector; It is a globally fixed bias vector; This is the state bias coefficient matrix; A multi-task joint migration and component prediction objective function is constructed. The optimization objective is not only to minimize the spectral difference between the target instrument and the reference instrument, but also to impose constraints on the prediction errors of multiple components, the preservation of spectral characteristic peak positions, and the shape of the local second derivative of the spectrum. The loss terms corresponding to different components are weighted according to the uncertainty of the reference detection method and the importance of the business. The objective function expression is as follows: ; in, For spectral alignment loss; The label prediction loss for the m-th component; To maintain peak position and avoid losses; For the smoothing loss of the second derivative of the spectrum, For the L2 regularization term of the state-modulated low-rank transfer model parameters, , , , , These are the weights for spectral loss, component loss, peak fitting loss, spectral smoothing term, and parameter regularization, respectively. The component loss weights satisfy: ; in, Let be the measurement variance of the true value of the reference instrument for the m-th sample, and represent the measurement uncertainty of the physicochemical true value of the standard sample itself. Let Variance be the migration model prediction variance for the m-th sample, representing the model uncertainty introduced by the cross-device migration model to the sample's spectral prediction. The higher the stability of the reference detection method and the higher the reliability of the current model itself, the greater the loss weight of the corresponding component task.
[0014] Furthermore, step 5 also includes the following steps: Step S55: Alternately minimize the iterative update parameters; The globally shared migration matrix is updated alternately using an alternating minimization iterative strategy. Global fixed bias vector Low-rank basis matrix , and state modulation parameters After each round of parameter iteration and update, calculate the spectral alignment loss, label prediction loss, peak preservation loss, second derivative smoothing loss, and model parameter norm, and record the total loss of the objective function in this round. If the number of available labeled samples is less than the preset threshold, only the bias term will be updated during the optimization process. ; During the iteration process, the convergence status is monitored synchronously: when the objective function continues to rise and the loss oscillation cannot be reduced, it is determined that the iteration is diverging; it automatically reverts to the effective parameters of the previous round, reduces the optimization step size, and restarts the iteration. Step S56: Determine the termination condition for the iteration; The iteration stops when one of the following conditions is met: Numerical convergence: The relative decrease of the objective function between two adjacent iterations is less than a preset threshold, and the condition is met continuously for a specified number of iterations; Parameter convergence: The update magnitude of all learnable parameters in the state-modulated low-rank transfer model is less than the preset parameter update threshold. Iteration limit stop: The relative decrease of the objective function is less than 10 for 5 consecutive iterations. -5 The migration spectrum change is less than 10. -4 The maximum number of iterations is set to 100-500. The actual threshold can be adaptively adjusted according to the accuracy of the spectral data, and numerical convergence and result stability verification are carried out synchronously throughout the iterative process; Step S57: Physical rationality verification, anomaly handling, and result output; A nested validation framework is adopted. The outer layer divides the validation set according to sample batch, origin, instrument serial number or temperature range; the inner layer searches for hyperparameters such as low-rank order, regularization parameter, state modulation degree of freedom, etc.; it is forbidden to split multiple repeated measurements of the same sample into training set and validation set to avoid data leakage. The state-modulated low-rank transition model does not use the minimum of a single RMSEP as the criterion. Instead, it constructs a Pareto non-dominated solution set by comprehensively considering prediction error, cross-instrument bias, peak position error, measurement repeatability, and computational cost. Then, it selects the non-dominated solution with the lowest complexity by combining engineering business constraints. Construct a comprehensive scoring function, and normalize each indicator in advance according to the upper limit allowed by the project: ; in, The overall evaluation score for the state-modulated low-rank transfer model. , , , , Weighting coefficients for each evaluation indicator; To verify the root mean square error of the prediction set; To verify the systematic bias between the predicted mean and the true value of the validation set; This refers to the error of the spectral characteristic peaks; This represents the relative standard deviation. CPU computation time for inference of the state-modulated low-rank transition model; The optimal solution for hyperparameters satisfies hard constraints: peak position error and repeatability must not exceed thresholds. The optimal combination of hyperparameters and model parameters obtained after optimization and screening: ; , A preset upper limit threshold is set for the error of spectral characteristic peaks; this is a hard constraint, and the error of spectral characteristic peaks cannot exceed [a certain threshold]. This ensures the physical rationality of wavelength mapping; , A pre-set upper limit threshold is set for the relative standard deviation; a hard constraint, the relative standard deviation of the state-modulated low-rank transfer model measurement must not exceed [a certain value]. To ensure the stability of instrument measurements; Step S58: Physical rationality verification, result acceptance / rejection, and anomaly recovery; After the iteration terminates, the physical rationality of the model is verified and the results are accepted. Results Acceptance: If the full-band residuals of the target instrument spectrum and the reference instrument standard spectrum after resampling, the prediction error of the state-modulated low-rank transfer model of the sample component concentration are all less than their respective preset upper limits, and the wavelength mapping function maintains the monotonically increasing constraint, then the model parameters obtained in this solution are deemed valid, and the results of this set of transfer models are accepted. Result rejection: If the full-band residual of the target instrument spectrum and the reference instrument standard spectrum after resampling, or the prediction error of the model of the concentration of the sample component exceeds the allowable range, or the wavelength mapping monotonicity constraint is not valid, then the solution result of this model is rejected and the anomaly recovery process is triggered; if the prediction error of the validation set decreases but the peak position and peak area indices of the standard material deteriorate, it is determined that the state modulation low-rank migration model relies on non-physical spectral deformation to fit the label sample, and it is necessary to increase the peak shape constraint strength or reduce the degree of freedom of the state modulation low-rank migration model. Handling of abnormal boundaries: If over-transfer occurs, roll back the previous effective model and increase the smoothing constraint; if label anomalies occur, exclude the sample from the supervised loss and retain it for unsupervised spectral correction. After all verifications are passed, the migrated spectrum will be... The complete transfer model parameters are output to the downstream step S6; if the verification fails, the formal model parameters are not output, but the reason for failure and intermediate results are output, and the model solving process of this step is terminated.
[0015] Furthermore, step 6 includes the following steps: Step S61: Calculate the Mahalanobis distance in the instrument state domain; The Mahalanobis distance between the current state of the instrument and the training state domain of the model is used to measure the deviation between the current instrument operating condition and the operating condition covered by the training samples. The calculation formula is as follows: ; in, The Mahalanobis distance is the instrument's current state. This is the current standardized instrument state vector; The training set contains the mean vector of instrument states. For the instrument state covariance matrix of the training set, It is the smallest regularity coefficient; It is the identity matrix; Step S62: Multi-component uncertainty estimation and total uncertainty synthesis; The prediction uncertainty is decomposed and synthesized into four core components: the inherent uncertainty of the model itself, the random uncertainty caused by repeated spectral measurements, the correction uncertainty caused by the spectral migration residuals across instruments, and the additional uncertainty caused by the instrument state exceeding the training domain. The formula for synthesizing the total uncertainty is as follows: ; in, This represents the total prediction uncertainty after synthesis. For model uncertainty; This refers to the uncertainty of repeated measurements. This refers to the uncertainty of the spectral migration residual. , , , The weighting coefficients for each component are obtained by calibration using an independent validation dataset. The threshold for determining state out-of-domain conditions; in the formula As a state ex-domain penalty term, it has the characteristic of conditional activation, when When the instrument's operating condition is determined to be outside the model's training coverage, posing a risk of extrapolation prediction, additional uncertainty due to state out-of-domain conditions is automatically added; when When the instrument is within its effective operating range, the value returns to zero, which does not affect the evaluation of conventional prediction uncertainty. Step S63, Predicted interval coverage calibration; Based on an independent calibration set, the prediction interval is calibrated to maintain order or shape, so that the actual empirical coverage of the prediction interval at the nominal confidence level is close to the target value. When insufficient coverage occurs, the prediction interval is expanded to correct it, rather than simply lowering the output quality threshold. Prediction interval expression: ; in, These are the predicted component values output by the model. The quantile is the quantile corresponding to the confidence level of 1-α; α is the significance level. The prediction standard deviation corresponding to the input spectral sample x represents the uncertainty of the sample prediction result; Step S64, Abnormal operating condition identification and handling; For instrument status out-of-range anomalies: If the current instrument status Mahalanobis distance is greater than the set threshold, the standard sample re-examination and spectrum re-acquisition process will be initiated first to rule out accidental interference; if the status distance still exceeds the threshold after re-examination, the output of formal quantitative prediction results will be stopped to avoid the risk of extrapolation prediction. For abnormal sample detection: if it is determined that the sample loading is insufficient, the sample particle size uniformity is too large, or the difference in spectral data collected repeatedly exceeds the limit, only a sample abnormality prompt will be output, prompting the sample to be prepared and sampled again; the fixed spectral migration model parameters will not be changed throughout the process to ensure model stability.
[0016] Furthermore, step 7 includes the following steps: Step S71, candidate acquisition parameter prediction; Based on the candidate integration time t and the number of repeated scans N available for the instrument, and using pre-established historical noise-integration time curves, the signal-to-noise ratio of each band under different (t, N) combinations is estimated. and risk probability ; Step S72: Solve for the optimal acquisition parameters using constrained discrete optimization; Construct an objective function for the acquisition parameters, with the goal of minimizing the overall detection cost, and solve for the optimal integration time and number of repeated scans. : ; in, This is a time-consuming cost item for detection; This is the cost term for predicting uncertainty; This is the cost term for spectral saturation risk. , , These are the corresponding weight coefficients; Simultaneously, multi-dimensional physical constraints are set: the signal-to-noise ratio of each band meets the following requirements. The probability of spectral saturation risk satisfies Furthermore, the integration time t and the number of scans N are taken from the set of discrete parameters allowed by the instrument. , ; Unrestricted increases in integration time are not permitted to mask optical path hardware failures; candidate integration times t are taken only from a preset discrete set of instruments. ; Step S73, branch logic decision execution; After solving for the optimal acquisition parameters, the closed-loop control judgment is executed according to the branch logic: Qualified output branch: When the total uncertainty of detection, spectral saturation, and instrument status Mahalanobis distance are measured. Since all three indicators are below the corresponding thresholds, the test results are deemed reliable and the prediction results are trustworthy. The final output is the predicted physicochemical value of the sample. Total forecast uncertainty And the corresponding test quality status code, indicating that the single test process has ended normally; Parameter optimization and resampling branch: If the current spectral quality or uncertainty does not meet the output criteria, but the optimization model has feasible acquisition parameter solutions, then the optimal parameters are adopted. Reacquire spectral data and return to step S2 to re-execute the entire process of preprocessing, correction, migration and prediction. The system limits the maximum number of reacquisition attempts to 1 to 3 times to avoid infinite loop detection. Abnormal Termination and Maintenance Branch: When there is no feasible solution for parameter optimization, or the number of re-acquisitions has reached the limit, or the instrument status continues to be out of range, it is determined that the current detection condition cannot meet the quantitative detection accuracy requirements, and the output of formal quantitative prediction results is prohibited. The system outputs corresponding business prompts to guide the execution of standard sample recalibration operations or prompts for instrument hardware maintenance. Step S74, Multivariate drift monitoring; Multivariate EWMA / CUSUM monitoring sequences were constructed for peak position, peak area, whiteboard response, instrument state distance, and prediction residuals of standard samples; short-term anomalies only triggered spectral reacquisition, and model update requests were only initiated after continuous drift was identified; EWMA iteration: ; in, The smoothing error of the p-th iteration is... Let p be the instantaneous error at the current moment. This is a smoothing coefficient, with a value ranging from 0 to 1. This represents the smoothing error from the previous iteration; CUSUM iteration: ; in, Let be the cumulative exceedance statistic for round p, used to continuously track the cumulative magnitude of errors exceeding the threshold. This is the cumulative over-limit statistics from the previous round. The preset allowable deviation threshold is a pre-defined upper limit for normal error. When the positive accumulation of deviation begins, The accumulated amount gradually decreases until it reaches zero; Step S75: Parallel verification of the shadow model, grayscale deployment, and automatic rollback; The near-infrared cross-device migration model, after iterative optimization, runs in shadow mode, simultaneously computing the historical playback dataset and the current test sample, without directly replacing the model used in the production environment. Only when the error, prediction interval coverage, and anomaly rate all meet the preset indicators will the iteratively optimized near-infrared cross-device migration model be launched in a gray-scale manner. If the verification fails, it will be automatically rolled back to maintain the original production model. Step S76, Data archiving and output rules; The entire process execution results, raw spectral data, intermediate parameters of each step, and model version verification codes are all fully archived and saved to meet the requirements for data traceability and result reproduction auditing. The output strictly follows the convergence and failure output rules: if the detection triggers the resource limit, the parameter has no feasible solution, or the overall quality conditions are not met, only the reason for failure and the last valid intermediate result are output. It is forbidden to output quantitative prediction values without quality indicators to ensure that all external output results have reliability endorsement.
[0017] The present invention adopts the above technical solution and has the following technical effects compared with the prior art: 1. It can distinguish between overall translation and local nonlinear wavelength errors, reduce band residuals, and improve wavelength calibration accuracy; This invention employs multiple standard characteristic peaks to solve a wavelength mapping function with monotonic constraints. Unlike traditional single-peak methods that only achieve overall translational calibration, this invention simultaneously corrects both overall wavelength shifts and local nonlinear wavelength deviations, effectively reducing wavelength residuals across different bands and eliminating cross-device system biases caused by wavelength dimensions. This provides a reliable foundation for spectral alignment and component prediction in subsequent biomass energy detection service scenarios. This gain comes from the multi-peak monotonic mapping algorithm itself, and is not achieved by increasing the number of samples, extending measurement time, or manually screening spectra.
[0018] 2. The low-rank state modulation structure balances parameter controllability and band differences, enabling efficient model transfer under conditions of few samples; This invention employs a state-modulated low-rank transfer framework, controlling the number of model parameters through low-rank decomposition while preserving the non-uniform response differences between different instrument bands. This avoids the contradiction of overfitting due to too many parameters and insufficient parameters to characterize instrument differences. Model adaptation can be completed with only a small number of transfer samples. Compared with methods such as slope-intercept correction and traditional piecewise direct standardization (PDS), RMSEP and prediction bias are significantly reduced, and the coefficient of determination R² is significantly improved on the independent validation set. This effect is brought about by the low-rank state modulation algorithm, which does not rely on expanding the calibration sample set, extending the acquisition time, or manually screening samples, thus adapting to the engineering implementation needs of grain biomass energy detection services.
[0019] 3. The combination of unlabeled spectral alignment and a small number of labeled samples for joint optimization significantly reduces the need for wet chemical calibration samples; The algorithm jointly utilizes a large number of paired unlabeled spectra for spectral domain alignment, and combines this with a small number of labeled samples containing wet chemical reference values for prediction error constraint and joint optimization. This eliminates the need to re-collect a complete calibration set, significantly reducing the costly and time-consuming wet chemical calibration workload. It achieves prediction accuracy close to that of complete recalibration with fewer labeled samples. This advantage stems from the design of the joint objective function, which is not obtained by increasing samples, extending measurements, or manually selecting data.
[0020] 4. Output quantifiable prediction uncertainty and instrument state out-of-domain criteria to avoid the risk of invalid output when the state goes out of bounds; This invention performs multi-component decomposition of prediction uncertainty and simultaneously calculates the Mahalanobis distance (state-domain distance) between the instrument state and the training domain. When the instrument's operating conditions, such as temperature and light source aging, exceed the training coverage of the transfer model, it can identify out-of-domain situations and will not directly output prediction results without prompting. Compared to traditional methods with fixed transfer parameters, it can identify drift under different temperature and light source aging conditions and provide a quantitative assessment of the reliability of measurement results. This capability comes from the uncertainty decomposition and state-domain determination modules, and is not an improvement brought about by sample size, measurement time, or manual screening.
[0021] 5. Form a measurement closed loop and dynamically adjust the spectral acquisition parameters based on the uncertainty to improve the overall performance of the instrument in actual measurement. This invention uses the calculated total uncertainty and saturation rate as feedback signals to optimize spectral acquisition hardware parameters such as integration time and number of scans in a closed loop. It automatically performs acquisition compensation under conditions such as low signal-to-noise ratio and light source aging. When the hardware cannot meet the measurement conditions, it outputs maintenance prompts, without relying on unlimited extension of acquisition time to mask hardware faults. Compared with modes with fixed integration time and fixed number of scans, it improves spectral signal-to-noise ratio and saturation rate, balancing measurement time, resampling count, and measurement success rate. This closed-loop gain is achieved through algorithm-hardware linkage optimization logic, and does not originate from sample expansion or manual intervention. Attached Figure Description
[0022] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn to scale.
[0023] Figure 1 This is the overall flowchart of the cross-device migration method for near-infrared quantitative analysis model based on instrument status perception in this invention; Figure 2 This is a schematic diagram showing the comparison before and after near-infrared cross-instrument spectral processing in this invention; Figure 3 This is a schematic diagram comparing the residuals before and after near-infrared migration processing in this invention; Figure 4 This is a schematic diagram comparing the standard peak wavelength error before and after correction in this invention; Figure 5 This is a schematic diagram comparing the prediction deviations of components before and after migration in this invention; Figure 6 This is a comparative schematic diagram of the improvement in repeatability across states in this invention; Figure 7 This is a schematic diagram illustrating the relationship between state distance and prediction uncertainty in this invention. Detailed Implementation
[0024] Examples, such as Figure 1 As shown, the method for transferring near-infrared quantitative analysis models based on instrument status awareness across devices includes the following steps: Step S1: Synchronously acquire multi-source data and instrument status; Simultaneously acquire dark spectrum, reference white plate spectrum, standard characteristic peak material spectrum, and original sample spectrum of transferred sample. Simultaneously record the instrument status data corresponding to each spectrum, including detector temperature, ambient temperature, light source current, cumulative light source working time, detector gain, and integration time. Each sample spectrum is acquired at least 3 times, and all data are bound to timestamps, sample numbers, and acquisition parameters.
[0025] Dark spectrum: The light source / incident light path is turned off for acquisition. Reacquisition is required if the temperature exceeds the limit or the integration time is changed. Reference spectrum: maintain the same integration time and gain as the sample, and eliminate saturated and low-intensity bands; Standard material spectra: At least three stable characteristic peaks distributed across the entire wavelength range are collected, used only for wavelength mapping, and not involved in component label training; Transferred samples: Select a small number of samples covering the full range of component indicators and simultaneously obtain wet chemical reference labels; All raw ADC counts are retained intact without prior smoothing.
[0026] Step S2: Raw spectrum preprocessing, bad pixel repair, and abnormal spectrum screening; After completing step S1, which involves synchronously acquiring multi-source data and instrument status, proceed to this step. This step is used to perform hardware correction, bad pixel identification and repair, and robust anomaly screening on the original sample intensity spectrum acquired by the target instrument. It suppresses spectral distortion caused by dark current, reference light fluctuations, ADC saturation, and single-point noise. After processing, the original layer, correction layer, and migration layer data are retained, and the corrected absorbance spectrum is output for use in the subsequent step S3, wavelength mapping.
[0027] Step S21: Spectral hardware correction and absorbance conversion; Read the original intensity spectrum of the sample under the same acquisition conditions Dark spectrum Reference whiteboard spectrum , where i represents the i-th repeated data collection. For the j-th wavelength sampling point, a minimal constant ε is introduced, where ε is 10 times the reference dynamic range. -8 ~10 -5 To avoid the denominator approaching 0 and causing divergence in logarithmic calculations, dark current subtraction, reference normalization, and absorbance conversion are performed according to the following formula: The absorbance obtained after correction .
[0028] Step S22: Identification of invalid wavelength point markers; Determine the calculation conditions for each wavelength sampling point: when the numerator is less than or equal to zero, the denominator is below the instrument's minimum effective count, or the original intensity spectrum... When the wavelength exceeds the saturation threshold of the ADC full scale, the wavelength point is marked as invalid.
[0029] Step S23: Damage interpolation repair and rejection of the entire spectrum; The number of consecutive invalid points on a single spectrum is counted. If the number of consecutive invalid points is less than a preset threshold, cubic spline interpolation or local polynomial interpolation is used to repair the invalid points using data from adjacent valid wavelength points. If the number of consecutive invalid points exceeds the preset threshold, the entire spectrum acquired in this acquisition is rejected directly, and this spectrum will not be included in the subsequent algorithm process.
[0030] Step S24, robust anomaly reduction processing based on multiple repeated spectra; Robust anomaly reduction processing is performed using multiple repeated acquisitions of the same sample at the same wavelength position. Take multiple repeated absorbance measurements Median, calculating the absolute deviation of the median Outlier sampling points are identified using the Median Absolute Deviation (MAD) robust criterion. The discrimination formula is as follows: ; in, Let be the absorbance value corresponding to the wavelength position of the i-th spectrum; The threshold coefficient for MAD anomaly detection is a robust detection control parameter, typically taken as 2 to 3; the constant 1.4826 is the normal distribution conversion constant, which converts MAD into an equivalent normal standard deviation.
[0031] If the conditions of the discrimination formula are met, the wavelength point of this acquisition is determined to be an outlier noise point. The calculation weight of the corresponding wavelength point is reduced, and the sampling point is not directly removed, so as to reduce the impact of single-frame random noise on subsequent calculations.
[0032] Step S25: Handling band anomalies and retaining tertiary spectral data; If the difference between the reference spectrum and the dark spectrum is lower than the instrument's effective counting threshold, it is determined that the reference intensity is insufficient. The corresponding band is marked as an invalid band, and logarithmic transformation will no longer be performed on this band, and extrapolation is prohibited. The invalid marks and abnormal codes generated during the spectral processing are synchronously bound to the spectral data. After the processing is completed, the corrected spectral input step S3 performs multi-peak wavelength mapping processing.
[0033] After completing the abnormal spectrum screening in step S2, the original unmodified layer spectral data is completely retained; the spectral data of the correction layer after bad pixel repair and absorbance conversion is saved; and the migration layer data is reserved for subsequent migration transformation.
[0034] Step S3: Multi-peak wavelength mapping with monotonicity constraints, and spectrum resampling to the reference instrument wavelength grid; After completing the original spectrum preprocessing, bad pixel repair and abnormal spectrum screening in step S2, this step is performed. The wavelength mapping relationship is solved by using multiple characteristic peaks of the standard material to correct the overall wavelength shift and local nonlinear wavelength error of the target instrument. The spectrum of the target instrument is resampled and aligned to the wavelength grid of the reference instrument to eliminate the spectral distortion caused by the inconsistency of wavelength axes between devices, and to provide wavelength-aligned spectral data for subsequent band feature extraction.
[0035] Step S31: Standard material spectral processing and characteristic peak extraction; First, obtain the spectrum of the standard material. Calculate the first and second derivatives of the standard material spectrum and extract P stable characteristic peaks. The selected characteristic peaks should satisfy the peak significance condition, the minimum peak spacing condition, and the stability condition for repeated acquisitions. Then, obtain the peak positions of each standard peak measured by the target instrument. and the corresponding nominal peak position on the reference instrument side. .
[0036] Step S32, wavelength mapping function initialization; Initialize wavelength mapping function The initial model uses a global translation model, and then higher-order parameters such as slope and curvature are gradually added, along with the mapping function. You can choose a quadratic polynomial, a cubic polynomial, or a piecewise monotonic spline function.
[0037] Step S33: Construct an objective function with robust loss and monotonicity penalty; Construct an objective function with Huber robust loss and monotonicity penalty term, and solve for the optimal parameters of the wavelength mapping. : ; in, The parameters to be solved for the wavelength mapping function; The weight is the p-th standard characteristic peak, and the weight is related to the reciprocal of the characteristic peak signal-to-noise ratio and peak width. The Huber robust loss function is used to reduce the interference of individual outlier peaks on the fitting results; The mapped wavelength is obtained by inputting the measured peak position of the target instrument into the mapping function; This is the monotonicity penalty coefficient; Wavelength mapping function for wavelength The first derivative; the integration interval covers the entire effective wavelength range of the spectrum.
[0038] Step S34: Iterative solution and monotonicity constraint verification; During the iterative solution process, the parameters are updated each time. Afterwards, all constraints were verified. Greater than 0, meaning the first derivative of the mapping function is greater than zero throughout. If the check finds a violation of monotonicity, reduce the iteration step size, or project the parameters back into the feasible region to eliminate non-physical solutions such as wavelength inversion and folding. After the iteration converges, the optimal parameters are obtained. Determine the final wavelength mapping function .
[0039] Step S35: Spectral wavelength transformation and area-preserving resampling; Perform wavelength transformation using the obtained wavelength mapping function: The original wavelength of the target instrument is mapped and converted to the wavelength in the coordinate system of the reference instrument. All sample spectra of the target instrument are resampled. The resampling process uses area-preserving interpolation to protect the peak area of the spectral absorption peak from being changed by the interpolation operation.
[0040] For bands that exceed the upper and lower limits of the reference instrument wavelength grid after mapping, no extrapolation is performed. These bands are directly marked as invalid bands. After all wavelength mapping and resampling operations are completed, the wavelength-aligned target instrument spectrum is output and sent to the subsequent step S4 for band-specific spectral feature extraction.
[0041] Step S36: Exception handling and result output; If the number of valid standard peaks extracted is less than 3, or the matching order of the standard peaks does not satisfy the monotonic relationship, the wavelength peak matching is determined to be unsuccessful. The most recent valid wavelength calibration parameters are used and marked as abnormal, and online updates to the wavelength mapping model are prohibited.
[0042] After all wavelength mapping and resampling operations are completed, the wavelength-aligned target instrument spectrum is output and sent to the subsequent step S4 for band-specific spectral feature extraction.
[0043] Step S4: Extract spectral features by waveband and construct a standardized instrument state vector; After resampling the target instrument spectrum to the reference instrument wavelength grid, this step is performed. This step aims to extract the relevant features of spectral response, noise, baseline, and saturation from the corrected spectrum by band, and combine them with the instrument hardware operating parameters to splice and standardize the instrument state vector, providing input for the subsequent state modulation low-rank transfer model, so as to realize the adaptive adjustment of the transfer transformation according to the actual working state of the instrument.
[0044] Step S41, spectral band division; The resampled full spectrum was divided into bands, dividing the complete wavelength range into K non-overlapping analysis bands. , The bands can be divided using an equal-width method or based on the characteristic absorption range of the sample components. Each band... Includes a set of wavelength sampling points .
[0045] Step S42: Calculate the spectral characteristics band by band; For each analysis band Calculate the band response ratio respectively Band noise variance Baseline intercept Baseline slope and the proportion of band saturation points .
[0046] Calculate the band response ratio: Band Response Ratio The difference in overall gain between the target instrument and the reference instrument in this band is characterized by using the median of the response ratios at each wavelength point within the band, reducing interference from single-point noise. The calculation formula is as follows: ; in, For the target instrument wavelength The reference whiteboard spectral intensity at that location; For the target instrument wavelength Dark spectral intensity at that location; For reference instrument wavelength The reference whiteboard spectral intensity at that location; For reference instrument wavelength The dark spectral intensity at that location; ε is a very small positive number used to avoid numerical overflow when the denominator approaches zero.
[0047] Calculate the band noise variance: Band noise variance To characterize the noise fluctuation level of repeated spectral measurements in this band, absorbance is first repeatedly collected at the same wavelength. Calculate the measurement variance, and then take the median of the variances of all wavelengths within the band as the noise variance for that band: ; in, For band The median of the calculation results for all wavelength points inside is taken. This represents the variance of a sequence of repeated measurements at the same wavelength position. To standardize the numerical dynamic range, the logarithm of the noise variance is used. Participate in the subsequent construction of state vectors.
[0048] Calculate the saturation point percentage: Perform a linear fit on the absorbance-wavelength data within the band to obtain the baseline intercept. and baseline slope These parameters respectively characterize the overall baseline shift of the band and the degree of baseline tilt with wavelength, and count the number of wavelength points within the band where the original ADC count reaches the saturation threshold. Combined with the total number of wavelength points in the band Calculate the percentage of saturation points: .
[0049] Step S43, concatenate the original state vectors; The instrument hardware operating parameters, which are collected and recorded synchronously with the spectrum, include detector temperature, ambient temperature, cumulative operating time of the light source, light source current, detector gain, and integration time. Simultaneously, the optimal wavelength mapping parameters obtained in the previous step are input. .
[0050] Optimal parameters for wavelength mapping Response ratio across all bands Logarithm of noise across all bands Baseline intercept Baseline slope saturation point percentage Detector temperature Ambient temperature The cumulative operating time L of the light source, the detector gain, and the integration time are sequentially concatenated to obtain the original state vector. : .
[0051] Step S44: Standardize the state vector dimension by dimension; The mean vector of each dimension of the state vector is obtained by statistically analyzing all training samples during the training phase of the transfer model. and standard deviation vector Perform dimension-by-dimensional standardization on the original state vector: ; in, The output is a standardized instrument state vector. The standardization operation eliminates the differences in dimensions and numerical magnitudes between different features and balances the influence of each state dimension on the subsequent modulation coefficients.
[0052] Step S45, Dimension Validation and Downstream Output; After standardization, dimension verification is performed to confirm that the dimensions of the output state vector match the preset dimensions of the transfer model. To maintain consistency, if a dimension mismatch occurs, the state vector is rejected and not passed to downstream models to avoid abnormal matrix operations in subsequent steps. The resulting standardized instrument state vector is then used. Input the state-modulated low-rank transfer model in step S5.
[0053] Step S5: Construct a state-modulated low-rank migration model and solve it jointly using unlabeled spectra and a small number of labeled samples; After completing step S4, the standardized instrument state vector is obtained. and the target instrument calibrated spectrum after wavelength alignment Next, this step is performed. This step constructs a state-modulated low-rank migration model and performs joint optimization by combining unlabeled paired spectral information with a small number of labeled transfer samples. Under the conditions of controlling the amount of state-modulated low-rank migration parameters and suppressing overfitting, the spectral migration transformation parameters that can be adaptively adjusted according to the instrument's operating status are solved.
[0054] Step S51: Solve the wavelength mapping function of the training set; Solving the wavelength mapping function using the standard characteristic peaks of the training set The wavelength mapping function is initialized using a global translation model, and then higher-order parameters such as slope and curvature are gradually introduced; the mapping parameters are verified after each update. Monotonicity constraints; when the monotonicity condition is violated, reduce the iteration step size or project the parameters back to the feasible solution region to eliminate non-physical solutions such as wavelength reversal and folding.
[0055] If the wavelength mapping monotonicity constraint is still not met after the parameter update, the parameters will be rolled back to the feasible parameters of the previous round, and the parameter update will be performed again until the monotonicity constraint is met or the wavelength peak matching is determined to be unsatisfactory.
[0056] Step S52: Solve for the global migration matrix and initial bias values; Perform quality screening on the original spectra of the training set: identify spectral defects with abnormal jumps in spectral intensity at single points or in local bands, and prioritize the use of neighborhood interpolation to complete the repair; if the band of consecutive defective points is too long, mark the spectrum as a suspicious sample.
[0057] After completing the training set spectral resampling, the global shared migration matrix is solved using the reference whiteboard spectrum and reference-target instrument paired samples. With global fixed bias vector When the spectral matrix has a high dimension, PCA dimensionality reduction or local mapping by band should be performed on the spectrum first to avoid the matrix ill-conditioning problem caused by directly solving the high-dimensional full matrix.
[0058] Step S53, initialize the state modulation coefficients; For state modulation coefficients Perform initialization and set the standard instrument state vector. Equal to the mean of the training set states hour, This causes the state-modulated low-rank transition model to regress to one relying solely on the average instrument state of the training set. , The shared transfer model prevents significant overcorrection from occurring when the instrument is in an untrained state.
[0059] When the standard instrument state vector When the state exceeds the coverage of the training set, it is determined to be an extrapolation boundary condition. The low-rank state modulation components are frozen, and correction is performed using only the reference shared migration matrix. A boundary alarm is then output.
[0060] Step S54: Construct the sample reliability weights and the joint objective function of multiple tasks; First, we construct the joint space of spectral features and instrument status, and define... It is a joint feature vector formed by splicing the spectral principal component features and the instrument state variables; To obtain the joint spatial covariance matrix, a diagonal shrinkage process is added to the covariance matrix to ensure matrix invertibility; the Mahalanobis distance from the joint spatial coordinates of spectral characteristics and instrument status to the reference center is: ,in, Joint feature vector of all samples in the training set The mean vector, i.e., the center point of the joint space samples; The overall sample weights are obtained by multiplying the reliability components, and the weight value range is limited by a pruning function. : ; in, The weight is the overall reliability weight of the i-th sample, used to weight the sample loss in the joint objective function; the higher the weight, the greater the contribution of the sample to the training of the state modulation low-rank transfer model. This is a clipping function that constrains the calculated weight values within the parentheses. Interval; less than Forced value Values greater than 1 are forced to be 1 to avoid extreme weight values causing training instability; The function is an exponential function, which implements Gaussian decay based on Mahalanobis distance. The farther the sample is from the baseline state, the lower the weight. Let be the Mahalanobis distance from the reference center to the i-th sample in the joint feature space of spectral and instrument status, which characterizes the degree to which the instrument status and spectral features of the sample deviate from the center of the training set; The distance decay scale parameter controls how quickly the Gaussian function decays as the Mahalanobis distance increases. The larger the value, the smoother the weight decay of distant samples; The spectral repeatability quality factor of the i-th sample ranges from 0 to 1 and characterizes the stability of repeated spectral measurements of the sample. The value of this factor decreases when the spectral noise is large or the repeatability is poor. Let be the label reliability quality factor for the i-th sample, with a value range of 0 to 1, representing the reliability of the true value of the sample's reference label; the factor value decreases when the label measurement error is large. This is the lower limit threshold for weights, which is the preset minimum allowable weight value to prevent sample weights from dropping to zero and causing the sample to become completely invalid.
[0061] If a sample's distance from the reference center in the combined spatial distance of spectral features and instrument status exceeds a set threshold, it is identified as an outlier spectrum. The sample's label loss weight is reduced, but it is still retained in the spectral alignment loss calculation. Samples with excessively low weights are fully retained in the audit log, but they no longer participate in the supervised label loss calculation. The unlabeled spectrum corresponding to the sample can still participate in the training of the state modulation low-rank transfer model for estimating wavelength axis and spectral response differences.
[0062] The spectral shift transformation is as follows: ,in, The predicted spectrum is migrated to the spectral domain of the reference instrument.
[0063] The transfer matrix adopts an architecture of superimposed low-rank state residuals on a globally shared matrix, thereby controlling the number of parameters in the state-modulated low-rank transfer model and adapting it to transfer scenarios with few samples. ; ; in, Here, is the state-dependent transition matrix, and is the normalized instrument state vector. A dynamically changing spectral linear transformation matrix is used to map the spectrum of the target instrument to the spectral domain of the reference instrument. The global shared migration matrix and the basic fixed migration matrix represent the spectral linearity correction terms of the instrument in its reference state. This represents the total number of low-rank bases, i.e., the order of the low-rank residual components, used to control the degrees of freedom of the residual model. Low-rank component summation index, value ; For the first The first-order state modulation coefficients are the normalized instrument state vectors. The function can be a linear function, a tanh bounded function, or a shallow network, used to adjust the contribution of the corresponding low-rank component according to the real-time status of the instrument. For the first Group of left low-rank basis matrices; For the first The transpose of a group of right-low-rank basis matrices; To constitute the first Low-rank residual matrix; For state-dependent bias vectors, the spectral baseline offset correction term dynamically changes with the instrument state; The baseline offset under reference instrument conditions is a globally fixed bias vector. This is the state bias coefficient matrix.
[0064] A multi-task joint migration and component prediction objective function is constructed. The optimization objective is not only to minimize the spectral difference between the target instrument and the reference instrument, but also to impose constraints on the prediction errors of multiple components, the preservation of spectral characteristic peak positions, and the shape of the local second derivative of the spectrum. The loss terms corresponding to different components are weighted according to the uncertainty of the reference detection method and the importance of the business. The objective function expression is as follows: ; in, For spectral alignment loss; The label prediction loss for the m-th component; To maintain peak position and avoid losses; For the smoothing loss of the second derivative of the spectrum, For the L2 regularization term of the state-modulated low-rank transfer model parameters, , , , , These are the weights for spectral loss, component loss, peak fitting loss, spectral smoothing term, and parameter regularization, respectively.
[0065] The component loss weights satisfy: ; in, Let be the measurement variance of the true value of the reference instrument for the m-th sample, and represent the measurement uncertainty of the physicochemical true value of the standard sample itself. Let Variance be the migration model prediction variance for the m-th sample, representing the model uncertainty introduced by the cross-device migration model to the sample's spectral prediction. The higher the stability of the reference detection method and the higher the reliability of the current model itself, the greater the loss weight of the corresponding component task.
[0066] Step S55: Alternately minimize the iterative update parameters; The globally shared migration matrix is updated alternately using an alternating minimization iterative strategy. Global fixed bias vector Low-rank basis matrix , and state modulation parameters After each round of parameter iteration and update, calculate the spectral alignment loss, label prediction loss, peak preservation loss, second derivative smoothing loss, and model parameter norm, and record the total loss of the objective function in this round.
[0067] If the number of available labeled samples is less than the preset threshold, only the bias term will be updated during the optimization process. .
[0068] During the iteration process, the convergence status is monitored synchronously: when the objective function continues to rise and the loss oscillation cannot be reduced, it is determined that the iteration is diverging; it automatically reverts to the effective parameters of the previous round, reduces the optimization step size, and restarts the iteration.
[0069] Step S56: Determine the termination condition for the iteration; The iteration stops when one of the following conditions is met: Numerical convergence: The relative decrease of the objective function between two adjacent iterations is less than a preset threshold, and the condition is met continuously for a specified number of iterations; Parameter convergence: The update magnitude of all learnable parameters in the state-modulated low-rank transfer model is less than the preset parameter update threshold. Iteration limit stop: The relative decrease of the objective function is less than 10 for 5 consecutive iterations. -5 The migration spectrum change is less than 10. -4The maximum number of iterations is set to 100-500. The actual threshold can be adjusted adaptively according to the accuracy of the spectral data, and numerical convergence and result stability verification are carried out synchronously throughout the iterative process.
[0070] Step S57: Physical rationality verification, anomaly handling, and result output; A nested validation framework is adopted. The outer layer divides the validation set according to sample batch, origin, instrument serial number or temperature range; the inner layer searches for hyperparameters such as low-rank order, regularization parameter, and state modulation degree of freedom; it is forbidden to split multiple repeated measurements of the same sample into the training set and the validation set to avoid data leakage.
[0071] The state-modulated low-rank transition model does not use the minimum of a single RMSEP as the criterion. Instead, it constructs a Pareto non-dominated solution set by comprehensively considering prediction error, cross-instrument bias, peak position error, measurement repeatability, and computational cost. Then, it selects the non-dominated solution with the lowest complexity by combining engineering business constraints.
[0072] Construct a comprehensive scoring function, and normalize each indicator in advance according to the upper limit allowed by the project: ; in, The overall evaluation score for the state-modulated low-rank transfer model. , , , , Weighting coefficients for each evaluation indicator; To validate the root mean square error of the prediction set, we characterize the overall error level of the state-modulated low-rank transfer model for predicting unknown sample components. To verify the systematic bias between the predicted mean and the true value of the validation set; This refers to the error of the spectral characteristic peaks; This represents the relative standard deviation. CPU computation time for inference of the state-modulated low-rank transition model.
[0073] The optimal solution for hyperparameters satisfies hard constraints: peak position error and repeatability must not exceed thresholds. The optimal combination of hyperparameters and model parameters obtained after optimization and screening: ; , A preset upper limit threshold is set for the error of spectral characteristic peaks; this is a hard constraint, and the error of spectral characteristic peaks cannot exceed [a certain threshold]. This ensures the physical rationality of wavelength mapping; , A pre-set upper limit threshold is set for the relative standard deviation; a hard constraint, the relative standard deviation of the state-modulated low-rank transfer model measurement must not exceed [a certain value]. This ensures the stability of the instrument's measurements.
[0074] Step S58: Physical rationality verification, result acceptance / rejection, and anomaly recovery; After the iteration terminates, the physical rationality of the model is verified and the results are accepted. Results Acceptance: If the full-band residuals of the target instrument spectrum and the reference instrument standard spectrum after resampling, the prediction error of the state-modulated low-rank transfer model of the sample component concentration are all less than their respective preset upper limits, and the wavelength mapping function maintains the monotonically increasing constraint, then the model parameters obtained in this solution are deemed valid, and the results of this transfer model are accepted.
[0075] Result rejection: If the full-band residual of the target instrument spectrum and the standard spectrum of the reference instrument after resampling, or the prediction error of the model of the concentration of the component of the sample to be tested exceeds the allowable range, or the wavelength mapping monotonicity constraint does not hold, then the solution result of this model is rejected and the anomaly recovery process is triggered; if the prediction error of the validation set decreases but the peak position and peak area index of the standard material deteriorate, it is determined that the state modulation low-rank migration model relies on non-physical spectral deformation to fit the label sample, and it is necessary to increase the peak shape constraint strength or reduce the degree of freedom of the state modulation low-rank migration model.
[0076] Handling of abnormal boundaries: If over-transfer occurs, roll back the previous effective model and increase the smoothing constraint; if label anomalies occur, exclude the sample from the supervised loss and retain it for unsupervised spectral correction.
[0077] After all verifications are passed, the migrated spectrum will be... The complete transfer model parameters are output to the downstream step S6; if the verification fails, the formal model parameters are not output, but the reason for failure and intermediate results are output, and the model solving process of this step is terminated.
[0078] Step S6: Calculation of uncertainty and state domain distance for component prediction and multi-component prediction; After completing the aforementioned spectral migration correction steps, the migrated spectrum aligned to the spectral domain of the reference instrument can be obtained. The migrated spectrum is then input into the pre-trained component prediction model on the reference instrument to achieve quantitative prediction of the sample's physicochemical properties. The corresponding predicted values of the physicochemical properties are output, and the prediction results are subjected to multi-dimensional uncertainty decomposition and quantitative evaluation. At the same time, the deviation of the instrument's current working state from the model's training state domain is calculated to achieve reliability evaluation of the prediction results, determination of the instrument's state boundary, and handling of abnormal working conditions.
[0079] Step S61: Calculate the Mahalanobis distance in the instrument state domain; The Mahalanobis distance between the current state of the instrument and the training state domain of the model is used to measure the deviation between the current instrument operating condition and the operating condition covered by the training samples. The calculation formula is as follows: ; in, The Mahalanobis distance is the instrument's current state. This is the current standardized instrument state vector; The training set contains the mean vector of instrument states. For the instrument state covariance matrix of the training set, It is the smallest regularity coefficient; It is an identity matrix.
[0080] Step S62: Multi-component uncertainty estimation and total uncertainty synthesis; The prediction uncertainty is decomposed and synthesized into four core components: the inherent uncertainty of the model itself, the random uncertainty caused by repeated spectral measurements, the correction uncertainty caused by the spectral migration residuals across instruments, and the additional uncertainty caused by the instrument state exceeding the training domain. The formula for synthesizing the total uncertainty is as follows: ; in, This represents the total prediction uncertainty after synthesis. For model uncertainty; This refers to the uncertainty of repeated measurements. This refers to the uncertainty of the spectral migration residual. , , , The weighting coefficients for each component are obtained by calibration using an independent validation dataset. To determine the state out-of-domain threshold, the 95%–99.9% quantile of the Mahalanobis distance in the training set was selected as the boundary standard for the effective state domain of the model.
[0081] in the formula As a state ex-domain penalty term, it has the characteristic of conditional activation, when When the instrument's operating condition is determined to be outside the model's training coverage, posing a risk of extrapolation prediction, additional uncertainty due to state out-of-domain conditions is automatically added; when When the instrument is within its effective operating range, the value returns to zero, which does not affect the evaluation of conventional prediction uncertainty.
[0082] Step S63, Predicted interval coverage calibration; Based on an independent calibration set, the prediction interval is calibrated to maintain order or shape, so that the actual empirical coverage of the prediction interval at the nominal confidence level (e.g., 95%) is close to the target value. When insufficient coverage occurs, the prediction interval is expanded to correct it, rather than simply lowering the output quality threshold.
[0083] Prediction interval expression: ; in, These are the predicted component values output by the model. The quantile is the quantile corresponding to the confidence level of 1-α; α is the significance level. The standard deviation of the prediction for the input spectral sample x represents the uncertainty of the prediction result.
[0084] Step S64, Abnormal operating condition identification and handling; For instrument status out-of-range anomalies: If the current instrument status Mahalanobis distance is greater than the set threshold, the standard sample re-examination and spectrum re-acquisition process will be initiated first to investigate accidental interference; if the status distance still exceeds the threshold after re-examination, the output of formal quantitative prediction results will be stopped to avoid the risk of extrapolation prediction.
[0085] For abnormal sample detection: if it is determined that the sample loading is insufficient, the sample particle size uniformity is too large, or the difference in spectral data collected repeatedly exceeds the limit, only a sample abnormality prompt will be output, prompting the sample to be prepared and sampled again; the fixed spectral migration model parameters will not be changed throughout the process to ensure model stability.
[0086] Step S7: Based on the acquisition closed-loop control of uncertainty and state distance, perform reacquisition, recalibration or maintenance alarm; After completing the component prediction, multi-component uncertainty assessment, and instrument state domain distance calculation in step S6, the closed-loop control process of this step begins. This step uses integration time t and the number of repeated scans N as adjustable optimization variables. It constructs a constrained discrete optimization model by comprehensively considering detection time, prediction uncertainty, and spectral saturation risk. The model adaptively solves for the optimal spectral acquisition parameters. Based on the current detection quality, uncertainty level, and instrument state domain out-of-domain status, it intelligently determines the output result, resampling correction, or equipment maintenance alarm, forming a complete detection closed loop and a long-term instrument drift monitoring mechanism.
[0087] Step S71, candidate acquisition parameter prediction; Based on the candidate integration time t and the number of repeated scans N available for the instrument, and using pre-established historical noise-integration time curves, the signal-to-noise ratio of each band under different (t, N) combinations is estimated. and risk probability .
[0088] Step S72: Solve for the optimal acquisition parameters using constrained discrete optimization; Construct an objective function for the acquisition parameters, with the goal of minimizing the overall detection cost, and solve for the optimal integration time and number of repeated scans. : ; in, This is a time-consuming cost item for detection; This is the cost term for predicting uncertainty; This is the cost term for spectral saturation risk. , , These are the corresponding weighting coefficients.
[0089] Simultaneously, multi-dimensional physical constraints are set to ensure that the optimized acquisition parameters are both engineering feasible and have reliable spectral quality: the signal-to-noise ratio of each band meets the following requirements. The probability of spectral saturation risk satisfies Furthermore, the integration time t and the number of scans N are taken from the set of discrete parameters allowed by the instrument. , .
[0090] This method does not allow the masking of optical path hardware failures by unrestrictedly increasing the integration time; the candidate integration time t is only taken from a preset discrete set of instruments. .
[0091] Step S73, branch logic decision execution; After solving for the optimal acquisition parameters, the closed-loop control judgment is executed according to the branch logic: Qualified output branch: When the total uncertainty of detection, spectral saturation, and instrument status Mahalanobis distance are measured. Since all three indicators are below the corresponding thresholds, the test results are deemed reliable and the prediction results are trustworthy. The final output is the predicted physicochemical value of the sample. Total forecast uncertainty The corresponding detection quality status code indicates that the single detection process has ended normally.
[0092] Parameter optimization and resampling branch: If the current spectral quality or uncertainty does not meet the output criteria, but the optimization model has feasible acquisition parameter solutions, then the optimal parameters are adopted. Reacquire spectral data and return to step S2 to re-execute the entire process of preprocessing, correction, migration, and prediction. The system limits the maximum number of reacquisition attempts to 1 to 3 times to avoid infinite loop detection.
[0093] Abnormal Termination and Maintenance Branch: When there is no feasible solution for parameter optimization, or the number of re-acquisitions has reached the upper limit, or the instrument status continues to exceed the range, it is determined that the current detection condition cannot meet the quantitative detection accuracy requirements, and the output of formal quantitative prediction results is prohibited. The system will output corresponding business prompts to guide the execution of standard sample recalibration operations or prompt the instrument hardware maintenance.
[0094] Step S74, Multivariate drift monitoring; A multivariate EWMA / CUSUM monitoring sequence is constructed for the peak position, peak area, whiteboard response, instrument status distance, and prediction residual of standard samples; short-term anomalies only trigger spectral reacquisition, and a model update request is only initiated after continuous drift is identified.
[0095] EWMA iteration: ; in, The smoothing error of the p-th iteration is... Let p be the instantaneous error at the current moment. This is a smoothing coefficient, with a value ranging from 0 to 1. This represents the smoothing error from the previous iteration.
[0096] CUSUM iteration: ; in, Let be the cumulative exceedance statistic for round p, used to continuously track the cumulative magnitude of errors exceeding the threshold. This is the cumulative over-limit statistics from the previous round. The preset allowable deviation threshold is a pre-defined upper limit for normal error. When the positive accumulation of deviation begins, The accumulated amount is gradually reduced until it reaches zero.
[0097] Step S75: Parallel verification of the shadow model, grayscale deployment, and automatic rollback; The near-infrared cross-device migration model, after iterative optimization, runs in shadow mode, simultaneously computing the historical playback dataset and the current test sample, without directly replacing the model used in the production environment. Only when the error, prediction interval coverage, and anomaly rate all meet the preset indicators will the iteratively optimized near-infrared cross-device migration model be launched in a gray-scale manner. If the verification fails, it will be automatically rolled back to maintain the original production model.
[0098] Step S76, Data archiving and output rules; The entire process execution results, raw spectral data, intermediate parameters of each step, and model version verification codes are all fully archived and saved to meet the requirements for data traceability and result reproduction auditing.
[0099] This step strictly follows the convergence and failure output rules: if the detection triggers the resource limit, the parameters have no feasible solution, or the overall quality conditions are not met, only the reason for failure and the last valid intermediate result will be output. It is forbidden to output quantitative prediction values without quality indicators to ensure that all external output results have reliability backing.
[0100] When the sample to be tested is actually tested on the machine, the software firmware level implementation can be completed according to the algorithm deployment and overall measurement execution process described below.
[0101] like Figure 2 A schematic diagram comparing near-infrared cross-instrument spectral processing before and after is shown below: Before migration correction, the original spectrum of the target instrument exhibits peak position shift, band response differences, and baseline distortion relative to the reference instrument spectrum. The spectral RMS difference is 0.061, the average peak position error is 7.8 nm, and the spectral correlation coefficient is 0.944. After correction using the method of this invention, the absorption peak position, response intensity, and baseline shape of the target instrument spectrum are highly matched with the reference instrument spectrum. The spectral RMS difference is reduced to 0.010, the average peak position error is reduced to 0.95 nm, and the spectral correlation coefficient is improved to 0.997. This invention can eliminate the spectral domain shift caused by cross-instrument processing while preserving the inherent spectral absorption characteristics of the sample. It does not introduce non-physical spectral distortion, providing high-quality spectral input for subsequent quantitative prediction.
[0102] like Figure 3 A schematic diagram comparing the residuals before and after near-infrared migration processing: Without migration correction, the RMS residual of the target instrument spectrum relative to the reference instrument spectrum is 0.058. The residual shows a significant systematic change with wavelength, which directly translates into component prediction bias. After migration correction according to this invention, the RMS residual decreases to 0.0024, and the residual fluctuates slightly around zero. The systematic spectral bias that changes with wavelength is effectively eliminated.
[0103] like Figure 4 A comparison diagram of standard peak wavelength error before and after correction is shown: Under uncorrected conditions, the average absolute peak position error of each standard characteristic peak is 7.83 nm, and the maximum peak position error is 9.1 nm, with both overall shift and local nonlinear wavelength deviation present. This invention employs multi-peak wavelength mapping with monotonicity constraints. After correction, the average absolute peak position error is reduced to 0.95 nm, and the maximum peak position error is 1.2 nm. The mapping function satisfies the monotonically increasing constraint throughout, avoiding non-physical phenomena such as wavelength reversal and folding, thus balancing wavelength correction accuracy and physical rationality. Unlike traditional single-peak calibration, which can only correct overall shift, this invention can simultaneously correct overall shift and local nonlinear wavelength error.
[0104] like Figure 5A diagram illustrating the comparison of component prediction biases before and after migration is presented. When the reference instrument model is directly deployed to the target instrument without migration correction, the root mean square error (RMSEP) of the validation set prediction is 1.52, the systematic bias (Bias) is 0.88, and the coefficient of determination is only 0.91. After employing the state-modulated low-rank migration model jointly optimized with label-free spectral alignment and a small number of labeled samples, as described in this invention, the RMSEP decreases to 0.46, and the Bias decreases to 0.05, reaching 0.99. This invention relies on low-rank decomposition to control the number of model parameters, requiring only a small number of transfer samples with wet chemical truth values to achieve high-precision model adaptation across devices, significantly reducing the cost of collecting and chemically detecting a complete set of calibration samples.
[0105] like Figure 6 A comparative diagram illustrating cross-state repeatability improvement: Without instrument state modulation compensation, the average relative standard deviation (RSD) of measurements in different instrument states is 2.82% due to fluctuations in operating conditions such as detector temperature and light source aging, with the worst batch reaching an RSD of 3.45%. This invention constructs an instrument state vector containing multi-dimensional hardware and spectral features, and adaptively compensates for spectral distortion caused by changes in instrument operating conditions through state modulation components. After compensation, the average RSD is reduced to 0.86%, and the worst batch RSD is reduced to 1.08%, significantly reducing the interference of instrument operating state drift on measurement repeatability and improving the long-term operational stability of the instrument.
[0106] like Figure 7 The diagram illustrates the relationship between state distance and prediction uncertainty: Within the instrument state domain covered by the model training set, the prediction error and prediction interval half-width remain at a low level; when the instrument operating state exceeds the coverage of the training set, the state Mahalanobis distance increases, and the prediction error and prediction interval half-width increase simultaneously. This invention can quantify the reliability of the measurement result by using the state domain Mahalanobis distance and prediction interval, identify the extrapolation boundary conditions of the instrument state, avoid outputting unreliable prediction results without prompts when the operating conditions exceed the boundary, and provide quantitative criteria for iterative convergence determination, result acceptance / rejection, and anomaly recovery.
[0107] The description of this invention is given for illustrative and descriptive purposes only and is not intended to be exhaustive or to limit the invention to the forms disclosed. Many modifications and variations will be apparent to those skilled in the art. The embodiments were chosen and described in order to better illustrate the principles and practical application of the invention and to enable those skilled in the art to understand the invention and design various embodiments with various modifications suitable for a particular purpose.
Claims
1. A method for cross-device transfer of near-infrared quantitative analysis models based on instrument status perception, characterized by: Includes the following steps: Step S1: Synchronously acquire multi-source data and instrument status; Simultaneously acquire dark spectrum, reference white plate spectrum, standard characteristic peak material spectrum, and original sample spectrum of transferred sample, and simultaneously record the instrument status data corresponding to each spectrum. The instrument status data includes detector temperature, ambient temperature, light source current, cumulative working time of light source, detector gain, and integration time. Step S2: Raw spectrum preprocessing, bad pixel repair, and abnormal spectrum screening; Hardware correction, bad pixel identification and repair, and robust anomaly reduction processing are performed on the original sample intensity spectrum acquired by the target instrument to output the corrected absorbance spectrum. Step S3: Multi-peak wavelength mapping with monotonicity constraints, and spectrum resampling to the reference instrument wavelength grid; The wavelength mapping function with monotonic constraints is solved by using multiple standard characteristic peaks to correct the overall wavelength shift and local nonlinear wavelength error of the target instrument, and the spectrum of the target instrument is resampled and aligned to the wavelength grid of the reference instrument. Step S4: Extract spectral features by waveband and construct a standardized instrument state vector; The response ratio, noise variance, baseline intercept, baseline slope and saturation point percentage of the wavelength-aligned spectrum are calculated for each band. Combined with the instrument hardware operating parameters and the optimal wavelength mapping parameters, the instrument state vector is obtained by splicing and standardizing. Step S5: Construct a state-modulated low-rank migration model and solve it jointly using unlabeled spectra and a small number of labeled samples; By utilizing the standardized instrument state vector and the target instrument calibration spectrum aligned with wavelength, and through an architecture of superimposing low-rank state residuals with a globally shared migration matrix, and combining unlabeled paired spectra with a small number of labeled transfer samples for joint optimization, the spectral migration transformation parameters that adaptively adjust with the instrument operating state are solved. Step S6: Calculation of uncertainty and state domain distance for component prediction and multi-component prediction; The migrated spectrum is input into the component prediction model at the reference instrument, which outputs the predicted values of physicochemical indicators. At the same time, multi-component uncertainty decomposition and synthesis are performed, and the Mahalanobis distance between the current state of the instrument and the training state domain of the model is calculated. Step S7, closed-loop control based on uncertainty and state distance; Using integration time and number of repeated scans as adjustable variables, a constrained discrete optimization model is constructed based on uncertainty, detection time and saturation risk. The optimal acquisition parameters are adaptively solved, and the output, re-acquisition correction or maintenance alarm is output according to the execution result of the decision branch.
2. The method for cross-device migration of near-infrared quantitative analysis model based on instrument status awareness as described in claim 1, characterized in that: Step 2 includes the following steps: Step S21: Spectral hardware calibration and absorbance conversion; Read the original intensity spectrum of the sample under the same acquisition conditions Dark spectrum Reference whiteboard spectrum , where i represents the i-th repeated data collection. For the j-th wavelength sampling point, a minimal constant ε is introduced, and the dark current subtraction, reference normalization, and absorbance conversion are performed according to the following formula: The absorbance obtained after correction ; Step S22, invalid wavelength point identification; Determine the calculation conditions for each wavelength sampling point: when the numerator is less than or equal to zero, the denominator is below the instrument's minimum effective count, or the original intensity spectrum... When the wavelength exceeds the saturation threshold of the ADC full scale, mark the wavelength point as invalid. Step S23: Bad pixel interpolation repair and rejection of the entire spectrum; The number of consecutive invalid points on a single spectrum is counted. If the number of consecutive invalid points is less than a preset threshold, cubic spline interpolation or local polynomial interpolation is used to repair the invalid points using data from adjacent valid wavelength points. If the number of consecutive invalid points exceeds the preset threshold, the entire spectrum acquired in this acquisition is rejected directly, and this spectrum will not be included in the subsequent algorithm process. Step S24, robust anomaly reduction processing based on multiple repeated spectra; Robust anomaly reduction processing is performed using multiple repeated acquisitions of the same sample at the same wavelength position. Take multiple repeated absorbance measurements Median, calculating the absolute deviation of the median Outlier sampling points are identified using the Median Absolute Deviation (MAD) robust criterion. The discrimination formula is as follows: ; in, Let be the absorbance value corresponding to the wavelength position of the i-th spectrum; is the threshold coefficient for MAD anomaly detection; the constant 1.4826 is the normal distribution conversion constant, which converts MAD into the equivalent normal standard deviation; If the conditions of the discrimination formula are met, the wavelength point of this acquisition is determined to be an outlier noise point. The calculation weight of the corresponding wavelength point is reduced, and the sampling point is not directly removed, so as to reduce the impact of single-frame random noise on subsequent calculations. Step S25: Handling band anomalies and retaining tertiary spectral data; If the difference between the reference spectrum and the dark spectrum is lower than the instrument's effective counting threshold, it is determined that the reference intensity is insufficient. The corresponding band is marked as an invalid band, and logarithmic transformation will no longer be performed on this band, and extrapolation will be prohibited. Invalid marks and abnormal codes generated during the spectral processing are synchronously bound to the spectral data.
3. The method for cross-device migration of near-infrared quantitative analysis model based on instrument status awareness as described in claim 1, characterized in that: Step 3 includes the following steps: Step S31: Standard material spectral processing and characteristic peak extraction; Obtain the spectrum of the standard material, calculate the first and second derivatives of the spectrum, and extract P stable characteristic peaks. The selected characteristic peaks should meet the conditions of peak significance, minimum peak spacing, and stability in repeated acquisitions. Obtain the peak positions of each standard peak measured by the target instrument. and the corresponding nominal peak position on the reference instrument side. ; Step S32, wavelength mapping function initialization; Initialize wavelength mapping function The initial model uses a global translation model, and then higher-order parameters such as slope and curvature are gradually added, along with the mapping function. You can choose a quadratic polynomial, a cubic polynomial, or a piecewise monotonic spline function; Step S33: Construct an objective function with robust loss and monotonicity penalty; Construct an objective function with Huber robust loss and monotonicity penalty term, and solve for the optimal parameters of the wavelength mapping. : ; in, The parameters to be solved for the wavelength mapping function; The weight is the p-th standard characteristic peak, and the weight is related to the reciprocal of the characteristic peak signal-to-noise ratio and peak width. The Huber robust loss function is used to reduce the interference of individual outlier peaks on the fitting results; The mapped wavelength is obtained by inputting the measured peak position of the target instrument into the mapping function; This is the monotonicity penalty coefficient; Wavelength mapping function for wavelength The first derivative; the integration interval covers the entire effective wavelength range of the spectrum; Step S34: Iterative solution and monotonicity constraint verification; During the iterative solution process, the parameters are updated each time. Afterwards, all constraints were verified. Greater than 0, meaning the first derivative of the mapping function is greater than zero throughout. If the check finds a violation of monotonicity, reduce the iteration step size, or project the parameters back into the feasible region to eliminate non-physical solutions such as wavelength inversion and folding. After the iteration converges, the optimal parameters are obtained. Determine the final wavelength mapping function .
4. The method for cross-device migration of near-infrared quantitative analysis model based on instrument status awareness as described in claim 3, characterized in that: Step 3 also includes the following steps: Step S35: Spectral wavelength transformation and area-preserving resampling; Perform wavelength transformation using the obtained wavelength mapping function: The original wavelength of the target instrument is mapped and converted to the wavelength in the coordinate system of the reference instrument; all sample spectra of the target instrument are resampled, and the resampling process uses area-preserving interpolation to protect the peak area of the spectral absorption peak from being changed by the interpolation operation. For bands that exceed the upper and lower limits of the reference instrument wavelength grid after mapping, no extrapolation is performed, and these bands are directly marked as invalid bands. After all wavelength mapping and resampling operations are completed, the wavelength-aligned target instrument spectrum is output and sent to the subsequent step S4 for band-specific spectral feature extraction. Step S36: Exception handling and result output; If the number of valid standard peaks extracted is less than 3, or the matching order of the standard peaks does not satisfy the monotonic relationship, the wavelength peak matching is determined to be unsuccessful. The most recent valid wavelength calibration parameters are used and marked as abnormal, and online updates to the wavelength mapping model are prohibited. After all wavelength mapping and resampling operations are completed, the wavelength-aligned target instrument spectrum is output and sent to the subsequent step S4 for band-specific spectral feature extraction.
5. The method for cross-device migration of near-infrared quantitative analysis model based on instrument status awareness as described in claim 1, characterized in that: Step 4 includes the following steps: Step S41, spectral band division; The resampled full spectrum is divided into bands, dividing the complete wavelength range into K non-overlapping analysis bands. , The bands can be divided using an equal-width method or based on the characteristic absorption range of the sample components. Each band... Includes a set of wavelength sampling points ; Step S42: Calculate the spectral characteristics band by band; For each analysis band Calculate the band response ratio respectively Band noise variance Baseline intercept Baseline slope and the proportion of band saturation points ; Calculate the band response ratio: Band Response Ratio The difference in overall gain between the target instrument and the reference instrument in the corresponding band is characterized by using the median of the response ratios at each wavelength point within the band, reducing interference from single-point noise. The calculation formula is as follows: ; in, For the target instrument wavelength The reference whiteboard spectral intensity at that location; For the target instrument wavelength Dark spectral intensity at that location; For reference instrument wavelength The reference whiteboard spectral intensity at that location; For reference instrument wavelength The dark spectral intensity at that location; ε is a very small positive number used to avoid numerical overflow when the denominator approaches zero; Calculate the band noise variance: Band noise variance To characterize the noise fluctuation level of repeated measurements of the same wavelength, absorbance is first repeatedly collected multiple times. Calculate the measurement variance, and then take the median of the variances of all wavelengths within the band as the noise variance for that band: ; in, For band The median of the calculation results for all wavelength points inside is taken. This represents the variance of a sequence of repeated measurements at the same wavelength position. To standardize the numerical dynamic range, the logarithm of the noise variance is used. Participate in subsequent state vector construction; Calculate the saturation point percentage: Perform a linear fit on the absorbance-wavelength data within the band to obtain the baseline intercept. and baseline slope These parameters respectively characterize the overall baseline shift of the band and the degree of baseline tilt with wavelength, and count the number of wavelength points within the band where the original ADC count reaches the saturation threshold. Combined with the total number of wavelength points in the band Calculate the percentage of saturation points: .
6. The method for cross-device migration of near-infrared quantitative analysis model based on instrument status awareness as described in claim 5, characterized in that: Step 4 also includes the following steps: Step S43, concatenate the original state vectors; The instrument hardware operating parameters, which are collected and recorded synchronously with the spectrum, include detector temperature, ambient temperature, cumulative operating time of the light source, light source current, detector gain, and integration time. Simultaneously, the optimal wavelength mapping parameters obtained in the previous step are input. ; Optimal parameters for wavelength mapping Response ratio across all bands Logarithm of noise across all bands Baseline intercept Baseline slope saturation point percentage Detector temperature Ambient temperature The cumulative operating time L of the light source, the detector gain, and the integration time are sequentially concatenated to obtain the original state vector. : ; Step S44: Standardize the state vector dimension by dimension; The mean vector of each dimension of the state vector is obtained by statistically analyzing all training samples during the training phase of the transfer model. and standard deviation vector Perform dimension-by-dimensional standardization on the original state vector: ; in, The output is a standardized instrument state vector. The standardization operation eliminates the differences in dimensions and numerical magnitudes between different features and balances the influence of each state dimension on the subsequent modulation coefficients. Step S45, Dimension Validation and Downstream Output; After standardization, dimension verification is performed to confirm that the dimensions of the output state vector match the preset dimensions of the transfer model. To maintain consistency, if a dimension mismatch occurs, the state vector is rejected and not passed to the downstream model to avoid abnormal matrix operations in subsequent steps. The resulting standardized instrument state vector is then used. Input the state-modulated low-rank transition model in step S5.
7. The method for cross-device migration of near-infrared quantitative analysis model based on instrument status awareness as described in claim 1, characterized in that: Step 5 includes the following steps: Step S51: Solve the wavelength mapping function of the training set; Solving the wavelength mapping function using the standard characteristic peaks of the training set The wavelength mapping function is initialized using a global translation model, and then higher-order parameters such as slope and curvature are gradually introduced; the mapping parameters are verified after each update. Monotonicity constraints; when the monotonicity condition is violated, reduce the iteration step size or project the parameters back to the feasible solution region to eliminate non-physical solutions such as wavelength reversal and folding; If the wavelength mapping monotonicity constraint is still not met after the parameter update, the parameters will be rolled back to the feasible parameters of the previous round, and the parameter update will be performed again until the monotonicity constraint is met or the wavelength peak matching is determined to be unsatisfactory. Step S52: Solve for the global migration matrix and initial bias values; Perform quality screening on the original spectra of the training set: identify spectral defects with abnormal jumps in spectral intensity at single points or in local bands; if the band of consecutive defective points is too long, mark the spectrum as a suspicious sample; After completing the training set spectral resampling, the globally shared migration matrix is solved using the reference whiteboard spectrum and reference-target instrument paired samples. With global fixed bias vector When the spectral matrix has a high dimension, PCA dimensionality reduction or local mapping by band should be performed on the spectrum first. Step S53, initialize the state modulation coefficients; For state modulation coefficients Perform initialization and set the standard instrument state vector. Equal to the mean of the training set states hour, This causes the state-modulated low-rank transition model to regress to one relying solely on the average instrument state of the training set. , The shared transfer model prevents significant overcorrection from occurring when the instrument is in an untrained state; When the standard instrument state vector When the state exceeds the coverage of the training set, it is determined to be an extrapolation boundary condition. The low-rank state modulation components are frozen, and correction is carried out using only the reference shared transition matrix. A boundary alarm is then output. Step S54: Construct the sample reliability weights and the joint objective function of multiple tasks; First, we construct the joint space of spectral features and instrument status, and define... It is a joint feature vector formed by splicing the spectral principal component features and the instrument state variables; To obtain the joint spatial covariance matrix, a diagonal contraction is added to the covariance matrix to ensure that the matrix is invertible; Spectral characteristics - Instrument status combined spatial Mahalanobis distance to the reference center: ,in, Joint feature vector of all samples in the training set The mean vector, i.e., the center point of the joint space samples; The overall sample weights are obtained by multiplying the reliability components, and the weight value range is limited by a pruning function. : ; in, The sample reliability weight for the i-th sample is used to weight the sample loss in the joint objective function. This is a clipping function that constrains the calculated weight values within the parentheses. Interval; less than Forced value Values greater than 1 are forced to be set to 1; It is an exponential function; Let be the Mahalanobis distance from the reference center to the i-th sample in the joint spectral-instrument state feature space; For distance attenuation scale parameters, The larger the value, the smoother the weight decay of distant samples; The spectral repeatability quality factor of the i-th sample, with a value range of 0 to 1; Let be the label confidence quality factor for the i-th sample, with a value range of 0 to 1; the factor value decreases when the label measurement error is large. This is the lower limit threshold for the weight; If a sample's distance from the reference center in the combined spatial distance of spectral features and instrument status exceeds a set threshold, it is identified as an outlier spectrum. The sample's label loss weight is reduced, but it is still retained in the spectral alignment loss calculation. Samples with excessively low weights are fully retained in the audit log, but they no longer participate in the supervised label loss calculation. The unlabeled spectrum corresponding to the sample can still participate in the training of the state modulation low-rank transfer model for the estimation of wavelength axis and spectral response differences. The spectral shift transformation is as follows: ,in, The predicted spectrum is migrated to the spectral domain of the reference instrument; The transfer matrix adopts an architecture of superimposed low-rank state residuals on a globally shared matrix, thereby controlling the number of parameters in the state-modulated low-rank transfer model and adapting it to transfer scenarios with few samples. ; ; in, This is the state-related transition matrix; The migration matrix is shared globally. This represents the total number of low-rank bases; Low-rank component summation index, value ; For the first The first-order state modulation coefficients are the normalized instrument state vectors. The function; For the first Group of left low-rank basis matrices; For the first The transpose of a group of right-low-rank basis matrices; To constitute the first Low-rank residual matrix; This is the state-dependent bias vector; It is a globally fixed bias vector; This is the state bias coefficient matrix; A multi-task joint migration and component prediction objective function is constructed. The optimization objective is not only to minimize the spectral difference between the target instrument and the reference instrument, but also to impose constraints on the prediction errors of multiple components, the preservation of spectral characteristic peak positions, and the shape of the local second derivative of the spectrum. The loss terms corresponding to different components are weighted according to the uncertainty of the reference detection method and the importance of the business. The objective function expression is as follows: ; in, For spectral alignment loss; The label prediction loss for the m-th component; To maintain peak position and avoid losses; For the smoothing loss of the second derivative of the spectrum, For the L2 regularization term of the state-modulated low-rank transfer model parameters, , , , , These are the weights for spectral loss, component loss, peak fitting loss, spectral smoothing term, and parameter regularization, respectively. The component loss weights satisfy: ; in, Let be the measurement variance of the true value of the reference instrument for the m-th sample, and represent the measurement uncertainty of the physicochemical true value of the standard sample itself. Let Variance be the migration model prediction variance for the m-th sample, representing the model uncertainty introduced by the cross-device migration model to the sample's spectral prediction. The higher the stability of the reference detection method and the higher the reliability of the current model itself, the greater the loss weight of the corresponding component task.
8. The method for cross-device migration of near-infrared quantitative analysis model based on instrument status awareness as described in claim 7, characterized in that: Step 5 also includes the following steps: Step S55: Alternately minimize the iteratively updated parameters; The globally shared migration matrix is updated alternately using an alternating minimization iterative strategy. Global fixed bias vector Low-rank basis matrix , and state modulation parameters After each round of parameter iteration and update, calculate the spectral alignment loss, label prediction loss, peak preservation loss, second derivative smoothing loss, and model parameter norm, and record the total loss of the objective function in this round. If the number of available labeled samples is less than the preset threshold, only the bias term will be updated during the optimization process. ; During the iteration process, the convergence status is monitored synchronously: when the objective function continues to rise and the loss oscillation cannot be reduced, it is determined that the iteration is diverging; it automatically reverts to the effective parameters of the previous round, reduces the optimization step size, and restarts the iteration. Step S56: Determine the termination condition for the iteration; The iteration stops when one of the following conditions is met: Numerical convergence: The relative decrease of the objective function between two adjacent iterations is less than a preset threshold, and the condition is met continuously for a specified number of iterations; Parameter convergence: The update magnitude of all learnable parameters in the state-modulated low-rank transfer model is less than the preset parameter update threshold. Iteration limit stop: The relative decrease of the objective function is less than 10 for 5 consecutive iterations. -5 The migration spectrum change is less than 10. -4 The maximum number of iterations is set to 100-500. The actual threshold can be adaptively adjusted according to the accuracy of the spectral data, and numerical convergence and result stability verification are carried out synchronously throughout the iterative process; Step S57: Physical rationality verification, anomaly handling, and result output; A nested validation framework is adopted. The outer layer divides the validation set according to sample batch, origin, instrument serial number or temperature range; the inner layer searches for hyperparameters such as low-rank order, regularization parameter, state modulation degree of freedom, etc.; it is forbidden to split multiple repeated measurements of the same sample into training set and validation set to avoid data leakage. The state-modulated low-rank transition model does not use the minimum of a single RMSEP as the criterion. Instead, it constructs a Pareto non-dominated solution set by comprehensively considering prediction error, cross-instrument bias, peak position error, measurement repeatability, and computational cost. Then, it selects the non-dominated solution with the lowest complexity by combining engineering business constraints. Construct a comprehensive scoring function, and normalize each indicator in advance according to the upper limit allowed by the project: ; in, The overall evaluation score for the state-modulated low-rank transfer model. , , , , Weighting coefficients for each evaluation indicator; To verify the root mean square error of the prediction set; To verify the systematic bias between the predicted mean and the true value of the validation set; This refers to the error of the spectral characteristic peaks; This represents the relative standard deviation. CPU computation time for inference of the state-modulated low-rank transition model; The optimal solution for hyperparameters satisfies hard constraints: peak position error and repeatability must not exceed thresholds. The optimal combination of hyperparameters and model parameters obtained after optimization and screening: ; , A preset upper limit threshold is set for the error of spectral characteristic peaks; this is a hard constraint, and the error of spectral characteristic peaks cannot exceed [a certain threshold]. This ensures the physical rationality of wavelength mapping; , A pre-set upper limit threshold is set for the relative standard deviation; a hard constraint, the relative standard deviation of the state-modulated low-rank transfer model measurement must not exceed [a certain value]. To ensure the stability of instrument measurements; Step S58: Physical rationality verification, result acceptance / rejection, and anomaly recovery; After the iteration terminates, the physical rationality of the model is verified and the results are accepted. Results Acceptance: If the full-band residuals of the target instrument spectrum and the reference instrument standard spectrum after resampling, the prediction error of the state-modulated low-rank transfer model of the sample component concentration are all less than their respective preset upper limits, and the wavelength mapping function maintains the monotonically increasing constraint, then the model parameters obtained in this solution are deemed valid, and the results of this set of transfer models are accepted. Result rejection: If the full-band residual of the target instrument spectrum and the reference instrument standard spectrum after resampling, or the prediction error of the model of the concentration of the sample component exceeds the allowable range, or the wavelength mapping monotonicity constraint is not valid, then the solution result of this model is rejected and the anomaly recovery process is triggered; if the prediction error of the validation set decreases but the peak position and peak area indices of the standard material deteriorate, it is determined that the state modulation low-rank migration model relies on non-physical spectral deformation to fit the label sample, and it is necessary to increase the peak shape constraint strength or reduce the degree of freedom of the state modulation low-rank migration model. Handling of abnormal boundaries: If over-transfer occurs, roll back the previous effective model and increase the smoothing constraint; if label anomalies occur, exclude the sample from the supervised loss and retain it for unsupervised spectral correction. After all verifications are passed, the migrated spectrum will be... The complete transfer model parameters are output to the downstream step S6; if the verification fails, the formal model parameters are not output, but the reason for failure and intermediate results are output, and the model solving process of this step is terminated.
9. The method for cross-device migration of near-infrared quantitative analysis model based on instrument status awareness as described in claim 1, characterized in that: Step 6 includes the following steps: Step S61: Calculate the Mahalanobis distance in the instrument state domain; The Mahalanobis distance between the current state of the instrument and the training state domain of the model is used to measure the deviation between the current instrument operating condition and the operating condition covered by the training samples. The calculation formula is as follows: ; in, The Mahalanobis distance is the instrument's current state. This is the current standardized instrument state vector; The training set contains the mean vector of instrument states. For the instrument state covariance matrix of the training set, It is the smallest regularity coefficient; It is the identity matrix; Step S62: Multi-component uncertainty estimation and total uncertainty synthesis; The prediction uncertainty is decomposed and synthesized into four core components: the inherent uncertainty of the model itself, the random uncertainty caused by repeated spectral measurements, the correction uncertainty caused by the spectral migration residuals across instruments, and the additional uncertainty caused by the instrument state exceeding the training domain. The formula for synthesizing the total uncertainty is as follows: ; in, This represents the total prediction uncertainty after synthesis. For model uncertainty; This refers to the uncertainty of repeated measurements. This refers to the uncertainty of the spectral migration residual. , , , The weighting coefficients for each component are obtained by calibration using an independent validation dataset. The threshold for determining state out-of-domain conditions; in the formula As a state ex-domain penalty term, it has the characteristic of conditional activation, when When the instrument's operating condition is determined to be outside the model's training coverage, posing a risk of extrapolation prediction, additional uncertainty due to state out-of-domain conditions is automatically added; when When the instrument is within its effective operating range, the value returns to zero, which does not affect the evaluation of conventional prediction uncertainty. Step S63, Predicted interval coverage calibration; Based on an independent calibration set, the prediction interval is calibrated to maintain order or shape, so that the actual empirical coverage of the prediction interval at the nominal confidence level is close to the target value. When insufficient coverage occurs, the prediction interval is expanded to correct it, rather than simply lowering the output quality threshold. Prediction interval expression: ; in, These are the predicted component values output by the model. The quantile is the quantile corresponding to the confidence level of 1-α; α is the significance level. The prediction standard deviation corresponding to the input spectral sample x represents the uncertainty of the sample prediction result; Step S64, Abnormal operating condition identification and handling; For instrument status out-of-range anomalies: If the current instrument status Mahalanobis distance is greater than the set threshold, the standard sample re-examination and spectrum re-acquisition process will be initiated first to rule out accidental interference; if the status distance still exceeds the threshold after re-examination, the output of formal quantitative prediction results will be stopped to avoid the risk of extrapolation prediction. For abnormal sample detection: if it is determined that the sample loading is insufficient, the sample particle size uniformity is too large, or the difference in spectral data collected repeatedly exceeds the limit, only a sample abnormality prompt will be output, prompting the sample to be prepared and sampled again; the fixed spectral migration model parameters will not be changed throughout the process to ensure model stability.
10. The method for cross-device migration of near-infrared quantitative analysis model based on instrument status awareness as described in claim 1, characterized in that: Step 7 includes the following steps: Step S71, candidate acquisition parameter prediction; Based on the candidate integration time t and the number of repeated scans N available for the instrument, and using pre-established historical noise-integration time curves, the signal-to-noise ratio of each band under different (t, N) combinations is estimated. and risk probability ; Step S72: Solve for the optimal acquisition parameters using constrained discrete optimization; Construct an objective function for the acquisition parameters, with the goal of minimizing the overall detection cost, and solve for the optimal integration time and number of repeated scans. : ; in, This is a time-consuming cost item for detection; This is the cost term for predicting uncertainty; This is the cost term for spectral saturation risk. , , These are the corresponding weight coefficients; Simultaneously, multi-dimensional physical constraints are set: the signal-to-noise ratio of each band meets the following requirements. The probability of spectral saturation risk satisfies Furthermore, the integration time t and the number of scans N are taken from the set of discrete parameters allowed by the instrument. , ; Unrestricted increases in integration time are not permitted to mask optical path hardware failures; candidate integration times t are taken only from a preset discrete set of instruments. ; Step S73, branch logic decision execution; After solving for the optimal acquisition parameters, the closed-loop control judgment is executed according to the branch logic: Qualified output branches: When the total uncertainty of detection, spectral saturation, and instrument status Mahalanobis distance are measured... Since all three indicators are below the corresponding thresholds, the test results are deemed reliable and the prediction results are trustworthy. The final output is the predicted physicochemical value of the sample. Total forecast uncertainty And the corresponding test quality status code, indicating that the single test process has ended normally; Parameter optimization and resampling branch: If the current spectral quality or uncertainty does not meet the output criteria, but the optimization model has feasible acquisition parameter solutions, then the optimal parameters are adopted. Reacquire spectral data and return to step S2 to re-execute the entire process of preprocessing, correction, migration and prediction. The system limits the maximum number of reacquisition attempts to 1 to 3 times to avoid infinite loop detection. Abnormal Termination and Maintenance Branch: When there is no feasible solution for parameter optimization, or the number of re-acquisitions has reached the limit, or the instrument status continues to be out of range, it is determined that the current detection condition cannot meet the quantitative detection accuracy requirements, and the output of formal quantitative prediction results is prohibited. The system outputs corresponding business prompts to guide the execution of standard sample recalibration operations or prompts for instrument hardware maintenance. Step S74, Multivariate drift monitoring; Multivariate EWMA / CUSUM monitoring sequences were constructed for peak position, peak area, whiteboard response, instrument state distance, and prediction residuals of standard samples; short-term anomalies only triggered spectral reacquisition, and model update requests were only initiated after continuous drift was identified; EWMA iteration: ; in, The smoothing error of the p-th iteration is... Let p be the instantaneous error at the current moment. This is a smoothing coefficient, with a value ranging from 0 to 1. This represents the smoothing error from the previous iteration; CUSUM iteration: ; in, Let be the cumulative exceedance statistic for round p, used to continuously track the cumulative magnitude of errors exceeding the threshold. This is the cumulative over-limit statistics from the previous round. The preset allowable deviation threshold is a pre-defined upper limit for normal error. When the positive accumulation of deviation begins, The accumulated amount gradually decreases until it reaches zero; Step S75: Parallel verification of the shadow model, grayscale deployment, and automatic rollback; The near-infrared cross-device migration model, after iterative optimization, runs in shadow mode, simultaneously computing the historical playback dataset and the current test sample, without directly replacing the model used in the production environment. Only when the error, prediction interval coverage, and anomaly rate all meet the preset indicators will the iteratively optimized near-infrared cross-device migration model be launched in a gray-scale manner. If the verification fails, it will be automatically rolled back to maintain the original production model. Step S76, Data archiving and output rules; The entire process execution results, raw spectral data, intermediate parameters of each step, and model version verification codes are all fully archived and saved to meet the requirements for data traceability and result reproduction auditing. The output strictly follows the convergence and failure output rules: if the detection triggers the resource limit, the parameter has no feasible solution, or the overall quality conditions are not met, only the reason for failure and the last valid intermediate result are output. It is forbidden to output quantitative prediction values without quality indicators to ensure that all external output results have reliability endorsement.
