Algorithm of Stability-Analysis-Based Feature Selection for NIR Calibration Transfer

For conventional near-infrared spectroscopy (NIR) technology, even within the same sample, the NIR spectral signal can vary significantly with variation of spectrometers and the spectral collection environment. In order to improve the applicability and application of NIR prediction models, effective calibration transfer is essential. In this study, a stability-analysis-based feature selection algorithm (SAFS) for NIR calibration transfer is proposed, which is used to extract effective spectral band information with high stability between the master and slave instruments during the calibration transfer process. The stability of the spectrum bands shared between the master and slave instruments is used as the evaluation index, and the genetic algorithm was used to select suitable thresholds to filter out the spectral feature information suitable for calibration transfer. The proposed SAFS algorithm was applied to two near-infrared datasets of corn oil content and larch wood density. Simultaneously, its calibration transfer performances were compared with two classical feature selection methods. The effects of different preprocessing algorithms and calibration transfer algorithms were also assessed. The model with the feature variables selected by the SAFS obtained the best prediction. The SAFS algorithm can simplify the spectral data to be transferred and improve the transfer efficiency, and the universality of the SAFS allows it to be used to optimize calibration transfer in various situations. By combining different preprocessing and classic feature selection methods with this, the sensitivity of the correlation between spectral data and component information are improved significantly, as well as the effect of calibration transfer, which will be deeply developed.


Introduction
As one of the green and non-destructive testing methods, near-infrared spectroscopy has been used to analyze qualitative and quantitative data by constructing multivariate correction models. At present, it has been widely used in petrochemical, pharmaceutical, agriculture, forestry, and other fields [1][2][3][4]. However, the basic characteristics of the tested sample, the differences in the structure and principles between spectrometers, and the variations in the detected environment all have influenced on the reliability of the model, and can cause signal drift and absorption peak shape changes in the results of near-infrared detection, resulting in the disturbed accuracy of the model [5]. Hence, ow to obtain an accurate and stable multivariate calibration mathematical model has become a central issue.
In actual production, the problem of poor generality among spectral models has hindered the development of spectral analysis technology. There are two common reasons: one is that the samples to be tested have changed. Due to the difference in time or testing environment (temperature, humidity, noise), performance differences appear between the samples used for testing and analysis, at which time, direct analysis of existing samples with the original model is not sufficient to meet the practical needs [6]. The second is the different types of spectrometers or principles of measurement. The differences in processing technology and mechanical structure lead to the difficulty of using a common model for the same batch of instruments, at the same time, the differences in instruments also hinder the sharing of production experience or scientific research technology [7]. Calibration transfer is one of the effective methods to solve the above technical problem at present [8], which eliminates the time-consuming nature and workload of model reconstruction and has far-reaching implications for the application and development of NIR techniques.
In recent years, miniaturized near-infrared spectrometers have been favored by the majority of manufacturers and markets. With their flexibility and versatility, they are widely used in medical, industrial, agricultural, and other fields [9]. However, it is difficult to share data between different spectrometers due to the different manufacturing processes and specifications of various miniaturized spectrometers, which limits the development of NIR spectroscopy in the current big data context. At present, some researches have been devoted to the calibration transfer between small-scale near-infrared spectrometers and laboratory spectrometers [10], the calibration transfer between different small-scale near-infrared spectrometers [11], and the calibration transfer between different tested samples [12]. However, there are still few systematic studies in this field, and further exploration is necessary.
Traditional calibration transfer algorithms have been widely used, and are often used to compare and test the reliability of new algorithms. They can be divided into two categories according to their having or not having standard samples. Standardless samples analysis methods, such as orthogonal signal correction (OSC) [13], finite impulse response (FIR) [14], etc., have been widely applied to transform and reduce the dimension of the spectrum in the pretreatment stage, thereby enhancing the readability of the spectrum and reducing the influence of noise and other irrelevant factors on the spectrum. Standard samples analysis methods normally construct the conversion coefficient matrix between the master and slave instruments by standardizing the data, to achieve the data reconstruction of the slave instrument, including direct standardization (DS) [15], piecewise direct standardization (PDS) [16], slope-bias correction (SBC) [17], Shenk's algorithm [18], etc. Recently, some novel algorithms-such as data-standardization-based spectral space transformation (SST) [19], factor-analysis-based canonical correlation analysis algorithm (CCA) [20], and mapping spectral data to low-dimensional space, based the spectral regression method [21], etc.-have been reported, which confirmed that these methods had better calibration transfer effects than traditional methods.
The traditional algorithm requires high similarity between transfer objects and a large number of labeled samples, which limits the transferability and application range of near-infrared technology. Therefore, a variety of calibration transfer algorithms have been proposed from different directions, such as non-linearity, machine learning, transfer learning, and standardless samples. Liu et al. [22] proposed an approach for calibration transfer, based on the alternating trilinear decomposition (ATLD) method combined the master and slave instruments spectrum data to form a three-way spectral matrix, and calculated the coefficients in the relative intensity to standardize the data. Liu et al. [23] proposed a linear model correction (LMC) method for calibration transfer without standard samples, using the constrained optimization method to standardize the coefficients of the models between the two instruments to achieve calibration transfer. Based on the principle of transfer learning, Yu et al. [24] had been achieved calibration transfer for different types of samples by using principal component analysis (PCA) combined with boosting extreme learning machine (ELM). Li et al. [25] used partial least squares to reduce the dimensionality of data, indicating that the prediction of constructed model was improved through transfer learning. Considering that there may be a nonlinear relationship between the instruments, Shan et al. [26] proposed a nonlinear calibration transfer method based on joint kernel subspace. According to the nonlinear characteristics between the master and slave instruments, the spectral data was reconstructed, and then the nuclear partial least quadratic method was used to establish the transfer model, through comparison, obtaining a similar result as the linear method. However, the full bands or the characteristic bands of the master instrument are often used in the modeling of the above methods. Although the efficiency is improved in this way, the corresponding characteristic bands between the master and slave instruments are ignored. Therefore, many targeted feature selection methods have been proposed for calibration transfer [27][28][29] to improve efficiency and prediction accuracy. Xu et al. [30] proposed a correlation-analysis-based wavelength selection method (CAWS); it constructed the Pearson's correlation coefficient matrix of the correlation between the master and slave instruments data, and determined the most suitable characteristic wavelength for calibration transfer according to the threshold value, finding that the improvement of prediction was obvious under full-spectrum conditions. Li et al. [31] proposed a new relative error analysis (REA) wavelength selection method based on relative errors, reducing redundant variables between delivery models, and calibration transfer of different fruit products was realized. Zhang et al. [32] combined screening wavelengths with consistent and stable signals (SWCSS) algorithm with traditional feature selection methods to further filter the feature wavelengths used for calibration transfer and improve the accuracy of the model. When using these methods to select features, only the relevant analysis is performed on the wavelength of the master and slave instruments, but the influence of the instability of the wavelength drift is not considered, and some of them are too complicated, which reduces the efficiency of calibration transfer.
Among the shortcomings of the above methods, we propose a stability-analysis-based feature selection algorithm (SAFS). According to the characteristics of the stability [33], the joint stabilities of the spectrum between the master and slave instruments are calculated by SAFS, the wavelengths with high stability are selected to construct the master model and calibration transfer for the slave model. Meanwhile, the genetic algorithm is used to determine the appropriate threshold to ensure a close relationship between the wavelength and the target component. The wavelength selected by the SAFS algorithm is not optimal for the construction of the master model, but the prediction accuracy and robustness of the slave model has been improved significantly, because it is an algorithm designed for calibration transfer specifically. The performance of the proposed SAFS algorithm was verified by using corn data, measured by different instruments, and larch wood data, involved in different moisture contents, and it was compared to those of other feature selection methods, under different pretreatment and calibration algorithm conditions.

Stability-Analysis-Based Feature Selection Method (SAFS)
In the partial least squares (PLS), the independent variable, X m×n , and the dependent variable, Y m×1 , have the following linear relationship [34]: For spectral data, the independent variable, X, is an m × n response matrix containing m samples and n spectral response variables; the dependent variable, Y, is the component information corresponding to m samples; β is a coefficient vector containing n regression coefficients; and E is the random error vector. The absolute value of β and E can reflect the contribution of each response variable to the built model, and the valid information variables of the spectrum are distinguished. According to this feature, we propose the SAFS algorithm. The specific process follows.
First, master and slave instruments samples are divided into correction set, validation set, and prediction set, according to the same ratio. Using the Monte Carlo method, the calibration sets a and b of the master and slave instruments are randomly sampled at a fixed ratio, P, and modeled separately. Monte Carlo sampling has been executed K times in total. The characteristic wavelengths can be measured by the stability index, and the where a ij and b ij represent the regression coefficient measured by the jth Monte Carlo sampling at the ith response variable using the master and slave instruments, respectively. a i and b i represent the mean value of the regression coefficient measured at the ith response variable in the K times of Monte Carlo sampling using the master and slave instruments, respectively. c i is the ratio of the mean value to the standard deviation of the regression coefficient, which is used to measure stability. Determine the maximum value |c i | max and minimum value |c i | min of |c i | as the optimal value range of the stability threshold, T (T (|c i | min , |c i | max )). According to the property of stability, if the regression coefficient measured by the master and slave instruments had a high average value and a low standard deviation, the stability would be high, and the corresponding ith response variable would be important, and its modeling and prediction ability has been improved, so that all |c i | > T corresponding response variables were characteristic wavelengths. Using the characteristic wavelengths selected by SAFS, the transferred prediction set is substituted into the master model and assessed the prediction result. The optimization process of SAFS algorithm is shown in Figure 1. the calibration sets a and b of the master and slave instruments are randomly sampled a fixed ratio, P, and modeled separately. Monte Carlo sampling has been executed K tim in total. The characteristic wavelengths can be measured by the stability index, and absolute value of the stability of each wavelength point can be calculated. The definit of stability is as follows [35]: where aij and bij represent the regression coefficient measured by the jth Monte Carlo sa pling at the ith response variable using the master and slave instruments, respectively. and⎯bi represent the mean value of the regression coefficient measured at the ith respon variable in the K times of Monte Carlo sampling using the master and slave instrumen respectively. ci is the ratio of the mean value to the standard deviation of the regress coefficient, which is used to measure stability. Determine the maximum value |ci|max and minimum value |ci|min of |ci| as the op mal value range of the stability threshold, T (T (|ci|min, |ci|max)). According to the prope of stability, if the regression coefficient measured by the master and slave instruments h a high average value and a low standard deviation, the stability would be high, and corresponding ith response variable would be important, and its modeling and predict ability has been improved, so that all |ci| > T corresponding response variables were ch acteristic wavelengths. Using the characteristic wavelengths selected by SAFS, the tra ferred prediction set is substituted into the master model and assessed the prediction sult. The optimization process of SAFS algorithm is shown in Figure 1. For the stability calculated by each Monte Carlo sampling, the regression coeffici is calculated by using 10-fold cross-validation to eliminate the overfitting in the model process ( Figure 1). The calibration transfer algorithm mainly includes three types, name the conversion matrix of the master-slave instrument spectrum data is established w sample standard; the spectrum data is converted from slave to the master instrume without sample standard; and the prediction result and component information are li arly calibrated. The SAFS algorithm can be used in combination with the above alg rithms.

Determination of the Optimal Threshold of SAFS with Genetic Algorithm
In stability analysis, the selection of the optimal threshold value is crucial. If threshold value is too large, some valid feature information may be eliminated, wh some invalid information and noise may be introduced if the threshold value is too sm For the stability calculated by each Monte Carlo sampling, the regression coefficient is calculated by using 10-fold cross-validation to eliminate the overfitting in the modeling process ( Figure 1). The calibration transfer algorithm mainly includes three types, namely, the conversion matrix of the master-slave instrument spectrum data is established with sample standard; the spectrum data is converted from slave to the master instruments without sample standard; and the prediction result and component information are linearly calibrated. The SAFS algorithm can be used in combination with the above algorithms.

Determination of the Optimal Threshold of SAFS with Genetic Algorithm
In stability analysis, the selection of the optimal threshold value is crucial. If the threshold value is too large, some valid feature information may be eliminated, while some invalid information and noise may be introduced if the threshold value is too small. In this study, a genetic algorithm (GA) [36] was used for threshold optimization. The initial population number was set to 50, the chromosome binary code length was set to 20, the maximum evolutionary algebra was set to 100, the crossover probability was set to 0.8, and the mutation probability was set to 0.1. The upper and lower wavelengths of the threshold T correspond to the maximum and minimum values of stability |c i | max and |c i | min . For the fitness function, the feature variables in the correction set of each population are screened according to the individual threshold, and the contiguous data blocks cross-validation is used to establish the PLS model for calibration transfer. Validation set for the slave instrument was then used for the above model prediction. The coefficient of determination (R 2 ) and the root mean square error of the validation set (RMSEV) were calculated and the fitness function was obtained as follows: It can be seen that a better prediction effect of the validation set is associated with larger R 2 and fitness function value, F, and a smaller RMSEV, and the stability of the wavelengths shared by the selected master and slave instruments is higher. At this time, the threshold is considered to be the best. The roulette wheel selection copy operation, probability-based crossover and mutation operations are used for the generated population to generate a new population, and the best individuals in the past are retained in the new population; finally, the algorithm iterates to meet the final conditions or reach the maximum heredity algebra, output the optimal threshold T best .

Data Processing
In this study, two datasets of near-infrared spectroscopy are used to verify the proposed SAFS algorithm. The first spectroscopy dataset is public corn sample data, downloaded from http://www.software.eigenvector.com/Data/Corn/index.html (accessed on 27 January 2022). The second dataset is larch wood samples data, which were collected from Xinghuo Forest Farm (45 • 43 5.73 N, 129 • 13 34.37 E), Fangzheng County, Heilongjiang Province, China.

Corn Dataset
The corn dataset consists of 80 corn samples measured by 2 different near-infrared spectrometers, namely: mp5 and mp6. Each spectra spanned the wavelength range from 1100 nm to 2498 nm with digitization interval of 2 nm, composing of 700 data points. In addition, the spectral data in the database are all original spectra without any preprocessing. The spectral response variable includes the moisture, oil, protein, and starch content of each corn sample. In this study, designating mp5 as the master instrument and mp6 as the slave instrument, and the oil content of the corn sample was studied. More specifically, the slave instrument data is transferred to the master instrument, and the main model is created to predict the transmitted data.

Larch Wood Dataset
The larch samples were collected from the natural secondary forest farm of larch. Four plots on the sunny side and the shaded side were set up with a plot size of 20 m × 20 m. Additionally, three typical sample trees were selected from each plot. After each sample tree was felled, the portable chain saw was used to cut multiple wood discs continuously from bottom to top near the standard diameter at breast height (1.3 m at breast height). Brought it back to the laboratory and peeled it by hand, the wood strips of 2 cm × 2 cm × 4 cm were extracted from the wooden discs with a total of 181 larch wood samples. Each sample was labeled and recorded. The samples were placed in a ventilated and dry roomtemperature (20 • C) environment for 4 weeks and their equilibrium moisture content was about 10%, then we determined the air-dried density of the wood samples according to the International Standard Organization (ISO) 13061-2: 2014 [37].
To avoid the effects caused by surface roughness, 80-mesh sandpaper was used to polish each side of the sample 5 times to make the surface roughness parameter Ra close to 12.5 µm. We controlled the temperature at 20 • C and set the moisture content to be 70%, 50%, 30%, and 10% in four groups, respectively. The air-dried wood samples were soaked in water for 20 days, and then dried in an oven, weighed, and we calculated the moisture content of the sample every 5-15 min after drying, until the moisture content of the sample was within the range of the specified variation group. When the specified moisture content value was reached, we measured the near-infrared spectrum data of the sample immediately. A portable spectrometer with a wavelength range of 350-2500 nm and composing of 2151 data points, ASD LabSpec ® Pro FR/A114260 was used to measure the spectrum. The fiber optic probe was used to scan once each at two different positions on the cross-section of the sample. Each scan time was about 1.5 s. The sample was continuously scanned 30 times during the set scan period. The average of the two measurements was taken as the original spectral data.
It shows that the NIR spectral vary to some extent with the moisture content of the wood sample (Figure 2), such as baseline drift, drift of a small part of the absorption peak, and change in the absorption peak shape. However, the overall trend as well as the absorption peak of the spectral is pretty similar. The internal structure of the wood sample is varied with moisture content, which could cause variation of the spectrum. Additionally, the location and scanning angle of the probe could also cause variation of the spectrum. In this study, we used the wood NIR model with 10% moisture content as the calibration master model, and used spectral data for wood samples at other moisture content levels (70%, 50%, 30%) as the slave model data, and the calibration transfer was investigated in terms of the measuring environment.
To avoid the effects caused by surface roughness, 80-mesh sandpaper was used to polish each side of the sample 5 times to make the surface roughness parameter Ra close to 12.5 μm. We controlled the temperature at 20 °C and set the moisture content to be 70%, 50%, 30%, and 10% in four groups, respectively. The air-dried wood samples were soaked in water for 20 days, and then dried in an oven, weighed, and we calculated the moisture content of the sample every 5-15 min after drying, until the moisture content of the sample was within the range of the specified variation group. When the specified moisture content value was reached, we measured the near-infrared spectrum data of the sample immediately. A portable spectrometer with a wavelength range of 350-2500 nm and composing of 2151 data points, ASD LabSpec ® Pro FR/A114260 was used to measure the spectrum. The fiber optic probe was used to scan once each at two different positions on the cross-section of the sample. Each scan time was about 1.5 s. The sample was continuously scanned 30 times during the set scan period. The average of the two measurements was taken as the original spectral data.
It shows that the NIR spectral vary to some extent with the moisture content of the wood sample (Figure 2), such as baseline drift, drift of a small part of the absorption peak, and change in the absorption peak shape. However, the overall trend as well as the absorption peak of the spectral is pretty similar. The internal structure of the wood sample is varied with moisture content, which could cause variation of the spectrum. Additionally, the location and scanning angle of the probe could also cause variation of the spectrum. In this study, we used the wood NIR model with 10% moisture content as the calibration master model, and used spectral data for wood samples at other moisture content levels (70%, 50%, 30%) as the slave model data, and the calibration transfer was investigated in terms of the measuring environment.

Data Processing
For the corn dataset, we verified the optimized performance of various spectral preprocessing methods, and standard normal variate transformation (SNV) [38] obtained the predicted results (R 2 = 0.6993,RMSE = 0.0980). Therefore, SNV was used as the spectral preprocessing method in this study. Additionally, SNV method is the same choice as Xu

Data Processing
For the corn dataset, we verified the optimized performance of various spectral preprocessing methods, and standard normal variate transformation (SNV) [38] obtained the predicted results (R 2 = 0.6993, RMSE = 0.0980). Therefore, SNV was used as the spectral preprocessing method in this study. Additionally, SNV method is the same choice as Xu et al. [30] which can be used to evaluate the performance of the SAFS. For the larch wood dataset, the 21-point Savitzky-Golay smoothing algorithm was used to eliminate noise [39], the 1st derivative of the spectral data was used to baseline correction [40], and then we eliminated the influence of particle size and scattering on the spectrum of the sample surface by combining SNV. Specifically, the high leverage value combined with the residual Student's t-test method [41] was used to screen the singular sample numbers of the four moisture content groups in the larch wood dataset. Four groups of outlier numbers were merged into one, and the sample data corresponding to the serial number of the four groups of data were removed. Finally, 13 samples of No. 6,12,20,22,27,38,39,41,44,45,47,56, and 154 were eliminated, and a total of 168 samples of larch wood were obtained. The sample set partitioning, based on the joint x-y distances (SPXY) method [42], was used to divide the sample set into the correction set, validation set, and prediction set. Among them, the calibration set, validation set, and prediction set of corn samples each had 45, 15, and 20 samples, respectively; the calibration set, validation set, and prediction set of larch wood samples each had 95, 31, and 42 samples, respectively.
The optimal principal factor number for the calibration model was determined by principal component analysis (PCA). Four representative algorithms, PDS, SBC, SST, and OSC, were used in the calibration transfer. The SBC algorithm is a correction algorithm for the prediction result. PDS and SST algorithms are calibration transfer algorithms with standard samples which constructed a spectrum data conversion matrix between master and slave instruments. For the conversion matrix, the PDS algorithm constructs it through a moving window; the SST algorithm constructs it through singular decomposition to separate the noise and useful information. In this study, for PDS, we set the window size to 9. For SST, the one-by-one substitution method was used to calculate the number of SST factor of the validation model, and it was considered that the optimal number of SST factors occurred when RMSEV of validation model was the smallest. The OSC algorithm was a calibration transfer algorithm without standard samples.
In this study, the number of Monte Carlo iterations of the SAFS algorithm was set to 1000, and the sampling rate was set to 0.8. Four methods of the synergy interval PLS (SiPLS) [43], competitive adaptive reweighted sampling algorithm (CARS) [44], feature-free selection ("none"), and SAFS were used for wavelength selection. The calculations were run in MATLAB software, version R2017a (Mathwork, American).

Calibration Transfer of Corn Dataset
For the calibration transfer between different instruments, based on the corn dataset, the spectral wavelengths were selected by SAFS, CARS, and SiPLS methods, respectively. Additionally, then the calibration transfer results were compared and evaluated.
When using CARS method, the Monte Carlo sampling was run 50 times with sampling rate of 0.8, the PLS model was constructed using 10-fold cross-validation, in which the maximum latent variable factor was set to 15. The results showed in Figure 3 indicating that the overall trend in the number of sample variables decreased gradually, and the trend of the curve was flattening. The cross-validated root means square error (RMSECV) curve first decreased and then increased (plot a and b in Figure 3). The RMSECV had been decreasing with the elimination of irrelevant information. However, when part of the useful information was eliminated, the RMSECV increased significantly, and the model appeared over-fitting. It was interesting that with the stability of useful information became to 0, the RMSECV correspondence would also increase (plot c in Figure 3). The modeling effect is best when the number of wavelength variable subsets was 23. Finally, 50 wavelengths were selected.
When using the SiPLS method, the spectral data were divided into 30 intervals. For each interval, 4 sub-intervals were jointly divided, and the PLS model was established. The maximum number of factors for the PLS model was 15. The final sequence numbers of the optimal feature interval were 13, 14, 17, and 26 ( Figure 4). Additionally, 92 wavelengths were selected.
Predicted results of corn oil content model transferring by mp6 to mp5 under different conditions are shown in Table 1. It can be seen that the RMSECV values of the mp5 correction model are reduced to varying degrees after the optimization of the feature selection methods. However, the correction model built with the SAFS algorithm is not the best. After using different calibration transfer algorithms to predict the samples of the mp6 prediction set, it can be found that the prediction results after feature selection by the SAFS algorithm are better than others, the value of determination coefficient R 2 is maintained at a high state compared to other methods, and the root mean square error of prediction (RMSEP) is the lowest. Among them, when the PDS, SST, and OSC algorithms are used for calibration transfer, and the RMSEP values of the prediction model, optimized by the SAFS algorithm, are 0.0731, 0.0893, and 0.1320. Additionally, the R 2 values are 0.8145, 0.7234, and 0.5556, respectively. However, there is an exception that when using the SBC algorithm, the "none" feature selection prediction effect is better, and its RMSEP is lowest. However, the RMSEP of SAFS is lower than CARS and SiPLS, indicating that its generalization ability is still competent. When using the SiPLS method, the spectral data were divided into 30 intervals. For each interval, 4 sub-intervals were jointly divided, and the PLS model was established. The maximum number of factors for the PLS model was 15. The final sequence numbers of the optimal feature interval were 13, 14, 17, and 26 ( Figure 4). Additionally, 92 wavelengths were selected.   When using the SiPLS method, the spectral data were divided into 30 intervals. For each interval, 4 sub-intervals were jointly divided, and the PLS model was established. The maximum number of factors for the PLS model was 15. The final sequence numbers of the optimal feature interval were 13, 14, 17, and 26 ( Figure 4). Additionally, 92 wavelengths were selected.   At the same time, it can be found that the prediction effect of the calibration transfer algorithm with standard samples is better than the method without standard samples. Among the algorithms with standard samples, the prediction results of the PDS and SST algorithms based on the data conversion idea are better than the SBC algorithm that only corrects the prediction results. ATLD, spectral regression, and CAWS methods were used by Liu et al. [22], Peng et al. [21] and Xu et al. [30] to transfer the same data (mp6 to mp5), respectively, and the RMSEP of the results were 0.1519, 0.098, and 0.096. Compared with these methods, the results of this study under the same preprocessing and calibration transfer algorithm were better (RMSEP = 0.0731). Therefore, the SAFS algorithm is reliable in the selection of calibration transfer features.

Calibration Transfer of Larch Dataset
For calibration transfers in larch wood dataset involved in different moisture content, the wavelengths of the master and slave model spectral data were selected by CARS and SiPLS methods. The parameter settings are the same as the corn data. Finally, 70 wavelengths were selected by using the CARS method. The sequence numbers of the optimal feature intervals selected by the SiPLS method are 12, 13, 16, and 18. Additionally, a total of 92 wavelengths were selected.
Quantitative prediction model of larch wood density of 70%, 50%, 30%, and 10% moisture content were constructed, respectively. Similar to the results in Table 1, The overall prediction performance of the calibration transfer model optimized by the SAFS algorithm is the best (Tables 2-4). However, there are a few exceptions. For instance, the RMSEP value without feature selection is the lowest when the OSC method is used for calibration transfer (Table 2); the RMSEP values without feature selection were maintained at more satisfactory levels when calibration transfer was performed using the SBC and SST algorithms (Table 3). However, the SAFS algorithm still obtains the optimal transfer result in the feature selection algorithms. It can be seen that the wavelengths with greater stability between the master and slave instruments data are fully considered by SAFS when selecting feature variables.  For the larch wood prediction models transferring by 70% to 10% moisture content, the prediction effect (R 2 = 0.4852, RMSEP = 0.0475) is best, when the SAFS is used to select wavelengths and the SBC is used for calibration transfer. For larch wood prediction models transferring by 50% to 10% moisture content, the prediction effect (R 2 = 0.3263, RMSEP = 0.0563) is best, when "none" feature selection is performed, and the SBC is used for calibration transfer. For the larch wood prediction model transferring by 30% to 10% moisture content, the prediction effect of the calibration transfer by PDS algorithm is the best (R 2 = 0.5333, RMSEP = 0.0486), when the SAFS is used to select wavelengths. Therefore, the baseline drift, absorption peak drift, and partial peak shape changes of the spectrum in different detection environments can be resolved by the SAFS algorithm, thereby improving the prediction of the transfer model. As illustrated in Tables 2-4, the minimum RMSECV in different moisture content conditions of 70%, 50%, and 30% are 0.0282, 0.0281, and 0.0279, respectively, which signifies that the experimental group whose moisture content is close to the control group has a relatively good correction model when other conditions remain unchanged; the prediction accuracy of the cross-validation correction model decreases with the increase in the moisture content.
Based on the results depicted Figure 5 Most of the predicted and standard values of 70% and 50% moisture content are located above the 10% moisture content prediction straight line, indicating a tendency for the overall prediction to be higher. Additionally, most of the predicted and standard values of 30% moisture content are below the 10% moisture content prediction straight line, indicating a tendency for the overall prediction to be lower. Different moisture content affects the response function, large systematic errors will occur when the 10% moisture content model is used to predict spectra under other moisture content conditions. After feature selection by SAFS and calibration transfer by PDS, the corresponding points of the predicted value and the standard value are roughly distributed on both sides of the prediction line of the master instrument, which indicates that the calibration transfer optimized by the SAFS algorithm can eliminate most of the differences between the master and slave instruments effectively, and improve the prediction effect of the forecast set of the slave instrument significantly.

Comparison of SAFS, CARS, and SiPLS Feature Selection Results
To further explore the optimization principles of SAFS, the three feature selection methods of SAFS, CARS, and SiPLS in Table 1 are combined with the PDS algorithm for analysis. The RMSECV of cross-validation correction model established by CARS is the lowest in each group of experiments, which signifies that the selected wavelengths have the highest correlation with the target component. The comparison results of wavelengths selected by SAFS and CARS on the corn dataset are shown in Figure 6. Where the gray part is the stability value calculated by SAFS, the horizontal dashed line is the stability threshold T, and the part above the threshold represents the wavelengths selected by SAFS.
The black part represents the wavelengths selected by CARS. It can be seen that in the 1228-1250 nm, 1300-1328 nm, and 1810-1828 nm bands, the stability calculated by SAFS is greater than the threshold, but CARS did not select them, and these bands are contained in the double-frequency absorption band of the O-H bond of water molecules [45], this may be the reason for the poor calibration transfer results of the CARS model. For the 2300-2498 nm band, the wavelengths had not been selected by the SAFS are located in the first-order, double-frequency absorption band of the O-H bond of water molecules in the long-wave near-infrared analysis. This may be the main reason why the cross-validation model built by SAFS does not perform well enough. The remaining wavelengths selected by SAFS and CARS are similar. moisture content.
Based on the results depicted Figure 5 Most of the predicted and standard values of 70% and 50% moisture content are located above the 10% moisture content prediction straight line, indicating a tendency for the overall prediction to be higher. Additionally, most of the predicted and standard values of 30% moisture content are below the 10% moisture content prediction straight line, indicating a tendency for the overall prediction to be lower. Different moisture content affects the response function, large systematic errors will occur when the 10% moisture content model is used to predict spectra under other moisture content conditions. After feature selection by SAFS and calibration transfer by PDS, the corresponding points of the predicted value and the standard value are roughly distributed on both sides of the prediction line of the master instrument, which indicates that the calibration transfer optimized by the SAFS algorithm can eliminate most of the differences between the master and slave instruments effectively, and improve the prediction effect of the forecast set of the slave instrument significantly.

Comparison of SAFS, CARS, and SiPLS Feature Selection Results
To further explore the optimization principles of SAFS, the three feature selection methods of SAFS, CARS, and SiPLS in Table 1 are combined with the PDS algorithm for analysis. The RMSECV of cross-validation correction model established by CARS is the lowest in each group of experiments, which signifies that the selected wavelengths have  Tables 1-4, the RMSECV value of the model built by the SiPLS method is slightly smaller than those of the SAFS algorithm, but it yields the worst RMSEP values of all the methods. For the corn dataset with the 1228-1250 nm, 1300-1328 nm, and 1800-1828 nm band, the wavelengths selected by SiPLS is obviously missing in these parts (Figure 7). In the 1672-1762 nm and 1856-1900 nm bands, many wavelengths whose stability are far below the threshold are eliminated by SAFS, but selected by SiPLS. This may be the reason why the SiPLS model obtains the worst calibration transfer results. In the 2270-2498 nm band, similar to the CARS results, the wavelengths had been not selected by SAFS. SAFS is prone to lack of selection in the long-wave near-infrared spectroscopy, which may be caused by interference such as noise, so it can be optimized by replacing the pretreatment method or combining with the traditional feature selection method.
According to the above results, for both datasets, the models with the best calibration performance performs poorly during transmission, but the transfer model optimized by the SAFS algorithm can consistently produce the best prediction results, even though its calibration performance is not optimal. Compared with CARS and SiPLS methods, the wavelengths selected by the SAFS have more representative, which means that SAFS can eliminate the variables of poor consistency and stability between master and slave instruments better (Figures 6 and 7). Specifically, in the calibration transfer process, the consistency and stability between variables play a more important role than weights.
SAFS. The black part represents the wavelengths selected by CARS. It can be seen that in the 1228-1250 nm, 1300-1328 nm, and 1810-1828 nm bands, the stability calculated by SAFS is greater than the threshold, but CARS did not select them, and these bands are contained in the double-frequency absorption band of the O-H bond of water molecules [45], this may be the reason for the poor calibration transfer results of the CARS model. For the 2300-2498 nm band, the wavelengths had not been selected by the SAFS are located in the first-order, double-frequency absorption band of the O-H bond of water molecules in the long-wave near-infrared analysis. This may be the main reason why the cross-validation model built by SAFS does not perform well enough. The remaining wavelengths selected by SAFS and CARS are similar. As shown in Tables 1-4, the RMSECV value of the model built by the SiPLS method is slightly smaller than those of the SAFS algorithm, but it yields the worst RMSEP values of all the methods. For the corn dataset with the 1228-1250 nm, 1300-1328 nm, and 1800-1828 nm band, the wavelengths selected by SiPLS is obviously missing in these parts (Figure 7). In the 1672-1762 nm and 1856-1900 nm bands, many wavelengths whose stability are far below the threshold are eliminated by SAFS, but selected by SiPLS. This may be the reason why the SiPLS model obtains the worst calibration transfer results. In the 2270-2498 nm band, similar to the CARS results, the wavelengths had been not selected by SAFS. SAFS is prone to lack of selection in the long-wave near-infrared spectroscopy, which may be caused by interference such as noise, so it can be optimized by replacing the pretreatment method or combining with the traditional feature selection method.
According to the above results, for both datasets, the models with the best calibration performance performs poorly during transmission, but the transfer model optimized by the SAFS algorithm can consistently produce the best prediction results, even though its calibration performance is not optimal. Compared with CARS and SiPLS methods, the wavelengths selected by the SAFS have more representative, which means that SAFS can eliminate the variables of poor consistency and stability between master and slave instruments better (Figures 6 and 7). Specifically, in the calibration transfer process, the consistency and stability between variables play a more important role than weights.

Conclusions
In the process of calibration transfer, appropriate consistent feature selection can reduce the variable redundancy and improve the prediction effect of the model. Therefore, a new feature selection method is proposed, called SAFS. It is used to optimize the common wavelengths of the master and slave instruments before constructing the transfer model, reduce the data dimension, and improve the prediction and efficiency of the traditional calibration transfer algorithm. Specifically, the Monte Carlo sampling method is used to calculate the absolute value of the correlation stability of the spectral data between

Conclusions
In the process of calibration transfer, appropriate consistent feature selection can reduce the variable redundancy and improve the prediction effect of the model. Therefore, a new feature selection method is proposed, called SAFS. It is used to optimize the common wavelengths of the master and slave instruments before constructing the transfer model, reduce the data dimension, and improve the prediction and efficiency of the traditional calibration transfer algorithm. Specifically, the Monte Carlo sampling method is used to calculate the absolute value of the correlation stability of the spectral data between master and slave instruments, and the genetic algorithm is used to find the optimal threshold of transfer effect (the maximum fitness function value of genetic algorithm) to eliminate invalid information variables whose stability is lower.
Two datasets of corn and larch wood were used to verify the reliability of the method. The calibration transfer was achieved through four classical methods with different principles, and a comparative analysis was also made with other feature selection methods. The results were shown that the overall prediction performance of the transfer model established by using the characteristic wavelength selected by SAFS was the best. SAFS was an algorithm specially developed for model transfer. The model performance optimized by SAFS and traditional feature selection methods were compared and analyzed. Although the correction performance of the SAFS optimized model was not optimal, its transfer performance was still much better than the traditional method. SAFS can be used as a framework algorithm that can be further optimized by changing the preprocessing method or by combining it with traditional feature selection methods.
In summary, the SAFS algorithm has been verified in both ideal state samples (corn dataset) and actual complex samples (larch wood dataset), and its simple principle and operability can improve the accuracy and efficiency of calibration transfer, which has practical application value. In practice, there are still many factors affecting wood density, and we will further investigate the optimized performance of SAFS under the influence of multiple factors. Additionally, the experimental results of SAFS algorithm on laboratory NIR spectrometers (mp5, mp6) and portable NIR spectrometers (LabSpec) have achieved satisfactory results. The improvement of SAFS algorithm for small NIR spectrometers will be one of the next research focuses.

Data Availability Statement:
The data presented in this study are available on request from the corresponding author. The data are not publicly available due to it is being used to apply for project.