## 2 Materials and Methods
### Spectral Curve Analysis and Machine Learning Modeling  
As shown in Figure 2, the difference of the spectral curve in different years is mainly reflected in the VNIR (400-1000 nm) range but not in the SWIR (1000-2500 nm) bands. It is easy to distinguish between 1 and 3 years, but the samples during 4-7 years appear to be aliasing in the VNIR region, so it is difficult to form a recognition method based on the threshold or threshold ratio. The identification of growth years is a classification problem. The statistical method of machine learning is used for identification, and the random forest method, which has the advantage of analyzing high-dimensional data, was selected [26]. [PERSON] et al. proposed a method that combines terahertz spectroscopy with machine learning to identify the origin of ginseng. The identification rate of two classification models, which are random forest and support vector machines (SVM), can be achieved at 88.5% and 87.5%, respectively. Compared with the SVM model, the random forest model can obtain better results. Therefore, the random forest method was used to identify the ginseng year [27]. Random forest is a machine learning method that uses multiple weak decision trees to vote to determine the output, and it can provide the importance of the input spectral band. It contains many decision trees representing a distinct instance of the classification of data inputs into the random forest model [28]. The random forest technique considers the instances individually, taking the one with the majority of votes as the selected prediction.  
Figure 2: The spectral reflectance of ginseng samples. Ages from 1 to 7 years are marked as different colors. There are 35 samples in total. For the different illuminating angles between VNIR and SWIR cameras, the curve shows a fault on 1000 nm, which can be neglected for fixed viewing and illuminating conditions for every sample.  
Each tree in the classifications takes input from samples in the initial dataset. Features are then randomly selected, which are used in growing the tree at each node. Every tree in the forest should not be pruned until the end of the exercise when the prediction is reached decisively. In such a manner, random forest enables any classifiers with weak correlations to create a strong classifier. The random forest identification program is developed based on the scikit-learn platform using Python coding language.  
Each sample contains one spectral curve data as input, and the marked year's value is used as output. Among the 35 samples, 80% (28 samples) were used as the training data sets and 20% (7 samples) are used as the test verification data sets. Considering the number of samples (the appropriate sample number depends on the significance of data characteristics, which is difficult to evaluate before training and testing, but after the data type is determined, the larger the sample number is generally the better), training and testing for 10 instances were adopted, seven test verification data are randomly selected each time, and it is ensured that each growth year has samples participating in training. The stratified k-fold cross validation is applied in the experiments in order to effectively solve the problem of producing an unbalanced sample number. Each fold preserves the proportions of the categories in the original data, which can render the verification more credible [29].