## 5 Results and Discussion
### The Optimal Value of the Nearest Neighbors for KNN  
From our previous discussions, it can be seen that, when the parameters are fixed, the accuracy of the SVM model can be maintained to a certain extent no matter if the quantity of training data is decreased or increased. This makes it feasible to use the cross-validation for parameter optimization and apply the same optimized parameters to all simulations. However, for the KNN method, the OA value varies significantly with the training data under a particular parameter \(K\) (number of nearest neighbors) while the cross-validation needs to separate the whole training data into small samples. Thus, it is impossible to optimize the parameter of KNN by using this kind of method. Section 5.3 indicates a possibility that the quantity of data in the smallest category determines the accuracy of the KNN method. To further verify this possibility, Figure 20 shows the variation of the 17-KNN method with training data quantity from 100 to 150. It can be seen that there are two jumps in accuracy with the increase in training data. The first jump is from 82.07% OA to 86.55% OA at the place of 107 training data (A-8, B-41, C-51, D-7) to 108 training data (A-9, B-42, C-50, D-7). The second jump is from 87.97% OA to 91.28% OA at the place of 137 training data (A-11, B-53, C-65, D-8) to 138 training data (A-10, B-53, C-65, D-9). The similarity of these two jumping points is that the amount of a particular class of data increases from 8, which is less than half of 17 (the value of K) to 9, which is more than the half of \(K\). This suggests that the possibility to be the absolute majority in voting of a certain GWC is a prerequisite for increased accuracy. Thus, to achieve the highest accuracy, the minimum condition is that the smallest GWC can be the absolute majority in voting, i.e., the sample scale of the smallest GWC needs to be more than half of the nearest neighbors. Figure 19: The Overall accuracy (OA) difference of different classification cases: (**a**) case 1: OA difference of 4-category classification for GWC A, B, C and D; (**b**) case 2: OA difference of 2-category classification for GWC A and B; (**c**) case 3: OA difference of 2-category classification for GWC B and C; (**d**) case 4: OA difference of 2-category classification for GWC C and D.  
Figure 20: The OA of the KNN method when \(K=17\). Figure 21 shows the \(K\)-OA curves with different sample scales. All four of the curves show a trend that first increases and then decreases with increasing values of \(K.\) It is worth noting that the position of the vertex corresponds with the quantity of the smallest category: for each curve, it will reach its maximum when the value of \(K\) is around the quantity of the smallest category. To further validate this correspondence between \(K\) and the quantity of training data, we compare the optimal value of the nearest neighbors \(K_{opt}\) that can achieve the highest accuracy (OA) and the minimum quantity of four GWCs with different training sample scales in Figure 22.  
In general, \(K_{opt}\) increases with the training data quantity although there may be some fluctuations. The minimum quantity of four GWCs also shows a high correlation with the best value of \(K.\) The values of the minimum quantity of four GWCs can be fitted by function (18) to bring them into correspondence with the domain of \(K\):  
\[X_{f}=2\cdot round\bigg{(}\frac{X+1}{2}\bigg{)}-1. \tag{18}\]  
Figure 21: The \(K\)-OA curves with different sample scale. Figure 22: \(K_{opt}\) and the minimum quantity of the four GWC training samples with different overall training sample scales. The correlation coefficient of \(K_{opt}\) and the fitted minimum quantity of 4 GWC is 0.9777, and the root mean square error (RMSE) between them is only 1.0057. This means that, for a classification problem with an imbalance in distributed samples such as that in our study, the best value of parameter \(K\) mainly depends on the quantity of class with the smallest sample scale.