# A Novel Method for Wheat Spike Phenotyping Based on Instance Segmentation and Classification
## 3 Results and Discussion
### Classification Results of Spiklets  
This study used different machine learning models to count the wheat grains of segmented spikelets based on the 52 spikelet image features involving shape, color, and texture features. In this study, 450 wheat spike images were collected from the field, and a total of 4193 spikelets were segmented with the number of grains per spikelet between 0 and 3 through the instance segmentation of the YOLOv8-seg model. As shown in Table 2, the training and testing accuracy of seven machine learning models, including SVM, DT, RF, GBDT, KNN, NB, and LDA, were all above 0.7, which proved that the 52 image features of the spikelets had a strong correlation with the number of their grains. The accuracy, precision, recall, and F1 score of the NB, LDA, and DT were relatively lower than those of the other four models. The results demonstrated that there was a complex nonlinear correlation between 52 image features of the spikelets and the number of their grains. The logical structures of the above three models were too simple to fully explore the nonlinear correlation, resulting in more misclassification between neighboring categories with insignificant differences in image features and lower accuracy in training and testing datasets. The KNN model improved the classification accuracy for different grain quantities by increasing the number of nearest neighbors appropriately, and the model was less insensitive to abnormal spikelet image features than other models. The RF model introduced randomness in the classification decision for different grain quantities to decrease the possibility of overfitting problems, and also realized the classification of high-dimensional spikelet image features without dimension reduction. GBDT model accumulated the classification results of multiple decision trees to count the number of spikelet grains and reduced classification losses along the direction of the fastest gradient decline of the square loss function. Therefore, KNN, GBDT, and RF had improved classification performance in accuracy, precision, recall, and F1 score of training or testing datasets. The SVM model solved the lin \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**Model**} & **A of Training** & **A of Test** & **P of Test** & **R of Test** & **F1 Score of Test** \\  & **Dataset** & **Dataset** & **Dataset** & **Dataset** & **Dataset** \\ \hline NB & 0.734 & 0.713 & 0.710 & 0.761 & 0.724 \\ \hline LDA & 0.805 & 0.797 & 0.786 & 0.823 & 0.801 \\ \hline DT & 0.818 & 0.801 & 0.793 & 0.778 & 0.780 \\ \hline KNN & 0.841 & 0.823 & 0.839 & 0.828 & 0.832 \\ \hline GBDT & 0.861 & 0.835 & 0.827 & 0.826 & 0.827 \\ \hline RF & 0.863 & 0.833 & 0.845 & 0.841 & 0.843 \\ \hline SVM & 0.870 & 0.855 & 0.860 & 0.865 & 0.863 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Classification results of the spikelets based on different models. ear inseparability problem of high-dimensional spikelet image features through the kernel function and avoided the overfitting problem caused by outliers by introducing a penalty slack variable. This study adopted the radial basis function to map high-dimensional spikelet image features and determined its optimal parameters, with the penalty slack variable as 1 and the kernel function parameter as 0.02 through the grid search method. The SVM model achieved the best classification performance among the seven machine learning models. The accuracy of training datasets, and the accuracy, precision, recall, and F1 score of testing datasets reached 0.870, 0.855, 0.860, 0.865, and 0.863, respectively. In order to further explore the feasibility and stability of SVM performance in the classification of spikelet grain quantities, this study obtained the confusion matrices and ROC curves, as shown in Figures 10 and 11. The confusion matrices demonstrated that almost all wrong classifications appeared in neighboring categories. The spikelets containing zero or one wheat grain had low classification errors.