# Evaluation of Baby Leaf Products Using Hyperspectral Imaging Techniques
## 2 Materials and Methods
### Prediction and Classification Models  
Two strategies were chosen for data analysis:  
1. Construction of a mathematical regression model for the purpose of finding a transfer function to determine leaf moisture from the hyperspectral data. 2. Construction of a mathematical classification model in order to identify a transfer function that can discriminate hyperspectral data based on a threshold value of absolute leaf moisture. To achieve this, the dataset was partitioned into two subsets based on a critical moisture threshold, identified as 83% absolute leaf moisture. This value signifies the point below which the crop enters a state of stress, thereby necessitating irrigation. For the construction of the regression model, a preliminary analysis was performed on the main existing multi-parametric models. Specifically, the Matlab 2024a toolbox contains the following classes of regression models:  
Linear regression models;  
Regression trees;  
Support vector machines;  
Efficiently trained regression models;  
Gaussian Process Regression models;  
Kernel optimization regression models;  
Ensemble of trees;  
Neural networks. All the above were used and the best one only was selected to analyze the data:  
The enumerated models necessitate a sequential process of training, validation, and testing. These three distinct steps are paramount for the proper configuration of the mathematical model, endowing it with the crucial ability to generalize from the data. This generalization capability ensures the model can accurately estimate the desired magnitude even when confronted with widely varying input data. To achieve this, the entire dataset, comprising the reflectance spectra and absolute humidity measurements of the baby leaf samples, is partitioned into three distinct subsets: 70% for training, 20% for validation, and 10% for testing. During the training phase, the chosen model is fitted using both the predictors (i.e., wavelengths) and the response data (i.e., the associated moisture values). This process enables the model to construct optimal fitting functions, according to the selected regression model, with the objective of maximizing the adjusted coefficient of determination (\(R_{adj}^{2}\)) and minimizing the root mean square error (RMSE). \[R_{adj}^{2}=1-\left(\frac{N-1}{N-p}\right)\frac{SSE}{SST}\]  
where N is the number of observations, \(p\) is the number of regression parameters (for example, for linear regression \(p\) = 2), SSE represents the sum of quadratic errors and SST represents the total quadratic sum. \[RMSE=\sqrt{\frac{1}{N}\frac{N}{i=1}\lvert p_{i}-y_{i}\rvert^{2}}\]  
where N is the number of observations, \(p_{i}\) are the ith predicted values from the model, and \(y_{i}\) are the ith experimental values. The validation phase, on the other hand, involves verifying the performance of the trained model using a validation scheme. The method employed is k-fold validation, which entails partitioning the validation dataset into \(k\) subsets, where each subset contains elements exclusive to itself. The model then performs data training (using the training set) and evaluates the performance of the model with each of the k validation subsets. Finally, the prediction error for each k set is determined. In particular, the k-fold validation method was performed with k = 5, to obtain the highest reliability of the model in terms of the generalization of the response when predicting the moisture data from the hyperspectral data. To proceed with the second strategy (i.e., classification), a statistical classifier using a supervised nonparametric algorithm of the KNN (k-nearest neighbors) type was chosen. The classifier, like the regression model, requires a training, validation, and testing phase. The same wavelengths determined for the regression model were used to compute the data. The performance evaluation of the classifier is performed by constructing the confusion matrix. This is a matrix that compares the actual classes with the classes determined by the classification model.