## 2 Materials and Methods
### Feature Selection and Classification Using Random Forest  
RF is an ensemble machine learning algorithm that is particularly effective for classification and regression tasks [23]. It consists of multiple decision trees constructed during the training phase, and the final output is determined by aggregating the predictions of the individual trees, often using majority voting in classification scenarios. The primary strength of RF lies in its ability to handle high-dimensional data, mitigate overfitting, and identify the most relevant features by calculating feature importance scores based on their contribution to reducing impurity in the decision nodes. In this study, RF was employed both as a feature selection tool and classifier. First, the RF algorithm was used to identify the most critical features from the FTIR spectra that contributed to differentiating between EVOO and other olive oil categories. This feature selection step helped reduce the dimensionality of the dataset and enhanced the efficiency and accuracy of the subsequent classification task. The reduced set of important features was then utilized by the RF model to classify the olive oil samples based on their spectral data, with a focus on understanding the effects of pre-processing techniques, such as S-G smoothing, on model performance. The performance of the models was assessed by the calculation of recall, precision, accuracy, and F1 score indices. Recall indicates the capacity of the model to accurately identify actual observations which are predicted correctly, i.e., how many observations of positive class (EVOO in our case) are actually predicted as positive. Precision is defined as the ratio of the total number of correctly classified positive classes divided by the total number of predicted positive classes. It is a useful metric in cases where false positives (i.e., olive samples from the \"other\" class are classified as \"EVOO\") are of higher concern than false negatives. Accuracy indicates how often the classifier makes the correct prediction, and it is the ratio between the number of correct predictions over the total number of predictions. F1 score is a machine learning evaluation metric that takes values between 0 and 1, and it is the harmonic mean of precision and recall. The higher the F1 score, the better the predictiveperformance of the model. Finally, the accuracy index evaluates the overall effectiveness of the classifier [24; 25].  
In this study, the RF technique, implemented in Python version 3.12, was used as a supervised machine learning algorithm for both feature selection and classification. RF operates by constructing multiple decision trees during training and aggregating their outputs to enhance predictive accuracy and reduce overfitting. The algorithm excels in handling high-dimensional data and assessing feature importance based on their contribution to reducing impurity at decision nodes. In our implementation, 100 estimators were used, that is, trees and the Gini impurity criterion, to measure the quality of a split when constructing the trees. For feature extraction, we tested several 'threshold' variables to retain the features. Our reported results are for threshold values of 0.001 and 0.0001 for both training our model and for validating it using the additional data set of samples, as described in Table 2.