# THz Data Analysis and Self-Organizing Map (SOM) for the Quality Assessment of Hazelnuts
## 4 Results
### Neural Networks Methods
Figure 7a shows a neural map with a hexagonal topology; specifically, the map highlights the positions of the neurons within the network, indicating how many observations are associated with each neuron. From the image, each neuron shows a number indicating the amounts of hazelnuts classified according to certain characteristics. In Figure 7b, the SOM Neighbor Weight Distances is shown; it precisely indicates the distances between neighboring neurons. The blue hexagons represent the neurons, while the colors visible in the map indicate the distances between neurons; darker colors represent larger distances, while lighter colors represent smaller distances. From Figure 8, it can be seen that the neural network has created a non-homogeneous group of neurons highlighted by the dark colors, in which rotten, shriveled and empty nuts fall. In contrast, the healthy hazelnuts fall in the yellow cluster. Figure 8: Distribution of hazelnuts according to their characteristics. It is clear from the image that the neural network was able to create two distinct clusters; rotten, shriveled and empty hazelnuts fall into the black neurons, while healthy hazelnuts were distributed in the yellow neurons. Figure 7: Neural map: (**a**) neural map with a hexagonal topology. In each neuron, a number relating to the type of hazelnut selected is reported; (**b**) the SOM Neighbor Weight Distances; neurons with a smaller distance are highlighted by the yellow color. In this homogeneous cluster fall the healthy hazelnuts, while in the non-homogeneous group of neurons highlighted by dark colors fall the empty, rotten and moldy hazelnuts. In this first test performed on fifty random hazelnuts, used as a neural network training test, it was seen how the unsupervised neural network was able to create two different clusters, one homogeneous and the other non-homogeneous. Most of the healthy hazelnuts fell into the homogeneous cluster. The following section will show the results of the largest data set. For the selection of one hundred and sixty-two hazelnuts, the neural network was first trained with a data set consisting of fifty hazelnuts, as reported above, in order to create a selection method. In the first step, the network was trained with fifty hazelnuts, while in the second and final step, the method was validated using a larger data set of one hundred and sixty-two hazelnuts. A map of the distribution of the second data set is shown below in Figure 9. \begin{table}
\begin{tabular}{c} **\%** \\ **Empty** \\ \end{tabular} \\ \hline
1 & 6 & 0 & 4 & 0 & 2 & 70\% & 10\% & 6\% & 14\% \\ \hline
2 & 17 & 17 & 0 & 0 & 0 & & & & \\ \hline
3 & 10 & 1 & 1 & 3 & 5 & & & & \\ \hline
4 & 17 & 17 & 0 & 0 & 0 & & & & \\ \cline{1-1} tot & 50 & 35 & 5 & 3 & 7 & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: 70% of the hazelnuts were healthy, 10% were rotten, 6% were shirveled, and finally 14% were empty. Figure 9: Distribution of the second data set within the neural network. From Figure 9, it can be seen that the rotten, shriveled and empty hazelnuts fall into the so-called bad neurons (black neurons), which are the same ones used by the network during the training process. The healthy hazelnuts, on the other hand, fall into the good neurons (yellow neurons), which are again the same ones used in the training process. Thus, in the black-colored neurons fall rotten, shriveled and empty hazelnuts, while in the yellow-colored neurons, only the healthy ones fall. Table 2 provides a summary of the results.