# Detection of Defective Features in Cerasus Humilis Fruit Based on Hyperspectral Imaging Technology
## 2 Materials and Methods
### Variable Selection Methods and Classification Models  
#### 2.6.1 Selection Methods of Characteristic Wavelengths  
The characteristic wavelengths were extracted by selecting a representative with the least redundancy and collinearity from the full band that can represent the main information of the sample. This improves the running speed and reliability of the model and improves the accuracy of the prediction results [16]. In this study, we chose regression coefficient (RC), successive projections algorithm (SPA), and competitive adaptive reweighted sampling (CARS) algorithms to reduce the dimensions of the original spectral matrix and extract effective wavelengths. Finally, the optimal algorithm was obtained by comparing the model coefficients.  
The RC is also called the \(\beta\)-coefficients method. It is based on the partial least square regression (PLSR) model and used to select the characteristic wavelength according to the local extreme value of the regression coefficient. The wavelengths with high absolute values of RCs were chosen as effective wavelengths [17]. The RC method characteristic wavelength selection procedures mentioned were carried out using the Unscrambler X10.1 (CAMO AS, Oslo, Norway).  
The SPA algorithm is an effective method for the selection of characteristic variables in the spectrum [18]. When extracting the characteristic wavelength, the algorithm searches for the optimal wavelength variable based on the multiple regression analysis models. Through the projection analysis of the vector, the wavelength is projected with other wavelengths, and the maximum value of the final projection vector is selected as the characteristic wavelength. After the spectral characteristic wavelength is extracted using SPA, a group of variables with the least irrelevant information content is obtained from the full band range. This new set of variables not only eliminates the influence of collinearity between wavelength variables, but also effectively reduces the complexity of the model. SPA uses RMSE as an evaluation index and determines the number of final characteristic variables based on the smaller RMSE value.  
The CARS algorithm is a feature information filtering method that has been widely used in recent years. The algorithm is based on the PLS model. It uses adaptive reweighted sampling (ARS) technology and the exponentially decreasing function (EDF) to remove the wavelength points with smaller weight from the PLS model [19], screen out the wavelength points with the larger absolute value of the regression coefficient, and select the variable combination with the smallest cross-validation root mean square error (RMSECV) in the PLS model through cross-validation. In each sampling process, the CARS operation is divided into four consecutive steps: Monte Carlo model sampling, EDF removing variables, ARS screening variables, and calculation of the RMSECV of each subset. At last, it chooses the subset with the lowest RMSECV value as the optimal subset. The SPA and CARS algorithm characteristic wavelength selection procedures mentioned were carried out in the MATLAB R2016b (The MathWorks, Natick, MA, USA).