## 7 Evaluation of the Model and Clustering of RF Signals
### Clustering RF Signals  
An interesting issue is the automatic clustering of radio signals detected and evaluated in the proposed model. We decided to evaluate the performance of clustering using hierarchical clustering, specifically agglomerative clustering [26; 27]. Agglomerative clustering [26; 27] is a hierarchical clustering algorithm that starts by considering each data point as an individual cluster. It iteratively merges the closest pairs of clusters based on a similarity measure until all data points belong to a single cluster. The algorithm begins by calculating the distance or similarity between each pair of data points and creates a proximity matrix. It then identifies the two closest clusters based on the proximity matrix and merges them into a new cluster. The process continues until all data points are part of a single cluster. The challenge of clustering in datasets with an unknown number of clusters requires setting a threshold value \(\lambda\), similar to the simple method of finding similar signals. The implementation of agglomerative clustering [26; 27] was obtained from the Scikit library [28]. An example of the model's operation, along with agglomerative clustering, is demonstrated using spectrogram 000303, which is shown in Figure 10. There are six visible signals, where 0 and 1 correspond to LSB, 2, 3, and 4 correspond to FM, and 5 corresponds to AM. The distance matrix between signals is presented in Equation (9). With the distance matrix, the similarity matrix can be calculated as shown in Table 2. On the other hand, similar signals have been color-coded in Figure 11.  
\[A_{m,n}= \begin{pmatrix}0.00&8.51&36.70&39.30&36.27&20.72\\ 8.51&0.00&32.89&35.87&32.48&19.84\\ 36.70&32.89&0.00&5.69&0.90&24.89\\ 39.30&35.87&5.69&0.00&6.46&27.79\\ 36.27&32.48&0.90&6.46&0.00&24.32\\ 20.72&19.84&24.89&27.79&24.32&0.00\\ \end{pmatrix}  \tag{9}\]  
However, not all signals can be easily distinguished, as shown in the example spectrogram 000381, depicted in Figure 12a, where signals 0, 1, and 2 represent AM, signal 3 represents WBFM, and signals 4-11 represent USB. In Figure 12b, visualizations of similar signals after hierarchical clustering with an RI of 0.84 are presented. Figure 10: Spectrogram 000303 (fft_size 2048, samp_rate \(17.5\times 10^{6}\), and length = 0.75 s) with detected signals from the rfspec-db database [22]). As observed, the FM signal (3) is correctly distinguished from the others (highlighted in yellow), a portion of the AM signal (highlighted in blue) as well as the USB signals (highlighted in orange) are also correctly detected as separate signals. However, there are overlapping detections of signals 1, 11, 4, 5, 7, 8, and 9 that are not grouped with either USB or AM, even though signal 1 is actually an AM signal, and the rest are USB signals. This may be attributed to various factors. Firstly, during evaluation, only a segment of the signal with a maximum duration of 96 pixels was sampled, whereas in reality, the signal is much longer. One potential solution could be to extract all subspectrograms composing the signal and calculate the average of the latent vector. Another significant aspect is the low resolution of the spectrograms and analog modulation signals, such as in the case of SSB modulation. For instance, a long constant tone in SSB modulation on the spectrogram may appear similar to AM or CW modulation.