## 3 Results and Discussion
### Random Forest Models Based on Feature Extraction
The highest classification accuracy (0.91) was obtained with S-G parameters (d = 2, p = 2, w = 13), yielding 980 features, suggesting that the S-G pre-processing step effectively reduced noise and highlighted relevant spectral features. Interestingly, the accuracy was reduced when the window size w = 12 was used, particularly for p = 3, resulting in a much lower accuracy (0.87). Additionally, for the case of a t = 0.001 threshold value, 58 samples (out of a total of 192) were used to test the trained models. The misclassification rate for the generated models during testing ranged from 6/58 to 10/58 samples. For the case of a t = 0.0001 threshold value, the misclassification rate for the generated models during testing ranged from 5/58 to 8/58 samples. For external validation data with feature importance thresholds set at 0.001 and 0.0001, the approach focused on testing the RF model's ability to generalize to olive oil spectral data not included in model development (unseen data). The results are shown in the last columns of Tables 3 and 4, respectively. For t = 0.001 the highest accuracy of 0.91 was obtained for the S-G smoothing parameters d = 2, p = 3, and w = 12, as well as for d = 2, p = 2, and w = 13, indicating an alignment in the performance of the prediction on unseen data (Table 5). For the two datasets, the confusion matrices are given below. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**S-G Parameters** & **Original Features** & **Important Features** & **Accuracy (Testing)** & **Accuracy (External Validation)** \\ \hline Without S-G & 3164 & 963 & 0.88 & 0.87 \\ d = 2, p = 2, w = 11 & 3164 & 930 & 0.88 & 0.76 \\ d = 2, p = 3, w = 11 & 3164 & 930 & 0.84 & 0.83 \\ d = 2, p = 2, w = 12 & 3164 & 960 & 0.86 & 0.74 \\ d = 2, p = 3, w = 12 & 3164 & 958 & **0.90** & 0.87 \\ d = 2, p = 2, w = 13 & 3164 & 980 & 0.84 & **0.91** \\ d = 2, p = 3, w = 13 & 3164 & 982 & 0.86 & 0.83 \\ \hline \hline \end{tabular}  
* S-G: Savitzky–Golay; d: derivative order; p: polynomial order; w: window size.  
\end{table} 
Table 4: Results of the RF models developed on the FTIR spectral data based on different pre-processing techniques using 0.0001 as the feature importance threshold together with classification accuracies obtained in both testing and external validation. For the second threshold of t = 0.0001, the highest accuracy of 0.91 was achieved for d = 2, p = 2, and w = 13, and the second-highest accuracy of 0.87 was achieved for d = 2, p = 3, and w = 12, which is the same as in the dataset that was used for model development without S-G pre-processing (Table 6). It can be concluded that both thresholds provide a stable model with high performance on unseen data for the same smoothing parameters applied on the FTIR spectra. Table 6 lists the two confusion matrices for t = 0.0001. The spectral features responsible for the classification in all cases are the bands located near 1744 cm\({}^{-1}\) (i.e., 1739, 1748, and 1751 cm\({}^{-1}\)), related to the carbonyl groups present in triacylglycerlecrols (C=O), the fingerprinting area 1250-1000 cm\({}^{-1}\) (i.e., 1088, 1094, 1116, 1123, 1124, 1158, 1162, 1236, 1240, and 1247 cm\({}^{-1}\)), which correspond to CH bending, and 1680 cm\({}^{-1}\), which is associated with unsaturated aldehydes. In the literature, FTIR spectroscopy has been used to distinguish vegetable oils from olive oils of different categories, varieties, and origins combined with PLS-DA. The characteristic spectral bands of triacylglycerlecrols containing unsaturated fatty acids have been observed to constitute the main basis of discrimination (3030-2800 cm\({}^{-1}\)) [26]. In another study, FTIR coupled with PCA was applied to discriminate the geographic origin of 84 monovarietal virgin olive oils from different Italian regions [27].