# Tomato Maturity Estimation Using Deep Neural Network
## 4 Results and Discussion  
### Classification Performance  
The DNN-based maturity classifier was trained repeatedly, and Figure 4 shows the loss and classification accuracy curves by epoch. The loss curve expresses the total loss, which is the sum of the softmax, mean, and variance losses. Each graph shows the difference between the training and validation sets during repeated learning, and it can be seen that the curve shapes are similar for both the training and validation data. In terms of the total loss, a rapid decrease can be observed up to 10 epochs, and the loss became saturated with a value of approximately 0.05 at 60 epochs. The training was terminated at 100 epochs, as we did not observe a further significant decrease in the training and validation loss. The model weights were finally selected when the validation loss was minimal. The classification accuracies (CAs) increased to greater than 0.95 after 50 epochs in both training and validation.  
The losses for the training and validation sets were both saturated, indicating that the model could train the data without overfitting by using a network with appropriately sized parameters.  
Figure 5 shows the confusion matrix, represented using the classification results of the test set. In each box, two numbers are included: one is the number of corresponding samples, and the other (in parentheses) is the normalized value, which is divided by the total sample number of each class--that is, the sum of all samples of the corresponding row. In the cases of the green and red stages, the classes were composed of images of completely immature or fully mature tomatoes, respectively, and the percentage of correctly classified samples was 97-98% in each class. Meanwhile, the intermediate stages showed lower percentages. Samples in the turning and pink stages have mixed color skin, with colors ranging from green to red, making it difficult to determine the color boundary visually. For this reason, the classification performance was observed to be relatively low (at the level of 77-83%), due to the inaccuracy of the reserved labels [25].  
Table 1 provides an analysis of classification performance by class using the test set. The accuracies were observed to be high (greater than 0.95), with an average value of 0.97--a similar level to that obtained in previous research on tomato maturity classification [26]. When considering only the accuracy metric, incorrect predictions can be provided for the minority classes (i.e., those with a smaller sample number), although the model has high accuracy globally; thus, recall, precision, and F1 score were also calculated to evaluate the classification performance. Precision and recall can offer class-wise insight and, in particular, the F1 score, which is the harmonic mean of the precision and recall, can more accurately represent the performance for a data composition with high specific class  
Figure 4: Total losses and classification accuracies for training and validation samples by epoch.  
(red stage) occupancy, which is imbalanced [27]. Precision was observed in the range of 0.91-0.95, while recall was relatively low (around 0.8) in the intermediate stages. Therefore, the model can estimate class correctly; however, the sensitivity in detecting the target class was low. The F1 score was approximately 0.91 on average, with a range of 0.85-0.97.