# Accurate Determination of Geographical Origin of Tea Based on Terahertz Spectroscopy
## 3 Classification Model
The principal components were created by converting the original spectral variables (i.e., the THz spectrum of tea samples) into linear combinations. The frequency range of the THz spectrum of tea samples was 0.2-1.0 THz. Therefore, the three principal components contained spectral information in the same frequency range. The contribution rates of these first three principal components reached 80.76%, 9.89%, and 3.67%, indicating that the original data set was effectively reduced into reasonable approximations via the first three principal components. A scoring drawing of the principal components of the samples can indicate their internal features and clustering information. We established a 2-D scoring drawing (Figure 5) of the first two principal components and a 3-D scoring drawing of the first three principal components (Figure 6), accordingly. Supervised learning necessitates two datasets: The training set (for modeling) and the testing set (for testing the quality of the established model). In our experiment, 40 groups of experimental data of each type of tea sample were randomly obtained as the training data and input to the SVM to establish  
Figure 4: GA-SVM algorithm flowchart. the model. The 20 remaining groups of experimental data were used as the testing set. The model as-established was then employed to classify and identify the four groups of tea samples. PCA can also be used to obtain the THz spectral features of samples and distinguish similar features across THz spectra. As shown in Figure 5, the cumulative contribution variance of the first three principal components reached 94.32%. Thus, PC1, PC2, and PC3 were selected as the featured spectrum of the green tea samples for identification with the GA-SVM model. We used the SVM to establish the classification model with a kernel function as a radius basis function. GA was applied to optimize the highest penalty factor C and kernel parameter g of the kernel function based on synchronous optimization. In the GA, various possible values of \((C,g)\) were examined and cross-verified to determine the set with the highest accuracy. The optimized SVM parameters were \(C=7.4787\) and \(g=0.10519\) (Table 1). \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Method** & **Best \(C\)** & **Best \(g\)** & **Population** & **Iteration** & **Cross-Validation** & **Train Set Accuracy** & **Consumed Time** \\ \hline GA & 7.4787 & 0.10519 & 20 & 200 & 5 & 100\% (160/160) & 7.83045 s \\ Grid & 0.35355 & 1.01034 & 20 & 200 & 5 & 100\% (160/160) & 3.64452 s \\ Search & & & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Parameters of Grid Search and genetic algorithm (GA). Figure 5: Scattered scores plot PC1, PC2. Figure 6: Scattered scores plot PC1, PC2, and PC3. The isolines of the GA and Grid Search are shown in Figure 8. The principles and approaches for parameter optimization of the two methods differ: GA requires a longer time than Grid Search (Table 1) and can optimize the overall parameters of the SVM. In the SVM model training process, the K-fold cross-validation was used. In K-fold cross-validation, the original sample is randomly partitioned into K subsamples. Of the K subsamples, a single subsample is retained as the validation data for testing the model, and the remaining K \(-\) 1 subsamples are used as training data. The cross-validation process is then repeated K times (the folds), with each of the K subsamples used exactly once as the validation data. The K results from the folds can then be averaged (or otherwise combined) to produce a single estimation. The advantage of this method over repeated random sub-sampling is that all observations are used for both training and validation, and each observation is used for validation exactly once. Five-fold cross-validation was used in this paper. In fact, the K-fold cross-validation method cannot only improve the utilization of data, but also effectively avoid over-trained and under-trained states, with the final results being more convincing.