## 4 Results
### Tomato Detection Using Deep Learning Models  
As mentioned, the models required defining the best confidence threshold before evaluating their performance. Table 3 indicates the value of the confidence threshold that maximises the F1-Score for each model, finding the best balance between the Precision and Recall, optimising the number of TP's while avoiding the FP's and FN's. Both models found their best F1-Score at similar confidence thresholds, i.e., similar confidence in their predictions. However, the YOLOv4 model achieved a better F1-Score of 86%. Figure 8 reports the evolution of the F1-Score with the variation of the confidence threshold for cross-validation. It is possible to infer that the models behave slightly different. Models with flattened curves indicate higher confidence in their predictions and a low amount of FPs and FNs. Such is the case with the SSD MobileNet v2 model. Despite having \begin{table}
\begin{tabular}{l c c} \hline \hline
**DL Models** & **Conf. Threshold**\(\geq\) & **F1-Score** \\ \hline SSD MobileNet v2 & 56\% & 74.16\% \\ YOLOv4 & 58\% & 86.01\% \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Confidence threshold for each DL model that optimises the F1-Score metric. Figure 7: Correlation between the Hue histogram Gaussian mean of each sample with its respective class, along with the plot of the tendency line, equation and R\({}^{2}\) of the quadratic function obtain. a lower F1-Score, it is more consistent, as it can maintain essentially the same F1-Score value over the confidence threshold. The previous analysis provided the benchmark in the validation set. The results presented below refer to the benchmarking of the test set that allows understanding the generalisation capacity of the trained DL models. Table 4 shows the results across the different metrics, considering all the predictions and the best-computed confidence threshold. Lower confidence rates tend to have lower Precision but a higher Recall rate. Hence, limiting the confidence threshold can become an advantage, as can be seen by the YOLOv4 model results. When the model has full freedom to make predictions (confidence threshold \(\geq\) 0), it presents a Recall up to 96%, but a Precision only around 16%, drastically affecting the F1-Score. However, by limiting the confidence threshold, the model could obtain a higher Precision without harming the Recall rate too much (still above 84%), thus obtaining an excellent F1-Score. Another important aspect is the inference time, quite similar in both models, with a slight advantage for the SSD MobileNet v2 model (0.067 s), reaching good and expected values considering that we are talking about one-stage detectors. Figure 9 shows a Precision x Recall curve built using all the predictions. The best performing model has the highest AUC, therefore the YOLOv4 model. However, the low Precision at higher Recall rates and the lower F1-Score indicates that the model has much prediction noise and false positives. Thus, considering all the model predictions, using the F1-score as a balanced metric between the Recall and Precision, SSD MobileNet v2 was the best performing model, with an F1-Score of 74.03%. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**DL Models** & **Conf. Threshold \(\geq\)** & **Inference Time** & **mAP** & **Precision** & **Recall** & **F1-Score** \\ \hline SSD MobileNet v2 & 0\% & 0.067 s & 67.82\% & 74.76\% & 73.72\% & 74.03\% \\ YOLOv4 & 0\% & 0.073 s & 90.02\% & 16.45\% & 95.84\% & 28.07\% \\ \hline SSD MobileNet v2 & 56\% & 0.067 s & 65.38\% & 77.62\% & 70.12\% & 73.68\% \\ YOLOv4 & 58\% & 0.073 s & 82.97\% & 86.73\% & 84.90\% & 85.81\% \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Detection results of the DL models over the evaluation metrics, considering all the predictions and the best computed confidence threshold. Figure 8: Evolution of the F1-score with the variation of the confidence threshold for both DL models in the validation set without augmentation.