# Evaluation of Baby Leaf Products Using Hyperspectral Imaging Techniques
## 3 Results and Discussions
### Classification Model Results  
The statistical classifier used is of the KNN (k-nearest neighbors) type. The construction phase of the statistical classifier involved the use of the experimental dataset (experimentally determined reflectance spectra and percent moisture values), and the critical moisture threshold value below which the baby-leafs crop requires irrigation intervention was considered. This threshold was determined as reported in Section 2.1, and is 0.83 (83% leaf moisture). This value could be assumed as an average limit for water deficiency, as an indirect measure of soil water content gradient expressed as a percentage of field capacity [40]. The training phase of the statistical classifier required 130 cycles of optimization to define the regularization parameters (hyperparameters), arriving at an average classification error of 15 percent, in the training phase (Figure 8). The regularization parameters given in Table 4 are regarding: number of neighbors, type of distance between neighbors, distance weights and data standardization. In particular, the Mahalanobis distance was chosen as the distance metric because it is particularly useful when working with data with a multivariate distribution, i.e., with several variables correlated with each other, as is the case with hyperspectral data. Unlike the Euclidean distance, which ignores correlations between variables, the Mahalanobis distance takes into account the covariance of the data, allowing for the better identification of outliers and the more accurate clustering of data [41]. The statistical classifier, set with the regularization parameters determined in the optimization phase, was validated with the validation dataset and then tested using the data in the test set. The performance measurement of the statistical classifier was performed by evaluating the confusion matrices for the validation and test phase, as well as the ROC curve for the two moisture classes determined. Figures 9 and 10 show, respectively, the confusion matrices for the validation and test phases of the KNN classifier. The confusion matrices presented illustrate the predicted classes on the x axis and the actual classes on the y axis. Each cell within the matrix displays percentage values, represented by a color gradient from saturated blue (indicating 100% correct classification) to saturated red (indicating 0% correct classification), with intermediate saturation levels reflecting corresponding percentages. Adjacent to the main 2 \(\times\) 2 confusion matrix, a secondary 2 \(\times\) 2 matrix is displayed on the left, indicating the \"true positive rate\" (TPR) on the left and the \"false negative rate\" on the right. It should be noted that these latter values are directly derivable from the primary confusion matrix. box); and at position 1,2 is displayed the percentage of misclassification of class one data incorrectly classified as class one data. Figure 8: Optimization cycles of the KNN statistical classifier in the training phase. Figure 9: Confusion matrix of the KNN classifier results for validation data. The analysis of the confusion matrices showed that the statistical classifier can estimate the data in the two moisture classes excellently, with 84.2% and 99.5% for classes 1 and 2, respectively, for the validation phase, and 81.3% and 99.4% for classes 1 and 2, respectively, for the test phase. An important aspect regarding the correct classification matrices should be noted. Taking the confusion matrix of the test set into analysis, the highest percentage of correct classification was obtained for class 2, that is, for the moisture dataset above the intervention threshold. This data, in a real-world application, can be very useful in order to determine the time of the start of irrigation, as it can be used as a discriminating value, meaning that all spectral data that do not fall into class 2 lead to defining a probably crop stress condition.