## 3 Results and Discussion
### Accuracy of the Hybrid ANN-GA Classifier  
The step prior to the classification of the apples is to look for the optimal configuration of the ANN. To obtain the optimal parameters of the MLP neural network, the training phase described in Section 2 was repeated 30 times. Table 5 shows the optimal values of the ANN parameters of the hidden layers. As can be seen, the optimal network has 2 layers with 4 and 25 hidden neurons, respectively.  
These parameters of Table 5 define an MLP that is considered optimal for the problem of interest. Table 6 shows the results of classification of this optimal ANN configuration using the confusion matrix. In this case, 19,520 object samples were used for training the network, 3877 for validation, and 3877 for testing.  
The system classified 741 out of the 753 samples belonging to the unripe class correctly (98.4% accuracy). On the other hand, the maximum misclassification rate was in the overripe class with a 2.46% error. Analyzing these errors, 25 samples out of the 30 incorrectly classified samples of Class 1 were misclassified in Class 2, and 17 samples of Class 2 were misclassified in Class 1. This means that  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Predicted/Real Class** & **1** & **2** & **3** & **4** & **All Data** & **Classification Error by Class (\%)** & **Classification Accuracy (\%)** \\ \hline
1 & 1268 & 25 & 5 & 0 & 1298 & 2.31 & \\ \hline
2 & 17 & 873 & 0 & 0 & 890 & 1.91 & \\ \hline
3 & 0 & 3 & 741 & 9 & 753 & 1.59 & \\ \hline
4 & 0 & 4 & 19 & 913 & 936 & 2.46 & \\ \hline \hline \end{tabular}
\end{table}
Table 6: Confusion matrix resulting from the classification of the ripening stage of the apples using the hybrid ANN-GA approach. Classes: 1. unripe; 2. half-ripe; 3. ripe; 4. overripe.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline Number of layers & 2 \\ \hline Number of neurons & 1 st layer: 4 \\  & 2 nd layer: 25 \\ \hline Transfer function & 1 st layer: Triangular basis \\  & 2 nd layer: Triangular basis \\ \hline Backpropagation training function & Gradient descent with momentum and adaptive learning rate \\ \hline Weight/bias learning function & Widrow–Hoff function \\ \hline \hline \end{tabular}
\end{table}
Table 5: Optimal parameters of the MLP neural network obtained in the artificial neural network–genetic algorithm (ANN-GA) hybrid approach for the classification of the ripening stages of the apples.  
the samples in these two classes, unripe and half-ripe, have very similar properties. Moreover, the same happens between Classes 3 and 4, ripe and overripe, but to a lower extent. From the 2.11% total error, up to 1.88% corresponds to an error of rank 1 (i.e., real class \(x\), predicted as \(x+1\) or \(x-1\)), only 0.23% to an error of rank 2, and there is no error of rank 3. This is a very interesting result, indicating that, even in the case of misclassification, the error committed by the system is not very high. For example, if a harvesting strategy is defined differentiating the stages before ripening (1 and 2) and after ripening (3 and 4), the probability of confusing both groups would be only 0.31% (12 samples). Finally, the classifier reached an overall accuracy of 97.88% over the test set. It has to be observed that the decisions using ripening information should be based on the global state of a tree or an area of the crop, not on individual fruits. Thus, the risk of applying an incorrect strategy would be extremely low.